-
-
Notifications
You must be signed in to change notification settings - Fork 340
Add structured output support for Anthropic provider #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Implements structured outputs using Anthropic's structured-outputs-2025-11-13 beta API. Changes: - Add structured output capability detection for Claude 4+ models - Implement output_format parameter with json_schema type in chat payload - Add anthropic-beta header handling to append structured-outputs beta version - Add comprehensive specs for structured output functionality - Refactor model version detection helpers (claude3_or_newer, claude4_or_newer) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Move schema validation logic into dedicated class to reduce complexity in the Chat module and improve separation of concerns. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
The spec file legitimately tests two separate classes (Provider and Chat module) that are closely related but have distinct responsibilities. Disabling this cop for this file is the appropriate solution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Do you plan to add or modify specs that hit the real API and produce new/updated VCR cassettes? |
|
@tpaulshippy that should be done now. I edited I modified |
|
ping @crmne |
Hey, I tried to support structured output for Anthropic.
The only problem is that RubyLLM::Schema currently adds
strict: trueto each schema it creates. Here's a PR in that repo to fix that: danielfriis/ruby_llm-schema#28Until that is merged, the workaround is to create this subclass of RubyLLM::Schema:
AI generated:
Summary
structured-outputs-2025-11-13beta APIChanges
completemethod override to inject the structured-outputs beta header when schema is providedsupports_structured_output?method to detect Claude 4+ models that support structured outputsoutput_formatparameter withjson_schematype in payload renderingclaude3_or_newer?andclaude4_or_newer?helper methods for cleaner version detectionTest plan
🤖 Generated with Claude Code