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

# Router

> Use Router to access a curated model catalog through an OpenAI-compatible API.

<Badge color="blue">Beta</Badge>

Router is a beta service that provides access to a curated model catalog through an OpenAI-compatible API.

<Info>
  Router currently exposes a broader chat-model catalog than the Confidential API catalog documented on this site. The tradeoff is explicit: Router requests are not confidential. Use the Confidential API for sensitive data and use Router when model breadth is the priority.
</Info>

<Warning>
  Router is not confidential. Do not send secrets, personal data, regulated
  data, or other sensitive data. Use [Prem API](/quickstart) for confidential
  processing.
</Warning>

Router uses the Chat Completions API. All models accept text. Selected models accept base64 images. The model catalog and API behavior can change during the beta.

## Request an API key

[Contact us](/contact-us) to request a Router API key. Include `Router access` in your message.

Store the key in an environment variable. Do not commit it to source control.

```bash theme={"system"}
export PREM_ROUTER_API_KEY="your-api-key"
```

The Router key is separate from the Confidential API key. `PREM_ROUTER_API_KEY` and `PREM_API_KEY` are not interchangeable.

## Make your first request

### Python

Install the OpenAI Python SDK:

```bash theme={"system"}
pip install openai
```

Create a Python file with this code:

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

client = OpenAI(
    api_key=os.environ["PREM_ROUTER_API_KEY"],
    base_url="https://router.prem.io/v1",
)

response = client.chat.completions.create(
    model="kimi-k3",
    messages=[
        {
            "role": "user",
            "content": "What can you help me build?",
        }
    ],
)

print(response.choices[0].message.content)
```

Run the file. The response appears in your terminal.

### Node.js test

Use Node.js 22 or later. Install the OpenAI JavaScript SDK:

```bash theme={"system"}
npm install openai
```

Create a file named `router.test.mjs`:

```javascript theme={"system"}
import assert from "node:assert/strict";
import test from "node:test";
import OpenAI from "openai";

const apiKey = process.env.PREM_ROUTER_API_KEY;
if (!apiKey) {
  throw new Error("Set PREM_ROUTER_API_KEY before you run this test.");
}

const client = new OpenAI({
  apiKey,
  baseURL: "https://router.prem.io/v1",
  maxRetries: 0,
  timeout: 120_000,
});

test("Router returns a chat completion", async () => {
  const response = await client.chat.completions.create({
    model: "kimi-k3",
    messages: [
      {
        role: "user",
        content: "Reply with exactly: Router is working",
      },
    ],
  });

  assert.equal(response.model, "kimi-k3");
  assert.equal(response.choices[0].message.role, "assistant");
  assert.match(response.choices[0].message.content ?? "", /\S/);
});
```

Run the live test:

```bash theme={"system"}
node --test router.test.mjs
```

## Models

Model availability, context windows, capabilities, and streaming requirements
can differ by API key. Use authenticated `GET /v1/models` as the source of
truth, then send an exact model ID from that response in your chat request.

Router currently exposes a broader chat-model catalog than the Confidential
API. This comparison is about catalog breadth, not confidentiality or model
quality. A model listed for Router is not evidence that the same model runs in
a confidential enclave.

See [Models](/router/models) for the base catalog, additional key-dependent
models, modality support, and streaming requirements.

<CardGroup cols={3}>
  <Card title="Models" icon="cube" href="/router/models" arrow="true">
    Browse model IDs and check which models are available to your API key.
  </Card>

  <Card title="API capabilities" icon="code" href="/router/capabilities" arrow="true">
    Use tool calls, structured output, reasoning, vision, log probabilities, and usage reporting.
  </Card>

  <Card title="Add a custom provider" icon="terminal" href="/router/integrations" arrow="true">
    Configure Router in OpenCode, Pi, and other OpenAI-compatible tools.
  </Card>
</CardGroup>
