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

# Prem Router (Beta)

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

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

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

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

## 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("Prem 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
```

## Available models

The following models are currently available:

| Model ID          | Family   | Context window | Streaming |
| ----------------- | -------- | -------------- | --------- |
| `kimi-k3`         | Kimi     | 1M tokens      | Optional  |
| `qwen-3.7-max`    | Qwen     | 1M tokens      | Required  |
| `qwen-3.7-plus`   | Qwen     | 1M tokens      | Required  |
| `qwen-3.6-plus`   | Qwen     | 1M tokens      | Required  |
| `qwen-3.5-9b`     | Qwen     | 262K tokens    | Optional  |
| `deepseek-v4-pro` | DeepSeek | 512K tokens    | Optional  |

For models marked **Required**, set `stream=True` in Python or `stream: true` in JavaScript.

Use the exact lowercase model ID in every API request. Call `GET /v1/models`
with your API key to retrieve the current catalog; availability may change
during the beta.

See [API capabilities](/router/capabilities) for tools, structured output, reasoning controls, vision, and log probabilities.

<CardGroup cols={2}>
  <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 Prem Router in OpenCode, Pi, and other OpenAI-compatible tools.
  </Card>
</CardGroup>
