For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Creates a message using the Anthropic Messages API format. Supports text, images, PDFs, tools, and extended thinking.
Authentication
AuthorizationBearer
API key as bearer token in Authorization header
Headers
X-OpenRouter-Experimental-MetadataenumOptional
Opt-in to surface routing metadata on the response under openrouter_metadata. Defaults to disabled.
Allowed values:
Request
This endpoint expects an object.
messageslist of objects or nullRequired
modelstringRequired
cache_controlobjectOptional
Enable automatic prompt caching. When set at the top level, the system automatically applies cache breakpoints to the last cacheable block in the request. Currently supported for Anthropic Claude models.
context_managementobject or nullOptional
max_tokensintegerOptional
metadataobjectOptional
modelslist of stringsOptional
output_configobjectOptional
Configuration for controlling output behavior. Supports the effort parameter and structured output format.
pluginslist of objectsOptional
Plugins you want to enable for this request, including their settings.
providerobjectOptional
When multiple model providers are available, optionally indicate your routing preference.
routeanyOptional
service_tierstringOptional
session_idstringOptional<=256 characters
A unique identifier for grouping related requests (e.g., a conversation or agent workflow) for observability. If provided in both the request body and the x-session-id header, the body value takes precedence. Maximum of 256 characters.
speedenumOptional
Allowed values:
stop_sequenceslist of stringsOptional
streambooleanOptional
systemstring or list of objectsOptional
temperaturedoubleOptional
thinkingobjectOptional
tool_choiceobjectOptional
toolslist of objectsOptional
top_kintegerOptional
top_pdoubleOptional
traceobjectOptional
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.
userstringOptional<=256 characters
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.