Endpoint
POST http://127.0.0.1:8045/v1/messages
The native Anthropic/Claude protocol endpoint provides full support for Claude Code CLI and advanced features like extended thinking, system prompts, and tool use.
Authentication
Anthropic-style API key header x-api-key: sk-antigravity
Alternatively, use standard Bearer authentication:
Bearer token format Authorization: Bearer sk-antigravity
API version, e.g., 2023-06-01
Beta features to enable. Automatically injected: anthropic-beta: claude-code-20250219,interleaved-thinking-2025-05-14
Request Body
Model identifier:
claude-sonnet-4-6 - Latest Claude Sonnet 4.6
claude-sonnet-4-6-thinking - With extended thinking
claude-opus-4-6-thinking - Opus with thinking
gemini-3-pro-high - Mapped to Gemini (via protocol conversion)
Conversation messages in Anthropic format Message role: user or assistant
Message content. Can be:
String: Plain text
Array: Multi-modal blocks (text, images, tool_use, tool_result)
System prompt to guide model behavior. Can be:
String: Simple system message
Array: Structured system blocks for advanced control
Maximum tokens to generate. Required for Claude protocol. Unlike OpenAI format, max_tokens is mandatory for Anthropic endpoints.
Enable Server-Sent Events (SSE) streaming
Sampling temperature (0.0 to 1.0)
Nucleus sampling (0.0 to 1.0)
Extended thinking configuration for reasoning models Thinking mode:
enabled - Enable with budget
adaptive - Dynamic budget (maps to fixed budget internally)
disabled - No extended thinking
Token budget for reasoning:
Low: 8192
Medium: 16384
High: 24576
Effort level: low, medium, high, max
Output configuration (Claude API v2.0.67+) Model reasoning effort: low, medium, high
Available tools for function calling JSON Schema for tool parameters
Server tools like web_search can be enabled via: Server tool type, e.g., web_search_20250305
Non-Streaming Response
Unique message identifier
Response type, always message
Model used for generation
Response content blocks Block type: text, thinking, tool_use, image
Text content (for text blocks)
Reasoning content (for thinking blocks)
Cryptographic signature for thinking/tool_use blocks
Tool call ID (for tool_use blocks)
Tool name (for tool_use blocks)
Tool parameters (for tool_use blocks)
Completion reason: end_turn, max_tokens, tool_use, stop_sequence
Token usage statistics Cached tokens read (prompt caching)
cache_creation_input_tokens
Tokens cached for future use
Example: Basic Chat
curl -X POST http://127.0.0.1:8045/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-antigravity" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Explain quantum computing"}
]
}'
Example: With System Prompt
curl -X POST http://127.0.0.1:8045/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-antigravity" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 2048,
"system": "You are a helpful coding assistant. Always explain your reasoning.",
"messages": [
{"role": "user", "content": "Write a Python function to reverse a string"}
]
}'
Example: Extended Thinking
curl -X POST http://127.0.0.1:8045/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-antigravity" \
-d '{
"model": "claude-sonnet-4-6-thinking",
"max_tokens": 4096,
"thinking": {
"type": "enabled",
"budget_tokens": 16384
},
"messages": [
{"role": "user", "content": "Solve this complex logic puzzle: ..."}
]
}'
Example: Claude Code CLI Integration
# Set environment variables
export ANTHROPIC_API_KEY = "sk-antigravity"
export ANTHROPIC_BASE_URL = "http://127.0.0.1:8045"
# Run Claude Code CLI
claude "Help me debug this Python code"
curl -X POST http://127.0.0.1:8045/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-antigravity" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 2048,
"tools": [
{
"name": "get_weather",
"description": "Get current weather",
"input_schema": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}
],
"messages": [
{"role": "user", "content": "What's the weather in Tokyo?"}
]
}'
curl -X POST http://127.0.0.1:8045/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: sk-antigravity" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 2048,
"tools": [
{
"type": "web_search_20250305",
"name": "web_search"
}
],
"messages": [
{"role": "user", "content": "What are the latest AI developments?"}
]
}'
Content Block Types
Text Block
{
"type" : "text" ,
"text" : "Here is my response..."
}
Thinking Block
{
"type" : "thinking" ,
"thinking" : "Let me analyze this step by step..." ,
"signature" : "base64-encoded-signature"
}
{
"type" : "tool_use" ,
"id" : "toolu_123abc" ,
"name" : "get_weather" ,
"input" : {
"location" : "Tokyo"
},
"signature" : "base64-encoded-signature"
}
{
"role" : "user" ,
"content" : [
{
"type" : "tool_result" ,
"tool_use_id" : "toolu_123abc" ,
"content" : "Temperature: 22°C, Sunny"
}
]
}
Image Upload
{
"role" : "user" ,
"content" : [
{
"type" : "image" ,
"source" : {
"type" : "base64" ,
"media_type" : "image/jpeg" ,
"data" : "base64-encoded-image-data"
}
},
{
"type" : "text" ,
"text" : "What's in this image?"
}
]
}
Features
Full Claude Protocol : 100% compatible with Claude Code CLI and Anthropic SDKs
Extended Thinking : Support for reasoning tokens with signature validation
Tool Use : Client tools, server tools (web_search), and MCP integration
Streaming : Real-time SSE streaming with thinking blocks
Context Caching : Automatic prompt caching for repeated contexts
Multi-modal : Images, documents, audio support
{
"type" : "error" ,
"error" : {
"type" : "invalid_request_error" ,
"message" : "max_tokens is required"
}
}
Common error types:
invalid_request_error - Malformed request
authentication_error - Invalid API key
rate_limit_error - Quota exceeded
server_error - Internal error