Skip to main content
Prem API exposes client-encrypted chat and audio routes. Use the TypeScript SDK directly, or run the bundled Confidential Proxy for the documented OpenAI- and Anthropic-compatible routes.
If you use an AI coding agent, load Prem API into the context of your agent with one command. See Use LLMs.

Use the Prem API SDK

1. Create an API key

  1. Open the dashboard. Sign in or register.
  2. Go to the API section.
  3. Create a new API key. Copy the key to a safe location.
Store the API key in an environment variable, for example PREM_API_KEY. Do not commit the API key to source control.

2. Install the SDK and make your first call

Install the TypeScript SDK from npm:
The SDK runs natively on Node.js, Bun, Deno, and Bare. It needs no native add-ons. You use one client library across all of them, from a backend service to a mobile app. See the React Native guide.
Then use this code to initialize the client and call the API:
You must set all four environment variables. CLIENT_KEK is your Key Encryption Key (KEK). The SDK expects a 32-byte key encoded as exactly 64 hexadecimal characters. The KEK protects your encryption keys and does not leave your device. See Encryption.
Store the KEK in a secret manager and reuse it. Do not regenerate it on each process start.
Get the latest endpoint values from dashboard.prem.io/endpoints.json.

3. Run a request

Run your script. The console shows the response.
For error codes and HTTP conventions, see Errors. For request limits, see Rate limits.

Use the OpenAI SDK

Run the bundled Confidential Proxy to expose OpenAI-compatible routes on your machine. Point the baseURL of an OpenAI client at the Confidential Proxy.
The current CLI reads PROXY_URL and ENCLAVE_URL from the environment. Pass the KEK with --kek; CLIENT_KEK is not currently bound as a CLI environment option.
Get the latest endpoint values from dashboard.prem.io/endpoints.json.
When the Confidential Proxy runs, install the OpenAI JavaScript SDK. Point the SDK at your local /v1 URL. The client sends your API key as the bearer token with each request:
See Confidential Proxy for all proxy options: Anthropic compatibility, daemon mode, and the full configuration.

Verify the selected route

Model-list and completion responses expose the requested alias and, for OpenAI-format completions, the resolved model ID. They do not expose an assurance profile. Do not classify a route from its model name. For glm-5.2, the completion response returns the resolved backend ID in response.model. See Platform Status for the current assurance boundary.

Next steps

API reference

Chat completions and other endpoints in detail.

Guides

Step-by-step guides for common flows (chat, audio, and more).

Models & Pricing

Available models, pricing tiers, and deployment strategies.

Agents & Automation

Building a bot, agent loop, or batch job? The config and gotchas that matter unattended.