Skip to content

Conversation

@dsfaccini
Copy link
Collaborator

Fixes #3625

many thanks to @nataziel for the reporting and suggesting a fix

),
# Bedrock does not support native structured output
supports_json_schema_output=False,
json_schema_transformer=None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BedrockProvider is not the only one that uses anthropic_model_profile, so with this changes the other providers still have the same issue.

I think we should implement this as I suggested in #3625 (comment):

That means moving the AnthropicJsonSchemaTransformer bit out of pydantic_ai.profiles.anthropic.anthropic_model_profile, and into AnthropicProvider.model_profile.

So anthropic_model_profile should not have any json_schema_transformer, and we should add it in AnthropicProvider.model_profile That way, AnthropicJsonSchemaTransformer will only be used with AnthropicProvider, not any other provider.

@dsfaccini dsfaccini requested a review from DouweM December 9, 2025 17:54
def model_profile(self, model_name: str) -> ModelProfile | None:
return anthropic_model_profile(model_name)
profile = anthropic_model_profile(model_name)
if profile:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the ModelProfile.from_profile(profile).update(...) (or ModelProfile(...).update(profile)) approach you had before better exactly because it also does the right thing when anthropic_model_profile returns None

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed it now, sorry about that

@DouweM DouweM changed the title fix: Remove anthropic dependency when running models on bedrock that don't natively support structured output Don't require anthropic dependency when using Anthropic model with other provider Dec 9, 2025
@DouweM DouweM self-assigned this Dec 9, 2025
@DouweM DouweM merged commit 34314b3 into pydantic:main Dec 9, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pydantic-ai-slim[bedrock] silently depends on anthropic

2 participants