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

> Build with Prem's confidential AI APIs: secure LLM inference with chat completions, audio transcription, and encryption. Start in 5 minutes.

Prem API is an **end-to-end encrypted**, **OpenAI-compatible** API. It gives chat, audio, and model endpoints with the same request shapes as OpenAI. Use the TypeScript SDK, or run the bundled **Confidential Proxy** and connect with an OpenAI client. You can start with a few lines of code.

<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
```

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

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

const client = await createRvencClient({
  apiKey: process.env.PREM_API_KEY!,
  clientKEK: process.env.CLIENT_KEK!,
});

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

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

You must set all four environment variables. `CLIENT_KEK` is your Key Encryption Key (KEK). The KEK is a 32-byte base64 secret that you generate and keep. The KEK protects your encryption keys and does not leave your device. See [Encryption](/encryption). Add the variables to your `.env` file:

```bash theme={"system"}
PREM_API_KEY=your-api-key
CLIENT_KEK=your-client-kek
PROXY_URL=https://gateway.prem.io
ENCLAVE_URL=https://conf-engine.prem.io
```

<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. You do not change the SDK.

```bash theme={"system"}
bunx -p @premai/api-sdk confidential-proxy
```

Configure the Confidential Proxy with these environment variables. Add them to your `.env` file:

```bash theme={"system"}
PROXY_URL=https://gateway.prem.io
ENCLAVE_URL=https://conf-engine.prem.io
CLIENT_KEK=your-client-kek
```

<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:8000/v1",
});

const stream = await client.chat.completions.create({
  model: "deepseek-v4-pro",
  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>

## 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>
</CardGroup>
