API reference

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

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)
JavaScript

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);
Shell

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_use and tool_result, tool definitions and tool_choice, max_tokens, stop_sequences, and streaming and non-streaming answers.
  • MCP servers: mcp_servers with the anthropic-beta header mcp-client-2025-11-20 (mcp-client-2026-09-15 and mcp-client-2025-04-04 are accepted too).
  • thinking sets the reasoning effort unless output_config.effort does. Thinking blocks are not returned; usage.output_tokens_details.thinking_tokens says how much of the output was reasoning.
  • cache_control hints 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, and usage.cache_read_input_tokens shows what was billed as cached.
  • POST /messages/count_tokens returns a local estimate (x-vani-token-count: local-estimate); billing uses the provider's usage.

MCP tools on the API

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:

Shell

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=false

Claude Code and other client guides

What differs from Anthropic's API

  • Model ids name their maker, for example anthropic/claude-sonnet-5.5 or openai/gpt-6-sol. Anthropic's own ids, such as claude-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_k is accepted and ignored.

Note

Anthropic-compatible describes the request and answer formats Vani accepts. The Vani API is a Vani AI service, not an Anthropic product.

Model ids, limits, headers and usageAPI prices per model

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

We use cookies for analytics and to measure how well our campaigns are working. None of it is needed to run the site, and your conversations are never included. See our Privacy Policy.