Repository navigation
Conversation
Claude 4.7 and later models reject temperature: 0 with a 400 invalid_request_error, and API version 2026-10-21 rejects the parameter on every model. Keep sending it only for Anthropic Compatible endpoints, where local runtimes may still honor it.
This branch has not been deployed
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.
Summary
Translation with the Anthropic Claude provider fails on every block when the model is a current Claude model. Each request hard-codes
temperature: 0, which the API now rejects:This PR stops sending
temperaturefrom the Anthropic provider. The Anthropic Compatible provider keepstemperature: 0, since local runtimes may still honor it.How it was found
Set up Margin from source with the Anthropic Claude provider and model
claude-haiku-5-5(the provider's built-in default,claude-3-5-haiku-latest, is an older model). Clicking Translate this page on a Hacker News thread rendered the 400 above in place of every translation; the API key and credits were valid, as the error came from the API itself.Why
Two changes on Anthropic's side make the fixed
temperature: 0fail:Per model, on API version
2023-06-01(what Margin sends today): Claude 4.7 and later models accept only the default sampling values, so any explicittemperatureother than the default returns a 400.On API version
2026-10-21:temperature,top_pandtop_kare removed for every model. From the migration guide:The same section notes that a request without these parameters samples with the defaults, and that models which already accept only the defaults, "such as Claude 4.7 and later models, sample as before."
Omitting the field works on both API versions and every model, so the provider won't need another change when Margin moves to
2026-10-21. The trade-off: on older models that still accept it (for example Claude Haiku 4.5), translations sample at the defaulttemperatureof 1.0 instead of 0.Changes
anthropic.ts: sendtemperature: 0only whensettings.provideris not"anthropic".anthropic.test.ts: assert the Anthropic request has notemperatureand the Anthropic Compatible request keepstemperature: 0.CHANGELOG.md: entry under Unreleased → Fixed.Testing
pnpm check,pnpm lint,pnpm fmt:check,pnpm check:extensionpasspnpm test: 472 tests in 42 files passNot in this PR
claude-3-5-haiku-latestis an older model; updating that default is left for a separate change.tool_choice: { type: "tool" }, which some newer Claude models (such as Claude Opus 5.5 and Claude Sonnet 5.5) also reject. Users on Haiku are unaffected; this is worth a follow-up.