> For clean Markdown of any page, append `.md` to the page URL.
> Documentation index: https://you.com/docs/llms.txt (section indexes: append `/llms.txt` to any section URL).
> Search these docs: Docs MCP at https://you.com/docs/_mcp/server (`searchDocs`, no API key).
> Call live You.com APIs: Product MCP at https://api.you.com/mcp (keyless `?profile=free` exposes `you-search` and `you-discover`. Research and finance use `/mcp/research`, `/mcp/finance`, or `?tools=` on `/mcp`). To pick an API or integration path, call `you-discover` on that server instead of guessing.
> OpenAPI: https://you.com/docs/openapi.json—auth header `X-API-Key`, env `YDC_API_KEY`.

# Inference Router Quickstart

The Inference Router exposes OpenAI-compatible and Anthropic-compatible endpoints at `https://api.you.com`. Point an existing SDK at that base URL and authenticate with your You.com API key.

## 1. Get an API key

Get an API key at [you.com/platform](https://you.com/platform) and send it as a bearer token:

```text
Authorization: Bearer <your-api-key>
```

The Web Search, Contents, Answer, and Research APIs read the key from `X-API-Key`. The Inference Router reads it from `Authorization`, the header the OpenAI and Anthropic SDKs already send. The samples below read the key from `YDC_API_KEY`.

## 2. List your models

`GET /v1/models` returns the models your key can call. Access is set per account, so two keys can see different lists.

```bash
curl https://api.you.com/v1/models \
  -H "Authorization: Bearer $YDC_API_KEY"
```

Each model reports two token limits:

| Field              | Meaning                                   |
| ------------------ | ----------------------------------------- |
| `max_input_tokens` | The context window, in tokens.            |
| `max_tokens`       | The largest output a request may ask for. |

A limit is published only when it holds for every request to the model. A model with no published limit omits the field in the OpenAI format, and reports `null` in the Anthropic format, which you get by sending an `anthropic-version` header. The Anthropic format also adds `display_name` and paging fields.

```json
{
  "object": "list",
  "data": [
    { "id": "kimi-k3", "object": "model", "max_input_tokens": 262144, "max_tokens": 131072 },
    { "id": "muse-spark-1.3", "object": "model" }
  ]
}
```

## 3. Send a request

Use a model `id` from the previous step. To try a request without code, open the [Playground](https://you.com/platform/playground/inference-router).

```python maxLines=0
import os

from openai import OpenAI

client = OpenAI(base_url="https://api.you.com/v1", api_key=os.environ["YDC_API_KEY"])

response = client.chat.completions.create(
    model="kimi-k3",
    messages=[{"role": "user", "content": "Explain nucleus sampling in two sentences."}],
)
print(response.choices[0].message.content)
```

```bash
curl https://api.you.com/v1/chat/completions \
  -H "Authorization: Bearer $YDC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "messages": [{"role": "user", "content": "Explain nucleus sampling in two sentences."}]
  }'
```

The same model through the Anthropic-compatible endpoint:

```python maxLines=0
import os

import anthropic

client = anthropic.Anthropic(base_url="https://api.you.com", auth_token=os.environ["YDC_API_KEY"])

message = client.messages.create(
    model="kimi-k3",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Explain nucleus sampling in two sentences."}],
)
print(message.content[0].text)
```

```bash
curl https://api.you.com/v1/messages \
  -H "Authorization: Bearer $YDC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Explain nucleus sampling in two sentences."}]
  }'
```

## 4. Stream the response

Set `stream` to `true` on `/v1/chat/completions` to receive the reply as server-sent events. Each `data:` line is a `chat.completion.chunk`, and the stream ends with `data: [DONE]`.

Set `stream_options.include_usage` to `true` to receive the token counts on one more chunk before `[DONE]`. That chunk has an empty `choices` list, so check `chunk.choices` before reading `delta`.

```python maxLines=0
stream = client.chat.completions.create(
    model="kimi-k3",
    messages=[{"role": "user", "content": "Explain nucleus sampling in two sentences."}],
    stream=True,
    stream_options={"include_usage": True},
)
for chunk in stream:
    if chunk.choices:
        print(chunk.choices[0].delta.content or "", end="", flush=True)
    if chunk.usage:
        print(f"\n{chunk.usage.total_tokens} tokens")
```

```bash
curl -N https://api.you.com/v1/chat/completions \
  -H "Authorization: Bearer $YDC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k3",
    "messages": [{"role": "user", "content": "Explain nucleus sampling in two sentences."}],
    "stream": true,
    "stream_options": {"include_usage": true}
  }'
```

`/v1/messages` streams Anthropic server-sent events when `stream` is `true`. When a request declares a web tool, the stream also carries progress events; see [Web Tools](/docs/guides/inference-router/web-tools).

## Next Steps

#### [Inference Router Overview](/docs/guides/inference-router)

What the router is and which endpoints it serves

#### [Web Tools](/docs/guides/inference-router/web-tools)

Let the router search the web and fetch pages for the model

#### [Playground](https://you.com/platform/playground/inference-router)

Try the Inference Router in your browser

#### [API reference](/docs/api-reference/inference-router/create-chat-completion)

Full parameter reference and request and response schemas