-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Based on my reading of the API documentation, this should work:
params = {
model: "claude-haiku-4-5",
max_tokens: 1000,
messages: [{role: "user", content: "respond with json"}],
betas: ["structured-outputs-2025-11-13"],
output_format: {
type: "json_schema",
schema: {
"type" => "object",
"properties" => {
"test" => {"type" => "string"}
},
"required" => ["test"],
"additionalProperties" => false
}
}
}
response = Anthropic::Client.new.messages.create(**params)
puts response.content[0].textWorth noting that I also tried:
#...
response = Anthropic::Client.new.beta.messages.create(**params)
puts response.content[0].textEither way, I get the following exception:
uninitialized constant Anthropic::Helpers::StructuredOutput (NameError)
in {output_format: {schema: Anthropic::Helpers::StructuredOutput::JsonSchemaConverter => model} => output_format}Looks like the existence of schema in output_format results in a logical branch that references a nonexistent constant.
fstybel, dschaub, ittsel-ali and benjaminjackson
Metadata
Metadata
Assignees
Labels
No labels