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

# Developer Experience

> What it is like to build on Prem API: SDK integration and OpenAI compatibility.

<Info>
  **You do not need encryption knowledge.** The encryption layer is not visible in your application code. If you used the OpenAI API before, you know how to use Prem API. The SDK does all cryptography automatically. You write normal API calls and you get normal responses.
</Info>

## Two Ways to Integrate

### Option 1: Prem API TypeScript SDK (Recommended)

Install the SDK. Use it like an OpenAI client:

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

const client = await createRvencClient({
  apiKey: process.env.PREM_API_KEY,
  clientKEK: process.env.CLIENT_KEK, // Your master key. You generate it, we never see it
});

// This looks exactly like an OpenAI call, because it is
const chat = await client.chat.completions.create({
  model: "deepseek-v4-pro",
  messages: [
    { role: "system", content: "You are a helpful assistant." },
    { role: "user", content: "Summarize this quarterly report." },
  ],
  stream: true,
});

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

The SDK does these steps for you:

* It encrypts your messages before it sends them.
* It does a secure key exchange with the enclave.
* It decrypts each streaming chunk when the chunk arrives.

You do not see these steps. Your code looks like an OpenAI integration.

### Option 2: Confidential Proxy (Any Language)

The SDK includes the Confidential Proxy, a local server that does all encryption for you. Use it for Python, Go, Java, or other languages with an OpenAI-compatible client library:

```bash theme={"system"}
# Start the local proxy (one command)
bunx -p @premai/api-sdk confidential-proxy --kek $CLIENT_KEK
```

Then point your existing code at `localhost`:

```python theme={"system"}
from openai import OpenAI

# Your existing OpenAI code. Just change the base URL
client = OpenAI(
    base_url="http://localhost:8000/v1",
    api_key="your-api-key",
)

response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Hello, privately."}],
)
```

You make **zero code changes** to your application logic. The Confidential Proxy encrypts outbound requests and decrypts responses automatically. See [Confidential Proxy](/confidential-proxy) for the full configuration and Anthropic support.

## What You Can Do

### Chat with AI Models

The chat API is OpenAI-compatible. It includes these features:

| Feature                      | Details                                                                    |
| ---------------------------- | -------------------------------------------------------------------------- |
| **Streaming**                | Output in real time, word by word. Prem API encrypts each chunk separately |
| **JSON mode**                | Structured output for reliable parsing                                     |
| **System messages**          | Control the behavior and personality of the model                          |
| **Multi-turn conversations** | Full conversation history and context management                           |
| **Audio transcription**      | Convert speech to text (Whisper, Deepgram)                                 |
| **Audio translation**        | Translate audio to English                                                 |

## Error Handling

Prem API uses standard HTTP status codes with structured error responses:

| Code | What It Means            | What to Do                                                        |
| ---- | ------------------------ | ----------------------------------------------------------------- |
| 400  | Invalid request format   | Check your input against the API spec                             |
| 401  | Invalid API key          | Make sure that your API key is correct and active                 |
| 403  | Insufficient permissions | Check the scopes of your API key                                  |
| 429  | Rate limited             | Use exponential backoff (examples in [Rate Limits](/rate-limits)) |
| 503  | Temporarily unavailable  | Wait, then send the request again                                 |

Each error includes a `support_id`. Give this ID to the Prem team to help with debugging.

## Rate Limits

Rate limits apply to each organization, across four dimensions:

| Dimension                     | What It Limits                 | Why                                                     |
| ----------------------------- | ------------------------------ | ------------------------------------------------------- |
| **RPS** (Requests per second) | How fast you can send requests | Prevents bursts that overload the system                |
| **TPM** (Tokens per minute)   | Total token throughput         | Manages inference capacity                              |
| **Concurrent**                | Simultaneous active requests   | Makes sure that all users get a fair share of resources |

Limits increase across the tiers (Free, Tier 1, Tier 2, Tier 3) when your usage grows. See [Rate Limits](/rate-limits) for the values and for retry strategies with code examples.

<Note>
  See the [Quickstart](/quickstart) for the step-by-step setup. See the [Guides](/guides/chat-completion) for examples that you can copy.
</Note>
