Skip to content

fix: skip temperature parameter for models that reject it - #892

Open
mvanhorn wants to merge 3 commits into
DayuanJiang:mainfrom
mvanhorn:fix/861-bedrock-claude-temperature-deprecated
Open

mvanhorn wants to merge 3 commits into
DayuanJiang:mainfrom
mvanhorn:fix/861-bedrock-claude-temperature-deprecated

Conversation

@mvanhorn

Copy link
Copy Markdown

Summary

Chat requests no longer hard-fail on Bedrock Opus 4.7/4.8 model IDs when the TEMPERATURE env var is set. app/api/chat/route.ts used to spread temperature: parseFloat(process.env.TEMPERATURE) into every streamText call unconditionally; these models reject the parameter outright, so every request failed. The spread is now gated on a new supportsTemperature(modelId) helper in lib/ai-providers.ts, and a [Temperature] SKIPPED for model: ... log line (mirroring the existing [Prompt Caching] log) tells operators when their setting was ignored instead of failing the request.

Why this matters

The reporter in #861 hit undefined: The model returned the following errors: temperature is deprecated for this model on every chat request. The hosted demo was fixed on the deployment side by unsetting TEMPERATURE, but the code path is unchanged, so any self-hosted deployment with TEMPERATURE set still breaks the moment it points at an Opus 4.7/4.8 model ID. Making the code model-aware fixes it for every operator instead of requiring each one to discover the env-var workaround.

The helper matches the plain, Bedrock inference-profile, and version-suffixed ID forms:

claude-opus-4-7
us.anthropic.claude-opus-4-8-20260115-v1:0
claude-opus-4.7@20251101

and defaults to true for unknown models so nothing else changes behavior — the same conservative capability-matching approach supportsPromptCaching already takes. env.example gets a one-line note that TEMPERATURE is ignored automatically for models that reject it.

Testing

Added tests/unit/ai-providers.test.ts cases for supportsTemperature: Opus 4.7/4.8 in plain, Bedrock-prefixed, and version-suffixed forms return false; older model IDs, non-Anthropic IDs, and unknown model strings return true. Ran the unit suite, formatting check, and TypeScript compilation — all pass.

Closes #861

AI was used for assistance.

@vercel

vercel Bot commented Jul 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
next-ai-draw-io Ready Ready Preview, Comment Jul 12, 2026 8:50am

This branch was successfully deployed

1 active deployment
Preview — dfedd1b8 Deployed Jul 12, 2026 by vercel[bot]
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.

[Bug] Bedrock Claude Opus 4.8/4.7 model temperature deprecated

1 participant