Skip to main content
POST
cURL
Anthropic-compatible endpoint for open-weights models hosted on Relace infrastructure. You can also use this by pointing any Anthropic SDK at 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

See the Open Models guide for SDK examples and streaming.

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 no cache_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, and thinking blocks are supported. document blocks, Files API references, and search results return 400.
  • Tools: client tools with an input_schema are supported, including disable_parallel_tool_use. tool_choice of any or a named tool is honored by models that support forced tool choice (forced_tool_choice in the model’s supported_features from GET /models) and served as auto by the rest. Anthropic’s server tools (web search, code execution, computer use, etc.) are ignored.
  • Structured output: output_config.format is accepted and ignored by the models above; none constrain output to a schema. output_config.effort maps onto the model’s reasoning effort levels where it has them.
  • stop_sequence: reported when the model identifies the matched sequence; otherwise stop_reason is end_turn.
  • Not served: /v1/messages/count_tokens, the Batches API, and the Files API.

Authorizations

x-api-key
string
header
required

Relace API key in the x-api-key header, as the Anthropic SDKs send it. Accepted on /v1/messages only.

Body

application/json

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.

model
string
required

ID of the hosted model to use, e.g. deepseek-ai/DeepSeek-V4-Flash-0731 or moonshotai/kimi-k3.

max_tokens
integer
required

Maximum number of tokens to generate. Reasoning tokens count toward this limit, so set a generous budget.

messages
object[]
required

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
any

System prompt, as a string or an array of text blocks.

stream
boolean

If true, the response is sent as server-sent events in the Anthropic streaming format. Token usage is reported in the message_delta event.

temperature
number

Sampling temperature. Higher values make output more random.

top_p
number

Nucleus sampling: only tokens within the top top_p probability mass are considered.

top_k
integer

Only the top_k most likely tokens are considered at each step.

stop_sequences
string[]

Up to 4 sequences at which generation stops.

tools
object[]

Anthropic-format tool definitions with name, description, and input_schema. Server tools are ignored.

tool_choice
object

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.

thinking
object

{"type": "enabled"} or {"type": "adaptive"} turns reasoning on; {"type": "disabled"} turns it off. budget_tokens is accepted but not enforced.

output_config
object

effort (low to max) maps onto the model's reasoning effort levels where it has them. format is accepted and ignored.

metadata
object

Response

Message generated

id
string

Unique identifier for the message, prefixed msg_

type
string

Always message

role
string

Always assistant

model
string

The model that served the request

content
object[]

The generated content blocks, in order: thinking (when reasoning is on), text, and tool_use (with the call's id, name, and parsed input)

stop_reason
string

Why generation stopped: end_turn, max_tokens, stop_sequence, or tool_use

stop_sequence
string | null

The matched stop sequence when stop_reason is stop_sequence; otherwise null

usage
object

Token usage information for the request