
Write HTML. Render video. Built for agents.
This package lets you use Claude through Vercel AI SDK by routing model calls to the Claude Agent SDK and Claude Code CLI. It handles streaming, multi-turn conversation, structured outputs, tools, sessions, and callback hooks so your app can treat Claude like a standard AI SDK model.
Builders who use Vercel AI SDK and want Claude Code as the model backend.
You can add Claude-powered generation, tool use, and session control to an AI SDK app with one provider import.
Exports `claudeCode()` so AI SDK apps can call Claude like a normal model.
Supports `streamText()`, conversation history, and session resume or fork flows.
Works with AI SDK output schemas and constrained decoding for object, array, and choice outputs.
Handles tool management, MCP servers, permissions, and tool streaming events.
Exposes `onSdkMessage`, hook and task events, `canUseTool`, `onElicitation`, and query-controller access.
Documents support lines for AI SDK v7, v6, v5, and legacy Claude SDK versions.
curl -fsSL https://claude.ai/install.sh | bash claude auth login
Latest Release: Version 4.x supports AI SDK v7 stable with the Claude Agent SDK. Version 3.x moves to maintenance for AI SDK v6 under the
ai-sdk-v6tag.
ai-sdk-provider-claude-code lets you use Claude via the Vercel AI SDK through the official @anthropic-ai/claude-agent-sdk and the Claude Code CLI.
| Provider Version | AI SDK Version | Underlying SDK | NPM Tag | Status | Branch |
|---|---|---|---|---|---|
| 4.x.x | v7 | @anthropic-ai/claude-agent-sdk | latest | Stable | main |
| 3.x.x | v6 | @anthropic-ai/claude-agent-sdk | ai-sdk-v6 | Maintenance | ai-sdk-v6 |
| 2.x.x | v5 | @anthropic-ai/claude-agent-sdk | ai-sdk-v5 | Legacy | ai-sdk-v5 |
| 1.x.x | v5 | @anthropic-ai/claude-code | v1-claude-code-sdk | Legacy | v1 |
| 0.x.x | v4 | @anthropic-ai/claude-code | ai-sdk-v4 | Legacy | ai-sdk-v4 |
Install commands for each line are listed under Installation below.
The 4.x line requires Zod ^4.1.8. Version 3.x remains available for AI SDK v6 under the ai-sdk-v6 tag.
npm install ai-sdk-provider-claude-code ai zod@^4.1.8
Note: Zod 3 support was dropped in v3.2.0 due to the underlying
@anthropic-ai/claude-agent-sdk@0.2.xrequiring Zod 4. If you need Zod 3 support, useai-sdk-provider-claude-code@3.1.x.
See the official docs for platform-specific options.
curl -fsSL https://claude.ai/install.sh | bash
claude auth login
# For AI SDK v7 (4.x; current latest tag)
npm install ai-sdk-provider-claude-code ai
# For AI SDK v6 maintenance (3.x)
npm install ai-sdk-provider-claude-code@ai-sdk-v6 ai@^6.0.0
# For AI SDK v5
npm install ai-sdk-provider-claude-code@ai-sdk-v5 ai@^5.0.0
# For AI SDK v4 (legacy)
npm install ai-sdk-provider-claude-code@ai-sdk-v4 ai@^4.3.16
# or use a specific version: npm install ai-sdk-provider-claude-code@^0.2.2
This is an unofficial community provider and is not affiliated with or endorsed by Anthropic or Vercel. By using this provider:
Please ensure you have appropriate permissions and comply with all applicable terms when using this provider.
latest)// npm install ai-sdk-provider-claude-code ai
import { streamText } from 'ai';
import { claudeCode } from 'ai-sdk-provider-claude-code';
const result = streamText({
model: claudeCode('haiku'),
prompt: 'Hello, Claude!',
});
const text = await result.text;
console.log(text);
// npm install ai-sdk-provider-claude-code@ai-sdk-v6 ai@^6.0.0
import { streamText } from 'ai';
import { claudeCode } from 'ai-sdk-provider-claude-code';
const result = streamText({
model: claudeCode('haiku'),
prompt: 'Hello, Claude!',
});
const text = await result.text;
console.log(text);
// npm install ai-sdk-provider-claude-code@ai-sdk-v5 ai@^5.0.0
import { streamText } from 'ai';
import { claudeCode } from 'ai-sdk-provider-claude-code';
const result = streamText({
model: claudeCode('haiku'),
prompt: 'Hello, Claude!',
});
const text = await result.text;
console.log(text);
This release ports the provider to AI SDK v7 / LanguageModelV4, adds first-class Claude Agent SDK callback, query-controller, MCP, and image support, and keeps the v7 support boundaries explicit:
^4.1.8require() is no longer availabletool-result parts/events with isError: true instead of the provider-specific tool-error stream extensionVersion 4.0.0 intentionally keeps optional provider surfaces absent unless the Claude Agent SDK has a durable provider-reference mapping:
ProviderV4.files() is not implemented yet. The AI SDK interface uploads { type: 'data' } or { type: 'text' } bytes and returns a reusable provider reference, but Claude Agent SDK 0.3.263 exposes no direct upload/reuse API for that contract. This provider forwards inline image file parts in prompts; non-image inline files (for example PDFs) emit an unsupported-file call warning and are not forwarded. It does not upload files into durable provider references.[File <name>: <mediaType>]; raw file bytes are not re-sent on replay. Richer tool-result file replay, such as re-sending actual image/file bytes for tool-result file parts, is deferred.ProviderV4.skills() is not implemented yet. Claude Code skills are loaded from configured user/project/local skill directories with the existing skills setting below; there is no Agent SDK API that uploads a skill bundle and returns an AI SDK provider reference.@ai-sdk/provider-utils@5.0.27 exposes WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, and serializeModelOptions() for provider model classes in the AI SDK v7 stack, but this provider has not added a serialization contract for provider instances or settings. Callback/function settings such as canUseTool, hooks, logger, spawnClaudeCodeProcess, and SessionStore methods are not JSON-serializable and must be recreated by the application.custom and reasoning-file parts are not emitted as provider output yet. Claude Agent SDK 0.3.263 has no durable reasoning-file artifact output that maps to AI SDK reasoning-file; assistant-history custom and reasoning-file parts have no Claude Code replay representation and are skipped (unknown unsupported content variants still warn).This version upgrades to AI SDK v6 stable with updated provider types:
usage.raw now contains raw provider usage (previously in providerMetadata['claude-code'].rawUsage)LanguageModelV3Usage and LanguageModelV3FinishReason (transparent to most users)This version migrates to @anthropic-ai/claude-agent-sdk with new defaults for better control:
See Breaking Changes Guide for details on migrating from v0.x to v1.x.
Key changes:
fable - Claude Fable (most capable)opus - Claude Opus (highly capable)sonnet - Claude Sonnet (balanced performance)haiku - Claude Haiku (fastest, most cost-effective)You can also use full model identifiers directly (e.g., claude-fable-5, claude-sonnet-4-6, claude-opus-4-8).
The docs/ai-sdk-v4/ and docs/ai-sdk-v5/ directories cover legacy provider versions (0.x and 1.x–2.x respectively) and are kept for reference.
Version 2.0.0 migrates from @anthropic-ai/claude-code to @anthropic-ai/claude-agent-sdk. Two defaults changed:
Restore old behavior explicitly:
import { claudeCode } from 'ai-sdk-provider-claude-code';
const model = claudeCode('sonnet', {
systemPrompt: { type: 'preset', preset: 'claude_code' },
settingSources: ['user', 'project', 'local'],
});
CLAUDE.md requires:
systemPrompt: { type: 'preset', preset: 'claude_code' }settingSources includes 'project'New recommended behavior (explicit config):
const model = claudeCode('sonnet', {
systemPrompt: 'You are a helpful assistant specialized in ...',
settingSources: ['project'], // or omit for no filesystem settings
});
CLI install and auth are unchanged:
curl -fsSL https://claude.ai/install.sh | bash
claude auth login
If you're upgrading from version 1.x:
npm install ai-sdk-provider-claude-code@ai-sdk-v5const model = claudeCode('sonnet', {
systemPrompt: { type: 'preset', preset: 'claude_code' },
settingSources: ['user', 'project', 'local'],
});
Benefits of v2.0.0:
This provider supports native structured outputs via Claude Agent SDK constrained decoding. On the 4.x line (AI SDK v7), use generateText() with an output specification such as Output.object({ schema }), then destructure output from the result. For streaming structured output, use streamText() with the same output setting and read partialOutputStream as partial objects arrive.
import { generateText, Output } from 'ai';
import { claudeCode } from 'ai-sdk-provider-claude-code';
import { z } from 'zod';
const UserProfileSchema = z.object({
name: z.string(),
age: z.number(),
email: z.string().describe('Email address (validate client-side)'),
});
const { output } = await generateText({
model: claudeCode('sonnet'),
output: Output.object({ schema: UserProfileSchema }),
prompt: 'Generate a user profile for a software developer',
});
console.log(output); // Matches the schema above
// { name: "Alex Chen", age: 28, email: "alex@example.com" }
Benefits:
Note: Schema-less JSON output (AI SDK v7
Output.json()) is not supported by Claude Code; useOutput.object()/Output.array()/Output.choice()with a schema or choices. The provider emits a V4unsupportedwarning withfeature: 'responseFormat'and treats the call as plain text.Current CLI limitation: Some JSON Schema features can cause the Claude Code CLI to silently fall back to prose (no
structured_output). The provider mitigates the most common case:formatkeywords (date-time,uri,uuid, ... — produced by Zod's.datetime(),.email(),.url(),.uuid()) are stripped client-side before the schema is sent, with the hint folded into the field'sdescription(e.g.,(expected format: email)). Server-side enforcement offormatstill does not exist in the CLI, but the AI SDK validatesoutputagainst your original Zod schema client-side, so nothing is lost. Complex regexpatterns (lookaheads/backreferences) remain unmitigated —patternis passed through untouched because the CLI genuinely rejects some patterns. Keep generation schemas simple and enforce stricter invariants after generation.If you are staying on the 3.x (AI SDK v6) line, its legacy structured-output examples may still use
generateObject()/streamObject(); new 4.x code should usegenerateText()/streamText()withOutput.
onSdkMessage, task/hook/MCP status events, canUseTool, onElicitation)DevTools and OpenTelemetry/OTel telemetry registration are app-level ai package features. This provider exposes standard AI SDK v7 metadata and stream parts for them, but adds no runtime dependencies for DevTools or OTel.
This provider exposes Agent SDK options directly. Key options include:
| Option | Description |
|---|---|
betas | Enable beta features (e.g., ['context-1m-2025-08-07']) |
sandbox | Configure sandbox behavior ({ enabled: true }). Cannot be combined with a settings file path (inline settings objects are fine) |
plugins | Load custom plugins from local paths |
resumeSessionAt | Resume session at a specific message UUID |
resumeDropsTurn | Guard resume + resumeSessionAt with the discarded prompt UUID; consumed after success. See guarded rewind |
enableFileCheckpointing | Enable file rewind support |
maxBudgetUsd | Maximum budget in USD for the query |
tools | Tool configuration (array of names or preset) |
allowDangerouslySkipPermissions | Allow bypassing permissions |
persistSession | When false, disables session persistence to disk (v3.2.0+) |
spawnClaudeCodeProcess | Custom process spawner for VMs/containers (v3.2.0+) |
permissionMode | Permission mode: 'default', 'acceptEdits', 'bypassPermissions', 'plan', 'dontAsk', 'auto' ('auto' and 'dontAsk' added in SDK 0.3.x; 'delegate' was removed in SDK 0.3.x and the CLI rejects it, so the provider rejects it at validation time) |
sessionId | Use a specific session ID for deterministic tracking and correlation (v3.4.0+). Must be a valid UUID; cannot be combined with continue/resume unless forkSession is also set |
debug | Enable programmatic debug logging from the SDK (v3.4.0+) |
debugFile | Path to a file for SDK debug log output (v3.4.0+) |
effort | Effort level: 'low', 'medium', 'high', 'xhigh', or 'max' |
thinking | Thinking config: { type: 'adaptive' }, { type: 'enabled', budgetTokens?: number }, or { type: 'disabled' } |
promptSuggestions | Enable prompt suggestions (boolean) |
skills | Enable skills for the session: 'all' or an array of skill names (v3.5.0+) |
settings | Inline Settings object or path to a settings JSON file (v3.5.0+) |
managedSettings | Restrictive policy-tier settings enforced on the subprocess (v3.5.0+) |
Sign in to join the discussion.
No comments yet. Be the first to say what this is good for.

Write HTML. Render video. Built for agents.
Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps
SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.
A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.
🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!