How to Use Claude API with Node.js (Complete Guide, 2026)
Dev.to AI
•
Generative AI
The official Anthropic SDK s Node.js and TypeScript out of the box. This guide covers everything from installation to streaming, tool use, and production best practices. Installation npm install -ai/sdk export ANTHROPIC_API_KEY = "your-key-here" First Message import Anthropic from " -ai/sdk "; const client = new Anthropic; const response = await client. messages. create ({ model: " claude-sonnet-4-6 ", max_tokens: 1024, messages: [{ role: " user ", content: " Explain async/await in JavaScript in 3 sentences. " }], }); console. log ( response. content [ 0.