# Model API

> Call always-on models with any OpenAI or Anthropic client and your Klio key, paid per token from your credit.

Canonical page: https://klio.tech/docs/model-api

## Always-on models, nothing to deploy

Always-on models on one OpenAI- and Anthropic-compatible endpoint. Use your Klio API key and pay per token from your Klio credit. There's nothing to deploy. The OpenAI-compatible base URL is `https://api.klio.tech/v1`; Anthropic clients use `https://api.klio.tech`.

Table: Models on the Model API

| Model | Name to send |
| --- | --- |
| DeepSeek V4.1 Flash | `deepseek/deepseek-v4.1-flash-1017` |
| GLM-5.3 Flash | `zai-org/GLM-5.3-Flash` |

Every model supports streaming and tool calls. Current prices per million input and output tokens are on the Models page in the console and in `GET /v1/models`, which needs no key.

## Call it

Create a key on the Keys page and set it as `KLIO_API_KEY`. Send it as `Authorization: Bearer` (OpenAI clients) or `x-api-key` (Anthropic clients).

```bash
curl https://api.klio.tech/v1/chat/completions \
  -H "Authorization: Bearer $KLIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "zai-org/GLM-5.3-Flash", "messages": [{"role": "user", "content": "Say hello in five words."}]}'
```

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.klio.tech/v1", api_key=os.environ["KLIO_API_KEY"])
reply = client.chat.completions.create(
    model="zai-org/GLM-5.3-Flash",
    messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(reply.choices[0].message.content)
```

```python
import os
from anthropic import Anthropic

client = Anthropic(base_url="https://api.klio.tech", api_key=os.environ["KLIO_API_KEY"])
reply = client.messages.create(
    model="zai-org/GLM-5.3-Flash",
    max_tokens=256,
    messages=[{"role": "user", "content": "Say hello in five words."}],
)
print(reply.content[0].text)
```

To use a Model API model in Claude Code:

```bash
export ANTHROPIC_BASE_URL=https://api.klio.tech
export ANTHROPIC_AUTH_TOKEN=$KLIO_API_KEY
claude --model zai-org/GLM-5.3-Flash
```

## Billing and limits

- Each request is charged for the input and output tokens the model reports, at the price in effect when it started, from your Klio credit: free credit first, then purchased credit.
- Model API spend counts toward your monthly spend limit and the $1 you can use before adding a card. Once either is reached, new requests are refused with 402 before they run.
- A stream you stop early is charged for the tokens generated up to its end.
- Each response carries `x-klio-request-id`; non-streamed responses also carry `x-klio-cost-micros`, the charge in millionths of a dollar.
- Each key can send up to 600 requests a minute, and a workspace can have 32 requests running at once; past either the answer is 429 with `Retry-After`. Request bodies are limited to 4 MB.
- Klio does not store your prompts or outputs. We keep token counts, cost and timing.

## Errors

Table: Model API errors

| Status | Code | Meaning |
| --- | --- | --- |
| 401 | `invalid_api_key` | The key is missing, revoked or not a Klio key. |
| 402 | `insufficient_credit` or `card_required` | Add credit, raise your monthly limit or add a card on the Billing page. |
| 404 | `model_not_found` | The model name is not one of the names above. |
| 429 | `rate_limited` | Too many requests for this key; retry after `Retry-After`. |
| 503 | `model_unavailable` | The model is temporarily unavailable; retry shortly. |
