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 speak the Anthropic API,
Claude Code works against Keln with three environment variables (setup below).
Same account, same key, same models, same prices: only the request shape differs.
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 key in the x-api-key header, the Anthropic convention. The
anthropic-version header is accepted 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. Anything on the
rate card is available on this surface.
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 identical to the OpenAI-shaped surfaces |
| 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:
export ANTHROPIC_BASE_URL="https://anthropic.keln.ai"
export ANTHROPIC_API_KEY="sk-keln-…" # your Keln key
export ANTHROPIC_MODEL="moonshotai/kimi-k3" # any catalog id with the Tools badge
Then run claude as usual.
Notes that matter in practice:
- Model choice: agent sessions need tool calling, pick a model with the Tools badge.
- Long sessions: repeated context automatically bills at the per-model cached rate; nothing to configure.
ANTHROPIC_SMALL_FAST_MODELcan point at a cheaper catalog model (e.g.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.