Skip to content

anthropic: Pass beta header for speed in BYOK#57707

Merged
tomhoule merged 1 commit into
mainfrom
tomhoule-ukkntrrotzwt
May 26, 2026
Merged

anthropic: Pass beta header for speed in BYOK#57707
tomhoule merged 1 commit into
mainfrom
tomhoule-ukkntrrotzwt

Conversation

@tomhoule

Copy link
Copy Markdown
Contributor

We were sending the speed field set to "standard" for BYOK Anthropic but without the corresponding beta header. leading the requests to fail with "invalid request format to Anthropic's API: speed: Extra inputs are not permitted".

This makes sure to attach the beta header whenever the speed parameter is used.

Release Notes:

  • Fixed "speed: Extra inputs are not permitted" errors for Opus 4.6 and 4.7 in the Anthropic API provider.

We were sending the `speed` field set to `"standard"` for BYOK Anthropic but without the corresponding beta header. leading the requests to fail with "invalid request format to Anthropic's API: speed: Extra inputs are not permitted".

This makes sure to attach the beta header whenever the `speed` parameter is used.

Release Notes:

- Fixed "speed: Extra inputs are not permitted" errors for Opus 4.6 and 4.7 in the Anthropic API provider.

Until now, BYOK Anthropic requests with `Speed::Fast` were sending the `speed` field on the body without the `fast-mode-2026-02-01` beta header, so Anthropic would not honor it. Attach the header from `Model::beta_headers` whenever the request opts into fast mode, mirroring how `llm_api` already does it for Zed-hosted requests.
   >
   > Note: cloud also attaches the header for `Speed::Standard`; this change does not, on the assumption that Standard is the default and needs no opt-in. Revisit if Anthropic starts rejecting `speed: "standard"` without the beta.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 26, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 26, 2026
@tomhoule tomhoule marked this pull request as ready for review May 26, 2026 08:44
let mut extra_beta_headers = Vec::new();
if supports_speed {
extra_beta_headers.push(FAST_MODE_BETA_HEADER.to_string());
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is mediated through supported_speed, which works in practice, but we could have the speed as an extra parameter on beta_headers instead, which is a bit uglier, but closer to where we actually build the request. I went back and forth between these two options. LMK it the other one sounds better.

@tomhoule tomhoule requested a review from bennetbo May 26, 2026 08:55

@bennetbo bennetbo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you, i'm fine with the way you implemented it here

@tomhoule tomhoule added this pull request to the merge queue May 26, 2026
Merged via the queue into main with commit 49fe1fc May 26, 2026
45 checks passed
@tomhoule tomhoule deleted the tomhoule-ukkntrrotzwt branch May 26, 2026 09:03
@tomhoule

Copy link
Copy Markdown
Contributor Author

/cherry-pick preview

zed-zippy Bot added a commit that referenced this pull request May 26, 2026
…o preview) (#57711)

Cherry-pick of #57707 to preview

----
We were sending the `speed` field set to `"standard"` for BYOK Anthropic
but without the corresponding beta header. leading the requests to fail
with "invalid request format to Anthropic's API: speed: Extra inputs are
not permitted".

This makes sure to attach the beta header whenever the `speed` parameter
is used.

Release Notes:

- Fixed "speed: Extra inputs are not permitted" errors for Opus 4.6 and
4.7 in the Anthropic API provider.

Co-authored-by: Tom Houlé <13155277+tomhoule@users.noreply.github.com>
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 2, 2026
We were sending the `speed` field set to `"standard"` for BYOK Anthropic
but without the corresponding beta header. leading the requests to fail
with "invalid request format to Anthropic's API: speed: Extra inputs are
not permitted".

This makes sure to attach the beta header whenever the `speed` parameter
is used.

Release Notes:

- Fixed "speed: Extra inputs are not permitted" errors for Opus 4.6 and
4.7 in the Anthropic API provider.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants