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

> Get started with the Prem API

Prem API is an **end-to-end encrypted**, **OpenAI-compatible** API: chat, audio, and models behind the same familiar request shapes. Use the TypeScript SDK, or run the bundled **local proxy** and connect with any OpenAI client — you can be up and running in a few lines of code.

<Tip>
  Using an AI coding agent? Load Prem API into your agent's context with one command. See [Use LLMs](/basics/troubleshooting/use-llms).
</Tip>

## Using the Prem API SDK

## 1. Create an API key

1. Open the [Dashboard](https://dashboard.prem.io) and sign in (or register).
2. Go to the [API](https://dashboard.prem.io/api-keys) section.
3. Create a new API key and copy it somewhere safe.

Store the key in an environment variable (for example `PREM_API_KEY`) and avoid committing it 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 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!,
});

const stream = await client.chat.completions.create({
  model: "openai/gpt-oss-120b",
  messages: [{ role: "user", content: "Hello!" }],
  stream: true,
});

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

All three environment variables are required. Add them to your `.env` file:

```bash theme={"system"}
PREM_API_KEY=your-api-key
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

That's it — run your script and you should see a response printed to the console.

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

## Using the OpenAI SDK

You can run a small Express server that exposes OpenAI compatible routes. Any OpenAI client can point its `baseURL` at this server — no SDK changes required.

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

All three environment variables are required. Add them to your `.env` file:

```bash theme={"system"}
PREM_API_KEY=your-api-key
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>

With the proxy running, install the OpenAI JavaScript SDK and point it at your local `/v1` URL:

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

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

const stream = await client.chat.completions.create({
  model: "openai/gpt-oss-120b",
  messages: [{ role: "user", content: "Hello!" }],
  stream: true,
});

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

```

## Next steps

<CardGroup cols={2}>
  <Card title="API reference" icon="book" href="/developer-resources/reference/rvenc/chat-completions">
    Chat completions and other endpoints in detail.
  </Card>

  <Card title="Recipes" icon="book-open" href="/recipes/overview">
    Step-by-step guides for common flows (chat, audio, and more).
  </Card>
</CardGroup>
