Description
When using the Anthropic provider with toolSearchRegex_20251119() and tools marked with providerOptions: { anthropic: { deferLoading: true } }, the SDK serializes Anthropic advanced tool-use fields into the request body but does not include the required advanced-tool-use-2025-11-20 beta header.
Anthropic rejects these requests unless users manually add the beta via providerOptions.anthropic.anthropicBeta.
Reproduction
import { createAnthropic } from "@ai-sdk/anthropic";
import { generateText, tool } from "ai";
import { z } from "zod";
const anthropic = createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
await generateText({
model: anthropic("claude-sonnet-4-6"),
prompt: "hello",
tools: {
tool_search_tool_regex: anthropic.tools.toolSearchRegex_20251119(),
sample: tool({
description: "sample tool",
inputSchema: z.object({}),
providerOptions: {
anthropic: { deferLoading: true },
},
execute: async () => ({ ok: true }),
}),
},
});
Expected behavior
The Anthropic provider should automatically include:
anthropic-beta: advanced-tool-use-2025-11-20
when using toolSearchRegex_20251119(), toolSearchBm25_20251119(), or deferLoading, similar to how other Anthropic beta-gated tools/options add their required beta headers automatically.
Actual behavior
The provider sends tool_search_tool_regex_20251119 and defer_loading in the request body, but does not add advanced-tool-use-2025-11-20 to anthropic-beta.
With @ai-sdk/anthropic@3.0.85 and ai@6.0.207, intercepting the request with a fake fetch produced this header:
{
"anthropic-beta": "structured-outputs-2025-11-13",
"anthropic-version": "2023-06-01",
"content-type": "application/json"
}
A manual workaround is required:
providerOptions: {
anthropic: {
anthropicBeta: ["advanced-tool-use-2025-11-20"],
},
}
Versions
@ai-sdk/anthropic: 3.0.85
ai: 6.0.207
- Runtime used for verification:
bun@1.3.13
Notes
This looks like a provider implementation bug rather than a feature request because the SDK exposes the beta-gated API surface and serializes the corresponding request body fields, but omits the required beta header.
Description
When using the Anthropic provider with
toolSearchRegex_20251119()and tools marked withproviderOptions: { anthropic: { deferLoading: true } }, the SDK serializes Anthropic advanced tool-use fields into the request body but does not include the requiredadvanced-tool-use-2025-11-20beta header.Anthropic rejects these requests unless users manually add the beta via
providerOptions.anthropic.anthropicBeta.Reproduction
Expected behavior
The Anthropic provider should automatically include:
anthropic-beta: advanced-tool-use-2025-11-20when using
toolSearchRegex_20251119(),toolSearchBm25_20251119(), ordeferLoading, similar to how other Anthropic beta-gated tools/options add their required beta headers automatically.Actual behavior
The provider sends
tool_search_tool_regex_20251119anddefer_loadingin the request body, but does not addadvanced-tool-use-2025-11-20toanthropic-beta.With
@ai-sdk/anthropic@3.0.85andai@6.0.207, intercepting the request with a fakefetchproduced this header:{ "anthropic-beta": "structured-outputs-2025-11-13", "anthropic-version": "2023-06-01", "content-type": "application/json" }A manual workaround is required:
Versions
@ai-sdk/anthropic:3.0.85ai:6.0.207bun@1.3.13Notes
This looks like a provider implementation bug rather than a feature request because the SDK exposes the beta-gated API surface and serializes the corresponding request body fields, but omits the required beta header.