# Anthropic-compatible API
`POST https://anthropic.keln.ai/v1/messages`, the Anthropic Messages schema, streaming and
non-streaming, for every catalog model. Built for tools that use the Anthropic API: Claude Code
works with Keln through three environment variables (see below).
Same account, same key, same models, same prices: only the request shape differs.
```bash
curl https://anthropic.keln.ai/v1/messages \
-H "x-api-key: $KELN_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "moonshotai/kimi-k3",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "Say hello from Keln."}]
}'
```
## Authentication
Send your normal Keln API key in the `x-api-key` header, the Anthropic convention. Keln accepts the
`anthropic-version` header as clients send it.
## Models
Use Keln model ids (`moonshotai/kimi-k3`, `deepseek-ai/deepseek-v4-flash`, …), the ids from
[`/v1/models`](models.md), not Anthropic model names. Every model on the
[Models & pricing](../models-pricing.md) page is available on this API.
## What's supported
| Feature | Contract |
|---|---|
| `messages`, `system`, `max_tokens` | standard Messages semantics |
| `stream: true` | the full Anthropic event lifecycle: `message_start` → `content_block_start` → `content_block_delta` → `content_block_stop` → `message_delta` → `message_stop` |
| Thinking models | the reasoning trace comes back as `thinking` content blocks, exactly where Anthropic clients expect it |
| `tools`, `tool_choice` (incl. forced `{"type": "tool", "name": …}`) | Anthropic `input_schema` tool shape, `tool_use` content blocks out, `tool_result` blocks in, full agent loops work |
| `usage` | `input_tokens` / `output_tokens` on every response. Billing is the same as on chat completions and Responses: the per-model rates on [Models & pricing](../models-pricing.md), with reasoning billed as output and repeated context at the [cached rate](../capabilities/caching.md) |
| Everything else | the same routing, validation, and [zero-data-retention](../capabilities/privacy.md) contracts as the rest of Keln |
## Using Claude Code
Point Claude Code at Keln with environment variables, no config file needed. For the desktop app,
see [Claude Desktop with Keln](../claude-desktop.md).
```bash
export ANTHROPIC_BASE_URL="https://anthropic.keln.ai"
export ANTHROPIC_API_KEY="sk-keln-…" # your Keln API key
export ANTHROPIC_MODEL="moonshotai/kimi-k3" # any catalog model with tool calling
```
Then run `claude` as usual.
Notes:
- **Model choice.** Agent sessions need tool calling, so pick a model that supports it.
- **Long sessions.** Keln bills repeated context at the per-model
[cached rate](../capabilities/caching.md) automatically. There is nothing to configure.
- **Background tasks.** Point `ANTHROPIC_SMALL_FAST_MODEL` at a cheaper catalog model, for
example `deepseek-ai/deepseek-v4-flash`, for Claude Code's background tasks.
## Web search
Send Anthropic's server tool, `{ "type": "web_search_20250305", "name": "web_search" }`, and Keln
runs the search and answers in Anthropic's own shape: `server_tool_use` and
`web_search_tool_result` blocks with the results, `citations` on the text, and
`usage.server_tool_use.web_search_requests`. Claude Code's WebSearch uses this tool, so it works
through Keln as it does against Anthropic. Send the result block back on the next turn and the
model keeps its findings. Details and price on [Web search](../capabilities/web-search.md).
Anthropic-compatible API
POST https://anthropic.keln.ai/v1/messages, the Anthropic Messages schema, streaming and
non-streaming, for every catalog model. Built for tools that use the Anthropic API: Claude Code
works with Keln through three environment variables (see below).
Same account, same key, same models, same prices: only the request shape differs.
Send your normal Keln API key in the x-api-key header, the Anthropic convention. Keln accepts the
anthropic-version header as clients send it.
Models
Use Keln model ids (moonshotai/kimi-k3, deepseek-ai/deepseek-v4-flash, …), the ids from
/v1/models, not Anthropic model names. Every model on the
Models & pricing page is available on this API.
What's supported
Feature
Contract
messages, system, max_tokens
standard Messages semantics
stream: true
the full Anthropic event lifecycle: message_start → content_block_start → content_block_delta → content_block_stop → message_delta → message_stop
Thinking models
the reasoning trace comes back as thinking content blocks, exactly where Anthropic clients expect it
Anthropic input_schema tool shape, tool_use content blocks out, tool_result blocks in, full agent loops work
usage
input_tokens / output_tokens on every response. Billing is the same as on chat completions and Responses: the per-model rates on Models & pricing, with reasoning billed as output and repeated context at the cached rate
Everything else
the same routing, validation, and zero-data-retention contracts as the rest of Keln
Using Claude Code
Point Claude Code at Keln with environment variables, no config file needed. For the desktop app,
see Claude Desktop with Keln.
exportANTHROPIC_BASE_URL="https://anthropic.keln.ai"exportANTHROPIC_API_KEY="sk-keln-…"# your Keln API keyexportANTHROPIC_MODEL="moonshotai/kimi-k3"# any catalog model with tool calling
Then run claude as usual.
Notes:
Model choice. Agent sessions need tool calling, so pick a model that supports it.
Long sessions. Keln bills repeated context at the per-model
cached rate automatically. There is nothing to configure.
Background tasks. Point ANTHROPIC_SMALL_FAST_MODEL at a cheaper catalog model, for
example deepseek-ai/deepseek-v4-flash, for Claude Code's background tasks.
Web search
Send Anthropic's server tool, { "type": "web_search_20250305", "name": "web_search" }, and Keln
runs the search and answers in Anthropic's own shape: server_tool_use and
web_search_tool_result blocks with the results, citations on the text, and
usage.server_tool_use.web_search_requests. Claude Code's WebSearch uses this tool, so it works
through Keln as it does against Anthropic. Send the result block back on the next turn and the
model keeps its findings. Details and price on Web search.