Providers

Anthropic

Configure the Anthropic provider for Claude models.

Setup

pnpm add @ai-sdk/anthropic
import { AiSdkProvider } from "noumen";
import { createAnthropic } from "@ai-sdk/anthropic";

const anthropic = createAnthropic({
  apiKey: process.env.ANTHROPIC_API_KEY!,
  baseURL: "https://...", // optional, for proxies
});

const provider = new AiSdkProvider({
  model: anthropic("claude-opus-4.6"),
  providerFamily: "anthropic",
  cacheConfig: { enabled: true }, // enables prompt caching
});

Options

All connection-level options come from createAnthropic.

OptionSourceDescription
apiKeycreateAnthropicAnthropic API key.
baseURLcreateAnthropicOverride the API base URL.
headerscreateAnthropicCustom headers sent with every request.

AiSdkProvider options

OptionDescription
providerFamily: "anthropic"Opt in to Anthropic-specific features: extended thinking, cache breakpoints, signature/redacted passthrough. Usually inferred, but pass explicitly when the underlying model doesn't self-identify as Anthropic (custom proxies, OpenAI-shaped wrappers, etc.).
cacheConfig: { enabled: true }Inject a cache_control: { type: "ephemeral" } breakpoint on the last user/tool message. Honors ChatParams.skipCacheWrite to shift the marker one turn back for subagent forks.

Streaming

AiSdkProvider routes through the AI SDK's doStream() and maps LanguageModelV2StreamPart events to noumen's OpenAI-compatible chunk format:

  • text-start / text-delta / text-end → text deltas.
  • reasoning-start / reasoning-delta / reasoning-end → thinking deltas with signature and redacted-data passthrough intact.
  • tool-input-start / tool-input-delta / tool-input-end / tool-call → tool call deltas, with JSON repaired on the fly.
  • finish → usage + finish reason.

Extended thinking

Enable Claude's extended thinking via AgentOptions.thinking:

const agent = new Agent({
  provider,
  sandbox: LocalSandbox({ cwd: "." }),
  options: { thinking: { type: "enabled", budgetTokens: 10_000 } },
});

AiSdkProvider maps this to providerOptions.anthropic.thinking = { type: "enabled", budgetTokens: 10000 }.

Message conversion

Anthropic uses a different message format than OpenAI. AiSdkProvider handles the mapping automatically via convertToModelMessages:

  • System messages become the system parameter.
  • Tool results are wrapped in tool_result content blocks within user messages.
  • Tool calls use Anthropic's tool_use content block format.

Models

  • claude-opus-4.6 — highest capability (default for the "anthropic" CLI shorthand).
  • claude-sonnet-4 — balanced speed and capability.
  • claude-haiku-3 — fastest, most affordable.