Skip to main content

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

x-api-key
string
required
Anthropic-style API key header
x-api-key: sk-antigravity
Alternatively, use standard Bearer authentication:
Authorization
string
Bearer token format
Authorization: Bearer sk-antigravity

Request Headers

Content-Type
string
required
Must be application/json
anthropic-version
string
API version, e.g., 2023-06-01
anthropic-beta
string
Beta features to enable. Automatically injected:
anthropic-beta: claude-code-20250219,interleaved-thinking-2025-05-14

Request Body

model
string
required
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)
messages
array
required
Conversation messages in Anthropic format
system
string | array
System prompt to guide model behavior. Can be:
  • String: Simple system message
  • Array: Structured system blocks for advanced control
max_tokens
integer
required
Maximum tokens to generate. Required for Claude protocol.
Unlike OpenAI format, max_tokens is mandatory for Anthropic endpoints.
stream
boolean
default:"false"
Enable Server-Sent Events (SSE) streaming
temperature
number
Sampling temperature (0.0 to 1.0)
top_p
number
Nucleus sampling (0.0 to 1.0)
top_k
integer
Top-K sampling parameter
thinking
object
Extended thinking configuration for reasoning models
output_config
object
Output configuration (Claude API v2.0.67+)
tools
array
Available tools for function callingServer tools like web_search can be enabled via:

Response Format

Non-Streaming Response

id
string
Unique message identifier
type
string
Response type, always message
role
string
Always assistant
model
string
Model used for generation
content
array
Response content blocks
stop_reason
string
Completion reason: end_turn, max_tokens, tool_use, stop_sequence
usage
object
Token usage statistics

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"

Example: Tool Use

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?"}
    ]
  }'

Example: Web Search (Server Tool)

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"
}

Tool Use Block

{
  "type": "tool_use",
  "id": "toolu_123abc",
  "name": "get_weather",
  "input": {
    "location": "Tokyo"
  },
  "signature": "base64-encoded-signature"
}

Tool Result Block (in messages)

{
  "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

Error Format

{
  "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

Build docs developers (and LLMs) love