> ## Documentation Index
> Fetch the complete documentation index at: https://openrouter.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MessagesRequest

Request schema for Anthropic Messages API endpoint

## Fields

| Field                 | Type                                                                                                                         | Required             | Description                                                                                                                                                                                                                                                                                                                                                                                                          | Example                                                                                                                                                     |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `CacheControl`        | [\*components.AnthropicCacheControlDirective](../../models/components/anthropiccachecontroldirective.mdx)                    | :heavy\_minus\_sign: | 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.                           | \{<br />"type": "ephemeral"<br />}                                                                                                                          |
| `ContextManagement`   | optionalnullable.OptionalNullable\[[components.ContextManagement](../../models/components/contextmanagement.mdx)]            | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Fallbacks`           | optionalnullable.OptionalNullable\[\[][components.MessagesFallbackParam](../../models/components/messagesfallbackparam.mdx)] | :heavy\_minus\_sign: | 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.                                                                                                                                                              | \[<br />\{<br />"model": "claude-opus-4-8"<br />}<br />]                                                                                                    |
| `MaxTokens`           | `*int64`                                                                                                                     | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Messages`            | \[][components.MessagesMessageParam](../../models/components/messagesmessageparam.mdx)                                       | :heavy\_check\_mark: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Metadata`            | [\*components.MessagesRequestMetadata](../../models/components/messagesrequestmetadata.mdx)                                  | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Model`               | `string`                                                                                                                     | :heavy\_check\_mark: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Models`              | \[]`string`                                                                                                                  | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `OutputConfig`        | [\*components.MessagesOutputConfig](../../models/components/messagesoutputconfig.mdx)                                        | :heavy\_minus\_sign: | Configuration for controlling output behavior. Supports the effort parameter and structured output format.                                                                                                                                                                                                                                                                                                           | \{<br />"effort": "medium"<br />}                                                                                                                           |
| `Plugins`             | \[][components.MessagesRequestPlugin](../../models/components/messagesrequestplugin.mdx)                                     | :heavy\_minus\_sign: | Plugins you want to enable for this request, including their settings.                                                                                                                                                                                                                                                                                                                                               |                                                                                                                                                             |
| `Provider`            | optionalnullable.OptionalNullable\[[components.ProviderPreferences](../../models/components/providerpreferences.mdx)]        | :heavy\_minus\_sign: | When multiple model providers are available, optionally indicate your routing preference.                                                                                                                                                                                                                                                                                                                            | \{<br />"allow\_fallbacks": true<br />}                                                                                                                     |
| `Safeguards`          | optionalnullable.OptionalNullable\[\[][components.AnthropicSafeguard](../../models/components/anthropicsafeguard.mdx)]       | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `ServiceTier`         | `*string`                                                                                                                    | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `SessionID`           | `*string`                                                                                                                    | :heavy\_minus\_sign: | 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. |                                                                                                                                                             |
| `Speed`               | optionalnullable.OptionalNullable\[[components.Speed](../../models/components/speed.mdx)]                                    | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  | fast                                                                                                                                                        |
| `StopSequences`       | \[]`string`                                                                                                                  | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `StopServerToolsWhen` | \[][components.StopServerToolsWhenCondition](../../models/components/stopservertoolswhencondition.mdx)                       | :heavy\_minus\_sign: | 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.                      | \[<br />\{<br />"step\_count": 5,<br />"type": "step\_count\_is"<br />},<br />\{<br />"max\_cost\_in\_dollars": 0.5,<br />"type": "max\_cost"<br />}<br />] |
| `Stream`              | `*bool`                                                                                                                      | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `System`              | [\*components.System](../../models/components/system.mdx)                                                                    | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Temperature`         | `*float64`                                                                                                                   | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Thinking`            | [\*components.Thinking](../../models/components/thinking.mdx)                                                                | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `ToolChoice`          | [\*components.ToolChoice](../../models/components/toolchoice.mdx)                                                            | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Tools`               | \[][components.MessagesRequestToolUnion](../../models/components/messagesrequesttoolunion.mdx)                               | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `TopK`                | `*int64`                                                                                                                     | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `TopP`                | `*float64`                                                                                                                   | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                             |
| `Trace`               | [\*components.TraceConfig](../../models/components/traceconfig.mdx)                                                          | :heavy\_minus\_sign: | 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.                                                                                                                                                                       | \{<br />"trace\_id": "trace-abc123",<br />"trace\_name": "my-app-trace"<br />}                                                                              |
| `User`                | `*string`                                                                                                                    | :heavy\_minus\_sign: | 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.                                                                                                                 |                                                                                                                                                             |
