Files
litellm/tests/litellm
shin-bot-litellm 84934a7258 fix(anthropic): filter unsupported JSON schema constraints for structured outputs (#20813)
* fix(anthropic): filter unsupported JSON schema constraints for structured outputs

Fixes 400 error when using Anthropic models with structured outputs that have
min/max constraints.

The Anthropic API doesn't support these JSON schema constraints:
- minimum/maximum (numeric)
- exclusiveMinimum/exclusiveMaximum (numeric)
- minLength/maxLength (string)
- minItems/maxItems (array)

This mirrors the transformation done by the official Anthropic Python SDK.
See: https://platform.claude.com/docs/en/build-with-claude/structured-outputs#how-sdk-transformation-works

Adds tests for the schema filtering function.

* fix: update descriptions with removed constraint info in filter_anthropic_output_schema

Address review feedback: the function now appends removed constraint
information to the description field (matching Anthropic SDK behavior),
rather than silently dropping constraints.

---------

Co-authored-by: OpenClaw <openclaw@users.noreply.github.com>
2026-02-14 09:07:40 -08:00
..