Anthropic::Message
Inherits JSON::Serializable < Struct < Value < Object
Constructors
Instance methods
Changes the API made to the request's input before showing it to the model, one entry per block in request order.
Get parsed output for structured outputs
When using structured outputs, Claude returns JSON in the text content. This method parses that JSON into a JSON::Any for easy access.
output = message.parsed_output
puts output["summary"].as_s
puts output["score"].as_f
Parse structured output into a typed Crystal value
Parse structured output into a typed Crystal value, raising on failure
Returns the refusal stop details when the model refused the request.
Equivalent to a typed downcast of stop_details when its variant is
RefusalStopDetails. Returns nil for any other (or absent)
stop_details variant.
Get combined text from all text blocks
Returns empty string if no text blocks exist.
puts message.text