Skip to content

[FEATURE] Support Anthropic's new structured outputs support #501

@tpaulshippy

Description

@tpaulshippy

Scope check

  • This is core LLM communication (not application logic)
  • This benefits most users (not just my use case)
  • This can't be solved in application code with current RubyLLM
  • I read the Contributing Guide

Due diligence

  • I searched existing issues
  • I checked the documentation

What problem does this solve?

with_schema works on some providers (OpenAI, gemini) but not on Anthropic because until now they have not had support for structured output.

Proposed solution

Implement the output_format key described at https://docs.claude.com/en/docs/build-with-claude/structured-outputs when users pass a schema to the render_payload method in lib/ruby_llm/providers/anthropic/chat.rb

Why this belongs in RubyLLM

Consistent support for structured outputs across providers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions