MessagesRequest - Go SDK
MessagesRequest - Go SDK
MessagesRequest type definition
MessagesRequest - Go SDK
The Go SDK and docs are currently in beta. Report issues on GitHub.
Request schema for Anthropic Messages API endpoint
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
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"} |
ContextManagement | optionalnullable.OptionalNullable[components.ContextManagement] | ➖ | N/A | |
MaxTokens | *int64 | ➖ | N/A | |
Messages | []components.MessagesMessageParam | ✔️ | N/A | |
Metadata | *components.Metadata | ➖ | N/A | |
Model | string | ✔️ | 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. | |
Provider | optionalnullable.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. | |
Speed | optionalnullable.OptionalNullable[components.Speed] | ➖ | N/A | fast |
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. |