Skip to content

fix(translator): move output_format to output_config.format for Bedrock and Vertex - #2985

Open
joaorufino wants to merge 2 commits into
theagentrouter:mainfrom
joaorufino:fix/anthropic-output-format-cloud
Open

joaorufino wants to merge 2 commits into
theagentrouter:mainfrom
joaorufino:fix/anthropic-output-format-cloud

Conversation

@joaorufino

Copy link
Copy Markdown

Description

Claude on AWS Bedrock (InvokeModel) and GCP Vertex AI rejects the top-level output_format field of the Messages API:

400 output_format: This field is deprecated. Use 'output_config.format' instead.

Structured outputs are generally available as output_config.format, but some Anthropic-native clients still send the beta field. For example, LiteLLM (1.105 through 1.108) sets output_format for a JSON-schema response_format on models it marks as supporting native structured outputs. The AWSAnthropic and GCPAnthropic translators forward output_format unchanged, so these requests fail on both clouds.

This moves output_format to output_config.format in the AWSAnthropic and GCPAnthropic messages and count_tokens translators:

  • other output_config fields, such as effort, are kept;
  • an output_config.format already in the request takes precedence;
  • output_format: null is dropped;
  • the schema is moved verbatim, so its property order is preserved;
  • a malformed output_config (not an object) is left for the backend to reject.

The Anthropic passthrough translator is unchanged.

Each request shape, sent through the gateway (before this change) with claude-sonnet-4-6:

request body AWSAnthropic messages GCPAnthropic messages GCPAnthropic count_tokens with this change, sent as
output_format 400 deprecated 400 deprecated 400 extra inputs output_config.format
output_format + output_config.format 400 deprecated 400 deprecated output_config.format
output_format: null 400 extra inputs 400 extra inputs field dropped
output_config.format (+ effort) 200, schema applied 200, schema applied 200 unchanged

Related Issues/PRs (if applicable)

Related PR: #2040 (stripped structured outputs on GCP; this keeps them instead).

Special notes for reviewers (if applicable)

  • AWSAnthropic count_tokens is changed for consistency but not verified live (our credentials lack bedrock:CountTokens). Bedrock validates that body as an InvokeModel request, which rejects output_format.
  • The Anthropic Messages → AWS Bedrock Converse translator accepts both fields but drops the schema (200 with unconstrained output). That is a separate gap, not changed here.
  • I used an AI assistant (Claude) to help investigate and write this change; I have reviewed and tested it and can revise it as needed.

…ck and Vertex

Claude on AWS Bedrock and GCP Vertex AI rejects the top-level
output_format field ("output_format: This field is deprecated. Use
'output_config.format' instead."), while Anthropic-native clients still
send it. The AWSAnthropic and GCPAnthropic messages and count_tokens
translators now move it to output_config.format, keeping other
output_config fields; an output_config.format already in the request
takes precedence.

Signed-off-by: João Rufino <j.rufino@swordhealth.com>
@joaorufino
joaorufino requested a review from a team as a code owner November 5, 2026 22:08
@netlify

netlify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for theagentrouter canceled.

Name Link
🔨 Latest commit 21106c9
🔍 Latest deploy log https://app.netlify.com/projects/theagentrouter/deploys/6aef56cf481f6313491a63ed

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.

1 participant