Repository navigation
[ai] Move to Anthropic SDK 1.x and API version 2026-10-21 - #103
Conversation
@anthropic-ai/sdk 0.122.0 -> 1.3.0, the first major that sends anthropic-version 2026-10-21. On that version the Claude API rejects temperature, top_p and top_k on every model, so the anthropic adapter no longer sends temperature; anthropic_compatible vendors, OpenAI and Workers AI still get it. The evals judge's temperature: 0 now samples at the default on a pre-4.7 Claude judge (agreed with the maintainer). The SDK sends the key as Authorization: Bearer for both Anthropic providers, so they share one client constructor. MessageParam is a union of per-role types: withRollingCacheBreakpoints leaves a system message alone. The SDK adds @opentelemetry/api, and the API bundle grows from 731 to 809 KiB gzip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # apps/web/package.json # docs/upgrades/unreleased.md
cliftonc
left a comment
There was a problem hiding this comment.
Thanks Robin, this is a really clean migration. The single constructor, the per-role MessageParam fix and the transport-level tests all look great.
I checked the compatible-vendor risk you flagged. Fireworks' docs say it ignores anthropic-version ("Not required. Fireworks ignores this header."), and Moonshot's Messages API spec doesn't list one. Both already took Bearer, so neither preset should notice.
One small nit before merge: porting step 40 ends with "then pnpm install so every package links the same drizzle-orm", which looks carried over from the postgres step. Could you drop that clause?
Happy to merge after that 👍
The SDK adds @opentelemetry/api, an optional peer of drizzle-orm, so the lockfile resolves a second drizzle-orm. pnpm --filter add relinks only apps/web, leaving apps/evals on the old copy and its typecheck failing on drizzle SQL types until pnpm install runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On step 40, the pnpm install is deliberate, though the step doesn't say why. The SDK brings @opentelemetry/api, which is an optional peer of drizzle-orm, so the lock file resolves a new drizzle-orm(…)(@opentelemetry/api@1.10.0)(postgres@4.0.0). pnpm --filter web add relinks only apps/web, so apps/evals keeps the old copy and tsc there reports 11 drizzle SQL type errors. I reproduced that on a clean checkout of main. I'll reword the step to give the reason rather than drop it. |
Summary
@anthropic-ai/sdkmoves from0.122.0to1.3.0, the first major that sends API version2026-10-21(was2023-06-01). Migration guide: https://platform.claude.com/docs/en/api/migration-2026-10-21What the new API version changes, and how it reaches the kit:
2026-10-21temperature/top_p/top_kare a 400 on every modelanthropicadapter never sendstemperature.ChatParams.temperaturestays, andanthropic_compatible,openai,openai_compatibleand Workers AI still get it.documentblock directly in anassistantmessage is a 400citationson ausertextblock is a 400citationsmatches are the research agent's own output field.The only call with a non-default value is the evals judge (
temperature: 0). It now samples at the default when the judge is a pre-4.7 Claude model. On Claude 4.7 and later, which already rejected the value, nothing changes. This was agreed as the option to take.The SDK's own breaking changes:
The SDK also adds
@opentelemetry/apias a dependency, so the API bundle grows from 731 to 809 KiB gzip. That's still far below Workers' limit. The SDK's licence is now Apache-2.0 (was MIT).Evidence
typecheckreports theMessageParamunion error inagent-loop.ts, andai-client.test.ts› "anthropic sends x-api-key…" fails, because the key now goes out as Bearer.After:
pnpm gatepasses on Node 26.13.0: api 639, the other web projects 1807 + 5 skipped, driver 13, cli 58, evals 25.authorization: Bearer sk-ant-secret, nox-api-key, andanthropic-version: 2026-10-21on the Claude API, and thattemperatureis gone for Claude (previously 0.2 was forwarded to Claude 4.5) but still reaches ananthropic_compatiblevendor. The temperature test failed before the adapter change.temperaturehit is a compatible, OpenAI or Workers AI path, and there's noanthropic-versionoverride in the source.Merge Danger
Door: two-way
Blast Radius: AI providers
anthropicprovider has abaseUrlpointing at a proxy that readsX-Api-Keyneeds that proxy to readAuthorization.anthropic_compatiblevendors now also receiveanthropic-version: 2026-10-21. The tests stub the vendor, so a real vendor answering on the new version is unverified. A vendor that rejects the header would fail every call, and the adapter's refusal recovery doesn't cover that. The porting note flags it.🤖 Generated with Claude Code