Skip to content

[BUG]: AI SDK v6 sends unsupported structured-outputs-2025-11-13 anthropic-beta header, breaking Vertex AI #19700

@minimAluminiumalism

Description

@minimAluminiumalism

Description

After upgrading to opencode v1.3.4/v1.3.5, all requests to Anthropic Claude models via Vertex AI fail with HTTP 400:

Unexpected value(s) `structured-outputs-2025-11-13` for the `anthropic-beta` header.
Please consult our documentation at docs.anthropic.com or try again without the header.

This is a regression introduced by #18433 (AI SDK v6 support), which upgraded @ai-sdk/anthropic from 2.0.65 to 3.0.64. The new SDK version injects structured-outputs-2025-11-13 into the anthropic-beta header — even for simple streamText / chat requests that do not use structured outputs.

Affected versions

  • Works: opencode v1.3.3 (@ai-sdk/anthropic@2.0.65)
  • Broken: opencode v1.3.4 / v1.3.5 (@ai-sdk/anthropic@3.0.64)

Affected providers

  • google-vertex-anthropic — Vertex AI does not support this beta value
  • Potentially any Anthropic-compatible endpoint that validates anthropic-beta header values

Reproduction

  1. Install opencode v1.3.5: npm install -g opencode-ai@1.3.5
  2. Configure any Anthropic Claude model (e.g. claude-opus-4-6) via Vertex AI
  3. Send any message

Direct curl verification against Vertex AI:

# FAILS — with structured-outputs header
curl -s "https://us-east5-aiplatform.googleapis.com/v1/projects/PROJECT/locations/us-east5/publishers/anthropic/models/claude-opus-4-6:rawPredict" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Anthropic-Beta: fine-grained-tool-streaming-2025-05-14,structured-outputs-2025-11-13" \
  -d '{"anthropic_version":"vertex-2023-10-16","max_tokens":32,"messages":[{"role":"user","content":"say hi"}]}'
# → 400: Unexpected value(s) `structured-outputs-2025-11-13`

# WORKS — without structured-outputs header
curl -s "https://us-east5-aiplatform.googleapis.com/v1/projects/PROJECT/locations/us-east5/publishers/anthropic/models/claude-opus-4-6:rawPredict" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Anthropic-Beta: fine-grained-tool-streaming-2025-05-14" \
  -d '{"anthropic_version":"vertex-2023-10-16","max_tokens":32,"messages":[{"role":"user","content":"say hi"}]}'
# → 200 OK

Root cause

@ai-sdk/anthropic@3.0.64 adds structured-outputs-2025-11-13 to the anthropic-beta header via betas.add(...) even when structured outputs are not being used. This was flagged during the review of #18433:

"with this change, models that use @ai-sdk/anthropic as provider will start passing a new anthropic beta value structured-outputs-2025-11-13 inside the anthropic-beta header. This is a breaking change (currently opencode does NOT send this value) and may cause providers that don't support this to return an error."@avarayr in #18433

Prior art in vercel/ai

This exact issue was reported and partially fixed upstream:

However, the fix in @ai-sdk/anthropic is incomplete — the header is still sent for regular requests when tools with strict schemas are involved, and opencode's anthropic custom loader in provider.ts does not strip it.

Suggested fix

In the anthropic custom loader (packages/opencode/src/provider/provider.ts, line 157), override the fetch to strip structured-outputs-2025-11-13 from the anthropic-beta header before sending to the upstream provider. This is similar to how the codex plugin overrides fetch for its needs.

Alternatively, the header could be filtered in the options.headers merge logic within getSDK().

Environment

  • opencode: v1.3.5
  • OS: macOS (darwin arm64)
  • Node: v24.13.1
  • Bun: 1.3.11 (bundled)

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions