class

Anthropic::OutputSchema

Inherits Anthropic::BaseOutputSchema < Reference < Object

Output schema for structured outputs

Defines the expected structure of Claude's response using JSON Schema. When provided, Claude will output JSON matching the schema.

output_schema = OutputSchema.new(
  name: "analysis_result",
  schema: {
    "summary" => Schema.string("Brief summary"),
    "score"   => Schema.number("Confidence score", minimum: 0.0, maximum: 1.0),
    "tags"    => Schema.array(Schema.string, description: "Relevant tags"),
  },
  required: ["summary", "score"]
)

Constructors

new(name : String, schema : Hash(String, Schema::Property), description : String | Nil = nil, required : Array(String) = [] of String)
Source

Instance methods

description
Source
name
Source
required
Source
schema
Source
to_output_format

Convert to OutputFormat for API requests

Source