> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prem.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Send chat and audio requests with client-side encryption through the Prem SDK or local proxy.

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.

> [!NOTE]
>
> The Prem API has two inference modes. This page tells you about **confidential inference**. See [Zero Data Retention](https://docs.prem.io/zdr/overview.md) for an OpenAI-compatible endpoint that needs no code changes. See the [comparison](https://docs.prem.io/zdr/comparison.md) to choose a mode.

> [!TIP]
>
> If you use an AI coding agent, load Prem API into the context of your agent with one command. See [Use LLMs](https://docs.prem.io/use-llms.md).

## Use the Prem API SDK

### 1. Create an API key

1. Open the [dashboard](https://dashboard.prem.io). Sign in or register.
2. Go to the [API](https://dashboard.prem.io/api-keys) 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:

```bash theme={"system"}
npm install @premai/api-sdk@1.0.70
```

> [!NOTE]
>
> The SDK runs natively on Node.js, Bun, Deno, and [Bare](https://github.com/holepunchto/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](https://docs.prem.io/guides/react-native.md).

Then use this code to initialize the client and call the API:

```typescript theme={"system"}
import { createRvencClient } from "@premai/api-sdk";

async function main() {
  const apiKey = process.env.PREM_API_KEY;
  const clientKEK = process.env.CLIENT_KEK;
  if (!apiKey || !clientKEK) {
    throw new Error("Set PREM_API_KEY and CLIENT_KEK");
  }

  const client = await createRvencClient({ apiKey, clientKEK });
  const response = await client.chat.completions.create({
    model: "deepseek-v4.1-flash-1017",
    messages: [{ role: "user", content: "Reply with exactly OK." }],
    max_completion_tokens: 128,
  });

  console.log(response.choices[0]?.message?.content);
  console.log("Resolved model:", response.model);
}

main().catch((error) => {
  console.error(error);
  process.exitCode = 1;
});
```

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](https://docs.prem.io/encryption.md).

```bash theme={"system"}
export PREM_API_KEY="your-api-key"
export CLIENT_KEK="$(openssl rand -hex 32)"
export PROXY_URL="https://gateway.prem.io"
export ENCLAVE_URL="https://conf-engine.prem.io"
```

Store the KEK in a secret manager and reuse it. Do not regenerate it on each process start.

> [!NOTE]
>
> Get the latest endpoint values from [`dashboard.prem.io/endpoints.json`](https://dashboard.prem.io/endpoints.json).

### 3. Run a request

Run your script. The console shows the response.

> [!TIP]
>
> For error codes and HTTP conventions, see [Errors](https://docs.prem.io/errors.md). For request limits, see [Rate limits](https://docs.prem.io/rate-limits.md).

## 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.

```bash theme={"system"}
npx -p @premai/api-sdk@1.0.70 confidential-proxy \
  --compat openai \
  --kek "$CLIENT_KEK"
```

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.

> [!NOTE]
>
> Get the latest endpoint values from [`dashboard.prem.io/endpoints.json`](https://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:

```typescript theme={"system"}
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.PREM_API_KEY!,
  baseURL: "http://127.0.0.1:8787/v1",
});

const stream = await client.chat.completions.create({
  model: "deepseek-v4.1-flash-1017",
  messages: [{ role: "user", content: "Hello!" }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || "");
}

```

> [!TIP]
>
> See [Confidential Proxy](https://docs.prem.io/confidential-proxy.md) 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 `deepseek-v4.1-flash-1017`, the completion response returns the resolved backend ID in `response.model`. See [Platform Status](https://docs.prem.io/platform-status.md) for the current assurance boundary.

## Next steps

> [card] [API reference](https://docs.prem.io/api-reference/chat-completions.md)
>
> Chat completions and other endpoints in detail.

> [card] [Guides](https://docs.prem.io/guides/chat-completion.md)
>
> Step-by-step guides for common flows (chat, audio, and more).

> [card] [Models & Pricing](https://docs.prem.io/models-and-pricing.md)
>
> Available models, pricing tiers, and deployment strategies.

> [card] [Agents & Automation](https://docs.prem.io/agents.md)
>
> Building a bot, agent loop, or batch job? The config and gotchas that matter unattended.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.