Claude Messages
Call Claude Fable 5.1, Opus 5.5, Sonnet 5.5 and Haiku 5.5 through one Anthropic Messages endpoint with a BeatAPI key.
- One endpoint,
POST /v1/messages, for every current Claude model. Changemodelto switch. - Text and image input, text output, streaming, tool use, extended thinking and prompt caching.
- Works with the Anthropic SDK: set the base URL to
https://direct.beatapi.io(without/v1) and use a BeatAPI key. - Claude models answer only on Anthropic Messages. A call to
/v1/responsesreturns400.
Use https://direct.beatapi.io as the base URL for text requests: it is not subject to Cloudflare’s 100-second limit, so a long non-streaming request is not cut off. https://api.beatapi.io also works and is the fallback if direct.beatapi.io is unreachable from your network. The key, models and prices are the same on both. Image and video APIs use https://api.beatapi.io only.
Opens this endpoint in the API Explorer. Enter your BeatAPI API key and send: the call is real and is billed to your own balance.
Models
Send one of these IDs as model. Each is a separate model; do not treat them as aliases of each other.
- Prices are the base tier, discount already applied. A long-context tier, cached-input rates and cache writes are not in this table; see the price table.
—means the catalogue does not publish the number.
Older IDs of this family still work and are listed on Legacy models.
Quick start
Install the anthropic package on your server, keep the key in BEATAPI_API_KEY, and never put it in browser code. These are request examples, not recorded model outputs.
Read the answer from the text blocks in content, then check stop_reason and usage. An HTTP 200 alone does not prove the answer satisfies your task: validate it in your application. Text requests return directly; do not poll /v1/tasks for them.
Endpoint and authentication
POST https://direct.beatapi.io/v1/messages
x-api-key
string
Required
Your BeatAPI key. Authorization: Bearer <BEATAPI_API_KEY> is also accepted.
Send the anthropic-version header, for example anthropic-version: 2023-06-01. The key goes in x-api-key or in Authorization: Bearer <key>; both work, so an existing Anthropic client only needs its base URL changed.
Claude models answer only on Anthropic Messages. Calling one on /v1/responses returns 400.
Request parameters
Standard Anthropic Messages fields are accepted. Request-format compatibility does not mean every beta feature or server tool is supported, so test the options you rely on.
model
string
Required
The exact model ID.
Allowed values: claude-fable-5-1, claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5
- Older IDs that still work (
claude-opus-5,claude-sonnet-5,claude-haiku-4-5-20251001) are on Legacy models. - Call
GET /v1/modelswith your key to confirm which models are enabled for it.
max_tokens
integer
Required
Upper bound on the generated tokens, thinking included.
- Always send it. If it is missing or
0, a default limit is applied, and that default may be lower than you expect. - The largest accepted value is 1,073,741,823; a larger value is
400 bad_request. Keep it at or below the max output of the model in the table above. max_tokensis also used to estimate how much balance a request needs. A very large value can be refused with402 insufficient_creditseven when the real output would be small. Set it to what you need.
messages
object[]
Required
The conversation, oldest message first. Each message has a role (user or assistant) and content. content is a string, or an array of content blocks.
- Block types you will use:
text,image(base64 or URL source),tool_use(in an assistant message), andtool_result(in a user message). - An empty or missing
messagesarray is400 bad_request.
Example
system
string | object[]
Optional
System prompt. A string, or an array of text blocks. Put cache_control on a block to cache a long, stable prefix.
Example
stream
boolean
OptionalDefault: false
Return the answer as server-sent events. See the Streaming section below.
Default: false
stop_sequences
string[]
Optional
Custom strings that stop generation. The response then has stop_reason: "stop_sequence".
tools
object[]
Optional
Tools the model may call. Each has a name, a description and an input_schema (JSON Schema). When the model calls one, the answer has stop_reason: "tool_use"; run the tool and return the result in a following tool_result block.
Example
tool_choice
object
Optional
Whether and how the model must use tools.
Allowed values: {"type":"auto"}, {"type":"any"}, {"type":"tool","name":"..."}, {"type":"none"}
autolets the model decide,anyforces some tool,toolforces the named tool,noneforbids tools.
Example
thinking
object
Optional
Extended thinking. Set type to turn it on or off. Thinking tokens count toward max_tokens and are billed as output tokens.
Allowed values: adaptive, enabled, disabled
thinking.typeis one of the values above.enabledtakesthinking.budget_tokens(an integer of at least 1,024, belowmax_tokens).thinking.displayissummarizedoromitted. Newer models may return no thinking text unless you ask forsummarized.- Set the depth of adaptive thinking with
output_config.effort.
Per model
claude-fable-5-1: Use{"type":"adaptive"}and set depth withoutput_config.effort;budget_tokensis rejected.claude-opus-5-5: Use{"type":"adaptive"}and set depth withoutput_config.effort;budget_tokensis rejected.claude-sonnet-5-5: Use{"type":"adaptive"}and set depth withoutput_config.effort;budget_tokensis rejected.
Example
output_config.effort
string
Optional
How much reasoning the model does. Start with high, then evaluate one level lower and higher on your own workload.
Allowed values: low, medium, high, xhigh, max
cache_control
object
Optional
Prompt caching. Put it on a system, messages or tools block to cache everything up to that block, or at the top level of the request. ttl is 5m (default) or 1h.
Allowed values: {"type":"ephemeral"}
- Cache reads, 5-minute cache writes and 1-hour cache writes are metered separately; a cached prefix is charged as a cache read, not as fresh input.
- The cache hit counts are in
usage.cache_read_input_tokensandusage.cache_creation_input_tokens.
Example
Tool use loop
When stop_reason is tool_use, append the assistant message as it was returned, run the tool, and send the result in a tool_result block of the next user message. Send the same tools again.
Response
A non-streaming call returns one JSON object. This is an abbreviated example.
Response fields
Streaming
Set "stream": true. The response is a stream of Anthropic server-sent events, compatible with the Anthropic SDK.
- The events are
message_start,ping,content_block_start,content_block_delta,content_block_stop,message_deltaandmessage_stop. - Text arrives in
text_delta, tool input ininput_json_delta(concatenate the fragments, then parse), and thinking text inthinking_delta. stop_reasonand the final output token count arrive inmessage_delta.- The response is
text/event-stream; without streaming it isapplication/json. A failure before the model is called is returned as a normal JSON error with an HTTP status, not as a stream event. - Set explicit timeouts and reconnect a streamed response safely.
Errors
HTTP errors at a glance
Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: error.code, error.message, retryable, request_id. Every other failure keeps the Anthropic shape {"type": "error", "error": {"type", "message"}}: the code is in error.type and the request id ends message. See Errors.
Full code table and retry policy: Errors.
Notes
- Claude models answer only on Anthropic Messages, not on OpenAI Responses.
- Thinking tokens are billed as output tokens and count toward
max_tokens. Budget enough output for thinking plus the answer. - Keep API keys on trusted servers, log the response request ID, and retry only
429,500and503.
Authentication
Send your API key as Authorization: Bearer <BEATAPI_API_KEY>.
Request
The exact model ID.
Older IDs that still work (claude-opus-5, claude-sonnet-5, claude-haiku-4-5-20251001) are on Legacy models.
Call GET /v1/models with your key to confirm which models are enabled for it.
claude-fable-5-1, claude-opus-5-5, claude-sonnet-5-5, claude-haiku-5-5
Upper bound on the generated tokens, thinking included.
Always send it. If it is missing or 0, a default limit is applied, and that default may be lower than you expect.
The largest accepted value is 1,073,741,823; a larger value is 400 bad_request. Keep it at or below the max output of the model in the table above.
max_tokens is also used to estimate how much balance a request needs. A very large value can be refused with 402 insufficient_credits even when the real output would be small. Set it to what you need.
The conversation, oldest message first. Each message has a role (user or assistant) and content. content is a string, or an array of content blocks.
Block types you will use: text, image (base64 or URL source), tool_use (in an assistant message), and tool_result (in a user message).
An empty or missing messages array is 400 bad_request.
System prompt. A string, or an array of text blocks. Put cache_control on a block to cache a long, stable prefix.
Return the answer as server-sent events. See the Streaming section below.
Custom strings that stop generation. The response then has stop_reason: "stop_sequence".
Tools the model may call. Each has a name, a description and an input_schema (JSON Schema). When the model calls one, the answer has stop_reason: "tool_use"; run the tool and return the result in a following tool_result block.
Whether and how the model must use tools.
auto lets the model decide, any forces some tool, tool forces the named tool, none forbids tools.
{"type":"auto"}, {"type":"any"}, {"type":"tool","name":"..."}, {"type":"none"}
Extended thinking. Set type to turn it on or off. Thinking tokens count toward max_tokens and are billed as output tokens.
thinking.type is one of the values above. enabled takes thinking.budget_tokens (an integer of at least 1,024, below max_tokens).
thinking.display is summarized or omitted. Newer models may return no thinking text unless you ask for summarized.
Set the depth of adaptive thinking with output_config.effort.
claude-fable-5-1: Use {"type":"adaptive"} and set depth with output_config.effort; budget_tokens is rejected.
claude-opus-5-5: Use {"type":"adaptive"} and set depth with output_config.effort; budget_tokens is rejected.
claude-sonnet-5-5: Use {"type":"adaptive"} and set depth with output_config.effort; budget_tokens is rejected.
adaptive, enabled, disabled
Prompt caching. Put it on a system, messages or tools block to cache everything up to that block, or at the top level of the request. ttl is 5m (default) or 1h.
Cache reads, 5-minute cache writes and 1-hour cache writes are metered separately; a cached prefix is charged as a cache read, not as fresh input.
The cache hit counts are in usage.cache_read_input_tokens and usage.cache_creation_input_tokens.
{"type":"ephemeral"}
Response
A non-streaming call returns one JSON object. This is an abbreviated example.
end_turn for a complete answer, max_tokens when max_tokens was reached, stop_sequence, or tool_use when the model calls a tool.

