Skip to content

fix(structured outputs): avoid including beta header if output_format is missing#1121

Merged
RobertCraigie merged 3 commits intoanthropics:nextfrom
karpetrosyan:dont-include-beta-header-if-format-not-provided
Jan 20, 2026
Merged

fix(structured outputs): avoid including beta header if output_format is missing#1121
RobertCraigie merged 3 commits intoanthropics:nextfrom
karpetrosyan:dont-include-beta-header-if-format-not-provided

Conversation

@karpetrosyan
Copy link
Collaborator

@karpetrosyan karpetrosyan commented Jan 20, 2026

Third-party clients (Vertex, Bedrock) don’t support structured outputs and its beta header, so when the SDK sets it, the remote server returns Error code: 400 - {'message': 'invalid beta flag'}.

This change just avoids always setting that header, so we can still port the tool_runner and stream helpers, which use parse method internally, with minimal changes.

@karpetrosyan karpetrosyan requested a review from a team as a code owner January 20, 2026 12:20
Copy link
Collaborator

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

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

Nice!

@karpetrosyan
Copy link
Collaborator Author

@RobertCraigie merge it please if it's ready. I can't merge unfortunately, even the approved ones 😢

@RobertCraigie
Copy link
Collaborator

Ah sorry I forgot you can't do that yet :(

@RobertCraigie RobertCraigie merged commit 062077e into anthropics:next Jan 20, 2026
5 of 6 checks passed
@stainless-app stainless-app bot mentioned this pull request Jan 20, 2026
colbyguan pushed a commit that referenced this pull request Jan 29, 2026
* codegen metadata

* feat(api): migrate sending message format in output_config rather than output_format

* chore(internal): update `actions/checkout` version

* fix(structured outputs): avoid including beta header if `output_format` is missing (#1121)

* fix(structured outputs): avoid including beta header if output_format is missing

* fix ci

* fix condition

* chore(ci): upgrade `actions/github-script`

* codegen metadata

* feat: use output_config for structured outputs

* feat(api): api update

* feat(api): migrate sending message format in output_config rather than output_format

* fix lint

* review fixes

* more fixes

* keep transformed_output_format naming

* typo

* add a test

* test for conflict

* do the same for create

* feat: add deprecation warning to all calls using output_format

* test: add unit tests for output_format -> output_config migration

* fix: change warning stack level to 4 for output_format derecation

* chore: consolidate warning suppressions in unit test

* fix: remove redundant output_config formatting in tool_runner methods

---------

Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
Co-authored-by: karpetrosyan <kar.petrosyanpy@gmail.com>
Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
Co-authored-by: Cameron McAteer <246350779+cameron-mcateer@users.noreply.github.com>

* feat(client): add custom JSON encoder for extended type support

* feat(api): add support for Structured Outputs in the Messages API

* fix(client): run formatter

* fix: remove class causing breaking change (#1333)

* release: 0.77.0

---------

Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
Co-authored-by: Kar Petrosyan <92274156+karpetrosyan@users.noreply.github.com>
Co-authored-by: dtmeadows <dmeadows@stainless.com>
Co-authored-by: karpetrosyan <kar.petrosyanpy@gmail.com>
Co-authored-by: Cameron McAteer <246350779+cameron-mcateer@users.noreply.github.com>
karpetrosyan added a commit to karpetrosyan/anthropic-sdk-python that referenced this pull request Feb 3, 2026
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