Messages
Send an Anthropic-compatible Messages request to a Relace-hosted model.
https://models.relace.ai with your Relace API key. The same models, pricing, and servers back Chat Completions; pick whichever dialect your client already speaks.
Models
Authentication
The key goes in either header, as your client prefers:x-api-key: <key>— what the Anthropic SDKs send.Authorization: Bearer <key>— the same header as every other Relace endpoint.
anthropic-version is accepted and ignored.
Prompt Caching
Prompt caching is automatic and needs nocache_control markers; any you send are accepted and ignored. Cache hits are billed at the Cached Input rate and reported in usage.cache_read_input_tokens, with usage.input_tokens counting only the uncached remainder. cache_creation_input_tokens is always 0: writing to the cache is free.
To keep a multi-turn session on its cache, set metadata.user_id to a stable value per session; it plays the role prompt_cache_key does on Chat Completions. See Prompt Caching and Session Affinity.
Extended Thinking
thinking: {"type": "enabled"} or "adaptive" turns a model’s reasoning on and "disabled" turns it off; budget_tokens is accepted but the models do not enforce a budget. Reasoning comes back as thinking content blocks (and thinking_delta events when streaming) with an empty signature. Reasoning tokens count toward max_tokens.
Differences from Anthropic
The request and response shapes follow the Anthropic Messages API, with these exceptions:- Content:
text,image(base64 or URL),tool_use,tool_result, andthinkingblocks are supported.documentblocks, Files API references, and search results return400. - Tools: client tools with an
input_schemaare supported, includingdisable_parallel_tool_use.tool_choiceofanyor a named tool is honored by models that support forced tool choice (forced_tool_choicein the model’ssupported_featuresfromGET /models) and served asautoby the rest. Anthropic’s server tools (web search, code execution, computer use, etc.) are ignored. - Structured output:
output_config.formatis accepted and ignored by the models above; none constrain output to a schema.output_config.effortmaps onto the model’s reasoning effort levels where it has them. stop_sequence: reported when the model identifies the matched sequence; otherwisestop_reasonisend_turn.- Not served:
/v1/messages/count_tokens, the Batches API, and the Files API.
Authorizations
Relace API key in the x-api-key header, as the Anthropic SDKs send it. Accepted on /v1/messages only.
Body
Anthropic-compatible Messages request
Anthropic-compatible request. cache_control markers and other Anthropic-only fields are accepted and ignored. Supported sampling parameters vary slightly by model.
ID of the hosted model to use, e.g. deepseek-ai/DeepSeek-V4-Flash-0731 or moonshotai/kimi-k3.
Maximum number of tokens to generate. Reasoning tokens count toward this limit, so set a generous budget.
The conversation so far, as Anthropic-format message objects with role (user or assistant) and content (a string, or an array of text, image, tool_use, tool_result, and thinking blocks).
System prompt, as a string or an array of text blocks.
If true, the response is sent as server-sent events in the Anthropic streaming format. Token usage is reported in the message_delta event.
Sampling temperature. Higher values make output more random.
Nucleus sampling: only tokens within the top top_p probability mass are considered.
Only the top_k most likely tokens are considered at each step.
Up to 4 sequences at which generation stops.
Anthropic-format tool definitions with name, description, and input_schema. Server tools are ignored.
Controls tool use: {"type": "auto"}, {"type": "any"}, {"type": "tool", "name": ...}, or {"type": "none"}. any and a named tool require a model with forced tool choice; others are served as auto. Set disable_parallel_tool_use to limit the model to one call per turn.
{"type": "enabled"} or {"type": "adaptive"} turns reasoning on; {"type": "disabled"} turns it off. budget_tokens is accepted but not enforced.
effort (low to max) maps onto the model's reasoning effort levels where it has them. format is accepted and ignored.
Response
Message generated
Unique identifier for the message, prefixed msg_
Always message
Always assistant
The model that served the request
The generated content blocks, in order: thinking (when reasoning is on), text, and tool_use (with the call's id, name, and parsed input)
Why generation stopped: end_turn, max_tokens, stop_sequence, or tool_use
The matched stop sequence when stop_reason is stop_sequence; otherwise null
Token usage information for the request