Anthropic Messages
Call Claude models natively through POST /v1/messages using official Anthropic SDKs or Claude Code, preserving extended thinking blocks, native tool schemas, and explicit cache_control breakpoints.
POST
https://api.vanix.io/v1/messagesInteractive Try It
POST /v1/messagesRequired Headers
| Header | Value |
|---|---|
x-api-key | Your Vanix AI API key (sk-...) |
anthropic-version | 2023-06-01 |
content-type | application/json |
Request Body Parameters
modelstringrequired Claude model ID (e.g.,
claude-sonnet-4-5, claude-opus-4-5, claude-haiku-4-5). max_tokensintegerrequired Maximum tokens to generate. Must be strictly greater than
thinking.budget_tokens when extended thinking is enabled. messagesarray<object>required Alternating
user and assistant turns with string or structured content blocks (text, image, document, tool_use, tool_result). systemstring | array<object>optional System prompt string or content block array supporting
cache_control: {"type": "ephemeral"}. thinkingobjectoptional Enable native extended thinking with
{"type": "enabled", "budget_tokens": 4096}. streambooleanoptionaldefault: false Stream Anthropic SSE events (
message_start, content_block_delta, message_delta, message_stop). Code Examples
bash
curl https://api.vanix.io/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: $VANIX_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 512,
"messages": [
{"role": "user", "content": "Explain why prompt caching lowers agent loop costs."}
]
}'python
import os
import anthropic
client = anthropic.Anthropic(
api_key=os.environ["VANIX_API_KEY"],
base_url="https://api.vanix.io",
)
msg = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=512,
messages=[{"role": "user", "content": "Explain why prompt caching lowers agent loop costs."}],
)
print(msg.content[0].text)ts
import Anthropic from '@anthropic-ai/sdk'
const client = new Anthropic({
apiKey: process.env.VANIX_API_KEY,
baseURL: 'https://api.vanix.io',
})
const msg = await client.messages.create({
model: 'claude-sonnet-4-5',
max_tokens: 512,
messages: [{ role: 'user', content: 'Explain why prompt caching lowers agent loop costs.' }],
})
console.log(msg.content)