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.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
  • Python SDK
    • Overview
  • Go SDK
      • Analytics
      • APIKeys
      • Byok
      • Chat
      • Credits
      • Datasets
      • Embeddings
      • Endpoints
      • Generations
      • Guardrails
        • Models
        • MessagesRequest
      • OAuth
      • Observability
      • Organization
      • Presets
      • Providers
      • Rerank
      • Beta.Responses
      • Transcriptions
      • Speech
      • VideoGeneration
      • Workspaces
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Fields
Go SDKAPI ReferenceModels

MessagesRequest - Go SDK

MessagesRequest type definition
Was this page helpful?
Previous

OAuth - Go SDK

OAuth method reference
Next
Built with

The Go SDK and docs are currently in beta. Report issues on GitHub.

Request schema for Anthropic Messages API endpoint

Fields

FieldTypeRequiredDescriptionExample
CacheControl*components.AnthropicCacheControlDirective➖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"}
ContextManagementoptionalnullable.OptionalNullable[components.ContextManagement]➖N/A
MaxTokens*int64➖N/A
Messages[]components.MessagesMessageParam✔️N/A
Metadata*components.Metadata➖N/A
Modelstring✔️N/A
Models[]string➖N/A
OutputConfig*components.MessagesOutputConfig➖Configuration for controlling output behavior. Supports the effort parameter and structured output format.{"effort": "medium"}
Plugins[]components.MessagesRequestPlugin➖Plugins you want to enable for this request, including their settings.
Provideroptionalnullable.OptionalNullable[components.ProviderPreferences]➖When multiple model providers are available, optionally indicate your routing preference.{"allow_fallbacks": true}
ServiceTier*string➖N/A
SessionID*string➖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.
Speedoptionalnullable.OptionalNullable[components.Speed]➖N/Afast
StopSequences[]string➖N/A
StopServerToolsWhen[]components.StopServerToolsWhenCondition➖Stop conditions for the server-tool agent loop. Any condition firing halts the loop (OR logic). When set, this overrides max_tool_calls.[
{"step_count": 5,"type": "step_count_is"},
{"max_cost_in_dollars": 0.5,"type": "max_cost"}
]
Stream*bool➖N/A
System*components.System➖N/A
Temperature*float64➖N/A
Thinking*components.Thinking➖N/A
ToolChoice*components.ToolChoice➖N/A
Tools[]components.MessagesRequestToolUnion➖N/A
TopK*int64➖N/A
TopP*float64➖N/A
Trace*components.TraceConfig➖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➖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.