Repository navigation
docs: update code samples to current Claude and OpenAI models - #5135
jackbridger wants to merge 7 commits into
Conversation
Several samples used models that are shut down (gpt-3.5-turbo, gpt-4-turbo, claude-sonnet-4-20250514) or retiring soon (claude-sonnet-4-5, gpt-4o). Swap them for the Claude 5.5 family and gpt-6-luna, and drop temperature from prompt configs since newer Claude models reject non-default values.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe documentation updates model identifiers across AI chat examples, AI agent guides, task examples, and integrations. Prompt examples also change selected configuration options. Compaction and tool guidance adds notes about Claude 5.5 reasoning blocks. The Nango example changes its output limit and response handling. Other examples revise telemetry setup, fallback handling, output formats, and stopping conditions. Merge Risk:
|
Claude 5.5 models think by default, reject a conversation that ends on an assistant turn, omit thinking text unless asked, and bind thinking blocks to the earlier system prompt, tools and messages. Give the compaction summarizers a final user instruction, match the head-start system prompt, request summarized thinking where reasoning is streamed, read text blocks by type in the Nango sample, and note where pruning, compaction or per-turn tools can invalidate thinking blocks.
Live testing on Claude 5.5, gpt-6-luna and ai 7 found samples that break for new users. Strip reasoning from messages kept after compaction, pass system prompts through `system` instead of the messages array on the agent pattern pages, add step limits so tool samples return text, replace the Llama 2 fallback with Claude Haiku 5.5, and fix missing or wrong imports.
…elemetry setup The image tool used experimental_toToolResultContent, which no AI SDK version we support honors, so the model never saw the chart. Use toModelOutput with a file part, switch generateObject to generateText with Output.object, and move the AI SDK 7 adapter note above the observability sample since v7 emits no spans without it.
…red output result
Summary
Code samples across the docs pointed at models that no longer work or are about to stop working:
gpt-3.5-turbo,gpt-4-turboandclaude-sonnet-4-20250514are already shut down,claude-sonnet-4-5retires on November 30, 2026, andgpt-4o/gpt-4o-minishut down in January 2027. Copying those samples today gives errors.This swaps model IDs in samples and prose to current models:
claude-sonnet-4-5,claude-sonnet-4-6,claude-sonnet-4-20250514claude-sonnet-5-5claude-haiku-4-5claude-haiku-5-5claude-opus-4-6claude-opus-5-5gpt-4o,gpt-4o-mini,gpt-4-turbo,gpt-3.5-turbogpt-6-luna(OpenAI's listed replacement forgpt-4o)Alongside the swap:
configexamples inai/promptsandai-chat/backendusedtemperature: 0.7, which Claude 5.5 and gpt-6-luna don't support (the AI SDK drops it with a warning), so the examples now usemaxOutputTokens: 1024instead.Claude 5.5 models also behave differently from 4.5 in ways a plain ID swap doesn't cover, so a few samples changed further: thinking is on by default and omits its text unless you ask for
display: "summarized", a conversation can't end on an assistant turn, and thinking blocks are bound to the earlier system prompt, tools and messages. The compaction summarizers now end with a user instruction, the head-start handler and agent share one system prompt, the Nango sample reads text blocks by type, and the native compaction and per-turn tools pages note where editing history or tools can invalidate thinking blocks.Every changed sample was run against the live APIs with current packages (
ai7,@ai-sdk/anthropic4,@ai-sdk/openai4,@anthropic-ai/sdk,openai,@trigger.dev/sdk4.8.5), with Anthropic's thinking-block check turned on the way new accounts get it. That surfaced samples that were already broken on current versions, now fixed too:{ role: "system" }insidemessages, whichai7 rejects; they now passsystem.stopWhen.A multi-turn
chat.agentbuilt from these docs (tools, summarized reasoning, two compactions) also ran end to end in a dev environment without errors.Left unchanged on purpose: the AI chat changelog (historical entries and a benchmark measured on a specific model), example-project pages that mirror code in other repos, and the DALL·E 3 image example, which needs a code change rather than a model swap and will follow separately.
Sources: OpenAI deprecations, Anthropic model deprecations.