Claude API

Use Claude Messages, streaming, tools, caching, and the Official Group playground.

Use an Official Group API key with POST https://app.apipool.dev/v1/messages. Check the model catalog for current availability and prices.

For Discount Group and Discount 2 keys, follow the Claude Code guide. Switching groups requires a key from the destination group.

Make a request

export APIPOOL_API_KEY="YOUR_APIPOOL_API_KEY"
curl https://app.apipool.dev/v1/messages \
  -H "x-api-key: $APIPOOL_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Explain an API in one sentence."}]
  }'

Read the answer in the text blocks of content and token counts in usage. Keep the x-apipool-request-id header to find the request in usage records.

Set the Anthropic SDK base_url or baseURL to https://app.apipool.dev. The SDK appends the endpoint path.

Models and pricing

Use the exact model ID listed for an available Official Group model. Fable 5.1 uses claude-fable-5-1 and Fable 5.2 uses claude-fable-5-2. Fable 5.2 is available only in the Official Group.

ModelModel IDInput / output (US$ per million tokens)
Fable 5claude-fable-58.50 / 42.50
Fable 5.1claude-fable-5-18.50 / 42.50
Fable 5.2claude-fable-5-26.80 / 34.00
Opus 5.5claude-opus-5-53.40 / 17.00
Opus 5, 4.8, 4.7claude-opus-5, claude-opus-4-8, claude-opus-4-74.25 / 21.25
Opus 4.6 (5-minute cache only)claude-opus-4-64.25 / 21.25
Sonnet 5.5, 5claude-sonnet-5-5, claude-sonnet-51.70 / 8.50
Sonnet 4.6, 4.5claude-sonnet-4-6, claude-sonnet-4-5-202509292.55 / 12.75
Sonnet 4.5 Thinking (5-minute cache only)claude-sonnet-4-5-20250929-thinking2.55 / 12.75
Haiku 4.5claude-haiku-4-5-202510010.85 / 4.25
Haiku 5.5 with up to 100,000 input tokensclaude-haiku-5-50.085 / 0.425
Haiku 5.5 with more than 100,000 input tokensclaude-haiku-5-50.425 / 2.125

The following models support Messages with text and thinking output. Caching, images, tools, Chat Completions, and beta extensions are unavailable. Use a content string or plain text blocks and omit cache_control.

ModelModel IDInput / output (US$ per million tokens)
Haiku 4.5 Thinkingclaude-haiku-4-5-20251001-thinking0.85 / 4.25
Opus 4.5claude-opus-4-5-202511014.25 / 21.25
Opus 4.5 Thinkingclaude-opus-4-5-20251101-thinking4.25 / 21.25
Opus 4.6 Thinkingclaude-opus-4-6-thinking4.25 / 21.25
Sonnet 4.6 Thinkingclaude-sonnet-4-6-thinking2.55 / 12.75

Cache reads and writes are billed separately. Check the model page for rates. Fable 5.2 costs US$0.17 for reads, US$8.50 for five-minute writes, and US$13.60 for one-hour writes per million tokens. Official Group Opus 4.6 and Sonnet 4.5 Thinking support text and a five-minute cache on Messages and Chat Completions. One-hour caches, images, and tools are unavailable for these two models. Read and write rates per million tokens are US$0.425 and US$5.3125 for Opus 4.6 and US$0.255 and US$3.1875 for Sonnet 4.5 Thinking. For Haiku 5.5, add ordinary input, cache reads, and cache writes to determine the tier. Above the threshold the entire request uses long-input rates for input, output, and cache. Output usage includes thinking tokens.

Sonnet 5.5 cache reads cost US$0.17 per million tokens. Cache rates vary by model and the request uses the price active on submission.

Streaming

Set "stream": true in a Messages request and use curl -N for SSE. Read text_delta from content_block_delta through message_stop. message_delta can include final usage and the stop reason.

stop_reason: "max_tokens" means the answer reached the output limit. If the stream errors or disconnects, check usage by request ID before retrying.

Tools and thinking

The models above that offer only a five-minute cache or no cache do not support tools. On tool-capable models, declare the functions your application executes in Messages tools.

{
  "name": "get_weather",
  "description": "Look up the weather for a city",
  "input_schema": {
    "type": "object",
    "properties": { "city": { "type": "string" } },
    "required": ["city"]
  }
}

Your application executes tool_use and returns a tool_result with the matching tool_use_id. Built-in web search, code execution, Batch, fast mode, and regional pricing modes are unavailable.

Thinking settings vary by generation. Use the exact model ID and check whether that model allows disabling thinking or forcing a tool. For extended thinking, thinking.budget_tokens must be less than max_tokens. Newer models may use adaptive thinking.

Caching and usage

On models with caching, use content block arrays for system or messages. Add "cache_control": {"type": "ephemeral"} to the last block of a repeated prefix. Omit ttl for the default five minutes or set "ttl": "5m". Opus 4.6 and Sonnet 4.5 Thinking accept those five-minute forms only. On models that offer a one-hour cache, use "ttl": "1h" with anthropic-beta: extended-cache-ttl-2025-04-11 as required. Short prompts may fall below the minimum cache length.

usage.input_tokens, cache_read_input_tokens, and cache_creation_input_tokens are separate counts. cache_creation breaks down writes by TTL. Keep the complete usage object and count each category once.

Playground

Try Sonnet 4.6 or open another available model and select an Official Group key. The playground streams single-turn text requests with up to 4,000 prompt characters and 4,096 output tokens, including thinking. Use the API for multi-turn history and supported caching. Tools and images depend on the chosen model. Actual playground usage is billed to your wallet. Use the request ID to check charges.

Troubleshooting

SituationWhat to check
HTTP 401 or invalid keyCheck that the key is enabled and copied in full.
Unavailable model or group mismatchCheck Official Group availability and use a matching key.
claude_code_client_requiredThe key belongs to a Claude Code group. Use an Official Group key.
Insufficient balanceAdd funds before submitting again.
Thinking parameter rejectedCheck the thinking settings and output budget for the chosen model.
Truncated outputShorten the prompt or increase API max_tokens.
Timeout or disconnectKeep the request ID and check its usage before retrying.