Skip to content

Fix using anthropic models with responses API in AI SDK#146

Merged
Ken Jiang (knjiang) merged 3 commits intomainfrom
aswin/03-18-fix_using_anthropic_models_with_responses_api_in_ai_sdk
Mar 19, 2026
Merged

Fix using anthropic models with responses API in AI SDK#146
Ken Jiang (knjiang) merged 3 commits intomainfrom
aswin/03-18-fix_using_anthropic_models_with_responses_api_in_ai_sdk

Conversation

@aswink
Copy link
Contributor

@aswink aswink commented Mar 19, 2026

A customer ran into an issue where AI SDK was failing because it has strict
type checks using a zod format. It expects responses API to always have IDs for
items and an annotations field, even if empty. We were dropping these when
translating between providers. Fix this by restoring the ID if the format
matches, otherwise putting a placeholder in. Also always fill in an empty
annotations.

At some point in the future we should look at adding annotations (openai) and
citations (anthropic's version) to the universal format.

A customer ran into an issue where AI SDK was failing because it has strict
type checks using a zod format. It expects responses API to always have IDs for
items and an annotations field, even if empty. We were dropping these when
translating between providers. Fix this by restoring the ID if the format
matches, otherwise putting a placeholder in. Also always fill in an empty
annotations.

At some point in the future we should look at adding annotations (openai) and
citations (anthropic's version) to the universal format.
Copy link
Contributor Author

aswink commented Mar 19, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@aswink aswink marked this pull request as ready for review March 19, 2026 00:00
@knjiang
Copy link
Contributor

i added a hook to validate via the AI SDK zod schema tests failed before :

image

tests pass after:

image

@knjiang Ken Jiang (knjiang) merged commit 8d8a501 into main Mar 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants