Anthropic::MessageCreateParams
Inherits JSON::Serializable < Struct < Value < Object
Request parameters for messages.create()
Typed struct that serializes directly to JSON for API requests. Replaces the verbose Hash(String, JSON::Any) pattern.
params = MessageCreateParams.new(
model: "claude-sonnet-4-6",
max_tokens: 1024,
messages: [MessageParam.user("Hello!")],
stream: false
)
body_json = params.to_json
Constructors
new(model : String, max_tokens : Int32, messages : Array(MessageParam), stream : Bool | Nil = nil, system : SystemPrompt | Nil = nil, temperature : Float64 | Nil = nil, top_p : Float64 | Nil = nil, top_k : Int32 | Nil = nil, tools : Array(ToolDefinition | ServerTool) | Nil = nil, tool_choice : ToolChoice | Nil = nil, stop_sequences : Array(String) | Nil = nil, metadata : Metadata | Nil = nil, service_tier : String | Nil = nil, thinking : ThinkingConfig | Nil = nil, cache_control : CacheControl | Nil = nil, container : String | Nil = nil, output_config : OutputConfig | Nil = nil, inference_geo : String | Nil = nil, fallbacks : FallbacksParam | Nil = nil, fallback_credit_token : FallbackCreditToken | Nil = nil, diagnostics : DiagnosticsParam | Nil = nil)
Sourcenew(pull : JSON::PullParser)
Sourcenew(*, __pull_for_json_serializable pull : JSON::PullParser)
SourceInstance methods
cache_control
Sourcecontainer
Sourcediagnostics
Sourcefallbacks
Server-side fallback chain (Array(FallbackParam)) or "default".
Requires the server-side-fallback-2026-07-01 beta (auto-attached).
inference_geo
Sourcemax_tokens
Sourcemessages
Sourcemetadata
Sourcemodel
Sourceoutput_config
Sourceservice_tier
Sourcestop_sequences
Sourcestream
Sourcesystem
Sourcetemperature
Sourcethinking
Sourcetool_choice
Sourcetools
Sourcetop_k
Sourcetop_p
Source