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

<Tip>
  If you use an AI coding agent, load Prem API into the context of your agent with one command. See [Use LLMs](/use-llms).
</Tip>

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

<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](/guides/react-native).
</Note>

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: "glm-5.2",
    messages: [{ role: "user", content: "Reply with exactly OK." }],
    reasoning_effort: "none",
    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](/encryption).

```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).
</Note>

### 3. Run a request

Run your script. The console shows the response.

<Tip>
  For error codes and HTTP conventions, see [Errors](/errors). For request limits, see [Rate limits](/rate-limits).
</Tip>

## 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.59 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).
</Note>

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: "glm-5.2",
  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](/confidential-proxy) for all proxy options: Anthropic compatibility, daemon mode, and the full configuration.
</Tip>

## 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](/platform-status) for the current assurance boundary.

## Next steps

<CardGroup cols={3}>
  <Card title="API reference" icon="book" href="/api-reference/chat-completions" arrow="true">
    Chat completions and other endpoints in detail.
  </Card>

  <Card title="Guides" icon="book-open" href="/guides/chat-completion" arrow="true">
    Step-by-step guides for common flows (chat, audio, and more).
  </Card>

  <Card title="Models & Pricing" icon="tags" href="/billing/models-and-pricing" arrow="true">
    Available models, pricing tiers, and deployment strategies.
  </Card>

  <Card title="Agents & Automation" icon="robot" href="/agents" arrow="true">
    Building a bot, agent loop, or batch job? The config and gotchas that matter unattended.
  </Card>
</CardGroup>
