API reference
Anthropic-compatible API
POST /messages takes Anthropic's Messages format, so the Anthropic SDKs and Anthropic-format clients such as Claude Code work by setting the base URL to https://api.vani.ai (the SDKs add /v1/messages) and using a Vani key. Any model GET /models lists can be called this way, not only Claude.
- SDK base URL
- https://api.vani.ai (without /v1)
- Endpoints
- POST https://api.vani.ai/v1/messages · /messages/count_tokens
- Authentication
- x-api-key or Authorization: Bearer
- Version header
- anthropic-version: 2023-06-01
On this pageQuickstart
Quickstart
Create a Vani key, then give the Anthropic SDK Vani's origin as its base URL. max_tokens is required, as on Anthropic's API.
Python (Anthropic SDK)
import os
from anthropic import Anthropic
client = Anthropic(base_url="https://api.vani.ai", api_key=os.environ["VANI_API_KEY"])
message = client.messages.create(
model="anthropic/claude-sonnet-5.5", # any id from GET /models
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}],
)
print(message.content)TypeScript (Anthropic SDK)
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.vani.ai", apiKey: process.env.VANI_API_KEY });
const message = await client.messages.create({
model: "openai/gpt-6-sol", // any id from GET /models
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
});
console.log(message.content);curl
curl "https://api.vani.ai/v1/messages" \
-H "x-api-key: $VANI_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"anthropic/claude-sonnet-5.5","max_tokens":256,"messages":[{"role":"user","content":"Hello"}]}'Supported
- Text and system blocks,
tool_useandtool_result, tool definitions andtool_choice,max_tokens,stop_sequences, and streaming and non-streaming answers. - MCP servers:
mcp_serverswith theanthropic-betaheadermcp-client-2025-11-20(mcp-client-2026-09-15andmcp-client-2025-04-04are accepted too). thinkingsets the reasoning effort unlessoutput_config.effortdoes. Thinking blocks are not returned;usage.output_tokens_details.thinking_tokenssays how much of the output was reasoning.cache_controlhints on system and user text blocks are passed to the model's provider where it takes them (x-vani-cache-hints: forwarded); a cache hit is never guaranteed, andusage.cache_read_input_tokensshows what was billed as cached.POST /messages/count_tokensreturns a local estimate (x-vani-token-count: local-estimate); billing uses the provider's usage.
Claude Code
Claude Code talks to the Messages endpoint. Set ANTHROPIC_BASE_URL to Vani's origin without /v1 and ANTHROPIC_API_KEY to your Vani key (never an Anthropic key), choose any model id, and keep your normal permission settings. These are the settings tested in the Claude Code guide:
Claude Code environment
export ANTHROPIC_BASE_URL='https://api.vani.ai'
export ANTHROPIC_API_KEY='vani_YOUR_VANI_API_KEY'
export ANTHROPIC_MODEL='openai/gpt-6-sol'
export CLAUDE_CODE_DISABLE_THINKING=1
export CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
export DISABLE_PROMPT_CACHING=1
export ENABLE_TOOL_SEARCH=falseWhat differs from Anthropic's API
- Model ids name their maker, for example
anthropic/claude-sonnet-5.5oropenai/gpt-6-sol. Anthropic's own ids, such asclaude-haiku-4-5, are accepted when they name exactly one model your key can use. - Text only: image and document blocks, hosted server tools and unsupported beta features are refused with 400 before a model runs, so nothing is billed.
top_kis accepted and ignored.
Note
More reference: OpenAI-compatible API · Model ids, limits, headers and usage · MCP tools on the API · Media API: images and videos · Artifacts API · Responses API: scope and limits · API overview · Docs and quickstart