@premai/api-sdk. It exposes OpenAI and Anthropic compatible HTTP routes on your machine and handles all end-to-end encryption transparently. Point any OpenAI or Anthropic client at it by changing a single base URL — no SDK changes, and it works from any language (Python, Go, Java, …).
How it works
The proxy runs on your machine and performs the same client-side encryption the SDK does. Your plaintext is encrypted before it leaves the proxy, so the Prem API Gateway only ever sees ciphertext and decryption happens inside the enclave’s Trusted Execution Environment. For the full cryptographic design — XWing key exchange, the two-server model, and the threat model — see Encryption.Running the server
Run the proxy directly withbunx or npx (no install required), or install it globally:
http://127.0.0.1:8000.
Set
PROXY_URL and ENCLAVE_URL to the values for your environment. Get the latest from dashboard.prem.io/endpoints.json.Configuration
The proxy is configured through environment variables or CLI flags (flags take precedence).Environment variables
| Variable | Required | Default | Description |
|---|---|---|---|
ENCLAVE_URL | Yes | — | Enclave endpoint that decrypts and runs inference |
PROXY_URL | Yes | — | Prem API Gateway endpoint that routes encrypted payloads |
CLIENT_KEK | Yes | — | Your Key Encryption Key — wraps DEKs (32 bytes, base64) |
JSON_BODY_LIMIT | No | 32mb | Max request body size |
HOST | No | 127.0.0.1 | Interface to bind |
PORT | No | 8000 | Port to listen on |
CONFIDENTIAL_PROXY_LOG_LEVEL | No | info | error, warn, info, http, verbose, debug, or silly |
CLI options
All commands accept the same server options:Compatibility modes
Choose which API surface to expose with--compat:
| Mode | Routes | Description |
|---|---|---|
openai | /v1/* | OpenAI-compatible API only |
anthropic | /v1/* | Anthropic-compatible Messages API only |
both | /openai/v1/* and /anthropic/v1/* | Both APIs side-by-side under separate prefixes |
both mode the two APIs are served under separate prefixes to avoid route conflicts. The Anthropic surface translates incoming Anthropic Messages requests into the internal OpenAI-compatible enclave pipeline, then pipes the response back as Anthropic SSE events.
Connecting a client
OpenAI
Point any OpenAI-compatible client at the proxy’s/v1 base URL and send your Prem API key as a bearer token:
Anthropic
When running with--compat anthropic (or both), the proxy exposes an Anthropic-compatible Messages API. Authenticate with x-api-key and send the anthropic-version header:
"stream": true for incremental responses:
temperature, and top_p. Streaming responses follow the Anthropic SSE format (message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop).
Running as a daemon
Beyond the default foreground mode, the CLI can manage the proxy as a background daemon.| Command | Description |
|---|---|
confidential-proxy | Run in the foreground, attached to the terminal |
confidential-proxy start | Start the server as a background daemon |
confidential-proxy stop | Gracefully stop the running daemon |
confidential-proxy status | Check whether the daemon is running and reachable |
start
Checks for an existing PID file (refusing to start a duplicate), spawns itself as a child process with logs directed to the configured log file, writes a PID file, and polls the HTTP endpoint until the server is reachable — then exits, leaving the daemon running.
stop
Sends
SIGTERM and waits up to 5 seconds for graceful shutdown. If the process is still alive, it escalates to SIGKILL and cleans up the PID file.start / stop / status):
| Option | Default | Description |
|---|---|---|
--pid-file | <data-dir>/proxy.pid | Custom PID file path |
--log-file | stdout/stderr | File to write daemon logs (with start) |
--log-level | info | Log verbosity (error … silly) |
--shutdown-timeout | 30000 | Max ms to wait for in-flight requests during graceful shutdown |
Next steps
Chat completions
The chat API in detail, with streaming and vision payloads.
Encryption
How key exchange and end-to-end encryption work.
The same proxy powers
confidential-claude, a convenience integration shipped in the SDK that launches Claude Code wired to the encrypted gateway. All traffic runs through this proxy.
