Warning: This package is experimental and subject to change.
ai-sdk-provider-claude-code lets you use Claude via the Vercel AI SDK through the official @anthropic-ai/claude-code SDK/CLI.
npm install -g @anthropic-ai/claude-code
claude loginnpm install ai-sdk-provider-claude-code aiThis is an unofficial community provider and is not affiliated with or endorsed by Anthropic or Vercel. By using this provider:
- You understand that your data will be sent to Anthropic's servers through the Claude Code SDK
- You agree to comply with Anthropic's Terms of Service
- You acknowledge this software is provided "as is" without warranties of any kind
Please ensure you have appropriate permissions and comply with all applicable terms when using this provider.
import { generateText } from 'ai';
import { claudeCode } from 'ai-sdk-provider-claude-code';
const { text } = await generateText({
model: claudeCode('sonnet'),
prompt: 'Hello, Claude!'
});
console.log(text);opus- Claude 4 Opus (most capable)sonnet- Claude 4 Sonnet (balanced performance)
- Usage Guide - Comprehensive examples and configuration
- Troubleshooting - Common issues and solutions
- Examples - Sample scripts and patterns
- 🚀 Vercel AI SDK compatibility
- 🔄 Streaming support
- 💬 Multi-turn conversations
- 🎯 Object generation with JSON schemas
- 🛑 AbortSignal support
- 🔧 Tool management (MCP servers, permissions)
- Requires Node.js ≥ 18
- No image support
- Some AI SDK parameters unsupported (temperature, maxTokens, etc.)
We welcome contributions, especially:
- Code structure improvements
- Performance optimizations
- Better error handling
- Additional examples
See Contributing Guidelines for details.
For development status and technical details, see Development Status.
MIT