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

# MessagesRequest - Go SDK

> MessagesRequest type definition

<Warning>
  The Go SDK and docs are currently in beta.
  Report issues on [GitHub](https://github.com/OpenRouterTeam/go-sdk/issues).
</Warning>

Request schema for Anthropic Messages API endpoint

## Fields

| Field                 | Type                                                                                                                           | Required             | Description                                                                                                                                                                                                                                                                                                                                                                                                          | Example                                                                                                            |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `CacheControl`        | [\*components.AnthropicCacheControlDirective](/client-sdks/go/api-reference/models/anthropiccachecontroldirective)             | :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. Currently supported for Anthropic Claude models.                                                                                                                                                                                                          | `{"type": "ephemeral"}`                                                                                            |
| `ContextManagement`   | optionalnullable.OptionalNullable\[[components.ContextManagement](/client-sdks/go/api-reference/models/contextmanagement)]     | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `MaxTokens`           | `*int64`                                                                                                                       | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Messages`            | \[][components.MessagesMessageParam](/client-sdks/go/api-reference/models/messagesmessageparam)                                | :heavy\_check\_mark: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Metadata`            | [\*components.Metadata](/client-sdks/go/api-reference/models/metadata)                                                         | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Model`               | `string`                                                                                                                       | :heavy\_check\_mark: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Models`              | \[]`string`                                                                                                                    | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `OutputConfig`        | [\*components.MessagesOutputConfig](/client-sdks/go/api-reference/models/messagesoutputconfig)                                 | :heavy\_minus\_sign: | Configuration for controlling output behavior. Supports the effort parameter and structured output format.                                                                                                                                                                                                                                                                                                           | `{"effort": "medium"}`                                                                                             |
| `Plugins`             | \[][components.MessagesRequestPlugin](/client-sdks/go/api-reference/models/messagesrequestplugin)                              | :heavy\_minus\_sign: | Plugins you want to enable for this request, including their settings.                                                                                                                                                                                                                                                                                                                                               |                                                                                                                    |
| `Provider`            | optionalnullable.OptionalNullable\[[components.ProviderPreferences](/client-sdks/go/api-reference/models/providerpreferences)] | :heavy\_minus\_sign: | When multiple model providers are available, optionally indicate your routing preference.                                                                                                                                                                                                                                                                                                                            | `{"allow_fallbacks": true}`                                                                                        |
| `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](/client-sdks/go/api-reference/models/speed)]                             | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  | fast                                                                                                               |
| `StopSequences`       | \[]`string`                                                                                                                    | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `StopServerToolsWhen` | \[][components.StopServerToolsWhenCondition](/client-sdks/go/api-reference/models/stopservertoolswhencondition)                | :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`.                                                                                                                                                                                                                                                                           | \[<br />`{"step_count": 5,"type": "step_count_is"}`,<br />`{"max_cost_in_dollars": 0.5,"type": "max_cost"}`<br />] |
| `Stream`              | `*bool`                                                                                                                        | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `System`              | [\*components.System](/client-sdks/go/api-reference/models/system)                                                             | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Temperature`         | `*float64`                                                                                                                     | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Thinking`            | [\*components.Thinking](/client-sdks/go/api-reference/models/thinking)                                                         | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `ToolChoice`          | [\*components.ToolChoice](/client-sdks/go/api-reference/models/toolchoice)                                                     | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Tools`               | \[][components.MessagesRequestToolUnion](/client-sdks/go/api-reference/models/messagesrequesttoolunion)                        | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `TopK`                | `*int64`                                                                                                                       | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `TopP`                | `*float64`                                                                                                                     | :heavy\_minus\_sign: | N/A                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                    |
| `Trace`               | [\*components.TraceConfig](/client-sdks/go/api-reference/models/traceconfig)                                                   | :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.                                                                                                                                                                       | `{"trace_id": "trace-abc123","trace_name": "my-app-trace"}`                                                        |
| `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.                                                                                                                 |                                                                                                                    |
