feat(genkit_anthropic): add beta/stable API selection and native structured outputs - #402
Open
adesinah wants to merge 1 commit into
Open
feat(genkit_anthropic): add beta/stable API selection and native structured outputs#402adesinah wants to merge 1 commit into
adesinah wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for Anthropic's stable and beta APIs, allowing users to opt into beta-gated features via apiVersion and betas options. It also implements native structured output support for capable models by mapping schemas directly to the output_config.format parameter, while maintaining a forced-tool fallback for older or uncurated models. The reviewer suggested an improvement to _toAnthropicSchema to automatically inject 'type': 'object' when properties or required are present but type is omitted, ensuring better robustness and consistency with the fallback path.
adesinah
force-pushed
the
fix/api_version_and_structure_output
branch
from
August 27, 2026 14:55
0a98efe to
9c7d196
Compare
adesinah
force-pushed
the
fix/api_version_and_structure_output
branch
from
August 27, 2026 15:10
9c7d196 to
194e39f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The plugin always called stable
messages.create, so no beta-gated feature was reachable, and structured output was faked with a synthetic return_output tool forced viatool_choice- which Anthropic rejects alongside extended thinking.The PR adds apiVersion ('stable' | 'beta') on both the plugin and per-request config, with the request winning and stable as the default, plus a betas override for features the curated list does not know yet. Beta requests send the anthropic-beta header on the unary and streaming paths alike. Models on Anthropic's Structured Outputs list now send the schema natively via
output_config.format, so structured output composes with manual thinking. Other models keep the forced-tool fallback, which now reportsINVALID_ARGUMENTwhen combined with manual thinking rather than letting the API reject the request.Also fixes a caller-supplied toolChoice silently unforcing
return_output.Closes #356