View Source Anthropic.OutputConfig (anthropic_community v0.5.0)

Builds output_config request-param maps for structured outputs. Pass the result as the :output_config option to Anthropic.Messages.create/2 or stream/2 to constrain Claude's response to a given JSON Schema.

Examples

Anthropic.Messages.create(client,
  model: "claude-opus-4-8",
  max_tokens: 1024,
  output_config: Anthropic.OutputConfig.json_schema(%{
    "type" => "object",
    "properties" => %{"answer" => %{"type" => "string"}},
    "required" => ["answer"]
  }),
  messages: [%{role: "user", content: "..."}]
)

Summary

Functions

Builds an output_config that constrains the response to the given JSON Schema.

Functions

Link to this function

json_schema(json_schema, opts \\ [])

View Source
@spec json_schema(
  map(),
  keyword()
) :: map()

Builds an output_config that constrains the response to the given JSON Schema.

Options

  • :effort - Reasoning effort level to apply while producing the structured output.