Create a message
Changed onCreates a message using the Anthropic Messages API format. Supports text, images, PDFs, tools, and extended thinking.
Request
- Base URLhttps://openrouter.ai/api/v1
- AuthHTTP bearer
Headers
Opt-in level for surfacing routing metadata on the response under openrouter_metadata.
Opt-in to surface routing metadata on the response under openrouter_metadata. Defaults to disabled. The legacy header X-OpenRouter-Experimental-Metadata is also accepted for backward compatibility.
Request body
Request schema for Anthropic Messages API endpoint
Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. When set on an individual content block, it marks an explicit cache breakpoint; block-level markers also work on OpenAI models that support explicit prompt caching — OpenRouter converts them to the provider's native format.
Opt-in versioned router-level deferred-tool protocol. Replay assistant reasoning unchanged on continuation. The portable profile needs the catalog unchanged across a continuation; the universal profile accepts a changed catalog and, with announce_catalog_changes, tells the model about it.
Fallback models to try if the primary model fails or refuses, in order. Handled by OpenRouter multi-model routing rather than Anthropic server-side fallbacks; cannot be combined with models. Each entry accepts only model. Maximum of 3 entries.
Configuration for controlling output behavior. Supports the effort parameter and structured output format.
Plugins you want to enable for this request, including their settings.
When multiple model providers are available, optionally indicate your routing preference.
DEPRECATED Use providers.sort.partition instead. Backwards-compatible alias for providers.sort.partition. Accepts legacy values: "fallback" (maps to "model"), "sort" (maps to "none").
A unique identifier for grouping related requests (e.g., a conversation or agent workflow). When provided, OpenRouter uses it as the sticky routing key, routing all requests in the session to the same provider to maximize prompt cache hits. Also used for observability grouping. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
Controls output generation speed. When set to fast, uses a higher-speed inference configuration at premium pricing. Defaults to standard when omitted.
Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides max_tool_calls. When a condition fires while the model is still emitting tool calls, the pending tool calls are executed and one final turn is made with tool calls disabled so the response ends with a natural-language answer instead of an unfinished tool call.
Metadata for observability and tracing. Known keys (trace_id, trace_name, span_name, generation_name, parent_span_id) have special handling. Additional keys are passed through as custom metadata to configured broadcast destinations.
A unique identifier representing your end-user, which helps distinguish between different users of your app. This allows your app to identify specific users in case of abuse reports, preventing your entire app from being affected by the actions of individual users. Maximum of 256 characters.
Example request
{
"max_tokens": 1024,
"messages": [
{
"content": "Hello, how are you?",
"role": "user"
}
],
"model": "anthropic/claude-4.5-sonnet-20250929",
"temperature": 0.7
}Response
Successful response
Non-streaming response from the Anthropic Messages API with OpenRouter extensions
Example response
{
"container": null,
"content": [
{
"citations": [],
"text": "Hello! I'm doing well, thank you for asking.",
"type": "text"
}
],
"id": "msg_01XFDUDYJgAACzvnptvVoYEL",
"model": "claude-sonnet-4-5-20250929",
"role": "assistant",
"stop_details": null,
"stop_reason": "end_turn",
"stop_sequence": null,
"type": "message",
"usage": {
"cache_creation": null,
"cache_creation_input_tokens": null,
"cache_read_input_tokens": null,
"inference_geo": null,
"input_tokens": 12,
"output_tokens": 15,
"output_tokens_details": null,
"server_tool_use": null,
"service_tier": "standard"
}
}Changes
- warning
added the new
Celerisenum value to thedata/oneOf[#/components/schemas/MessagesStartEvent]/message/providerresponse property for the response status - info
added the new optional request property
provider/options/celeris - info
added the new
Celerisenum value to the request propertyprovider/ignore/items/anyOf[#/components/schemas/ProviderName]
2 more changes in this revision
- warning