Skip to main content
Recipes

Anthropic

Use Anthropic's Claude models as your agent's LLM provider.

Installation

npm install @ai-sdk/anthropic

Quick Setup

import { anthropic } from "@ai-sdk/anthropic";
import { Agent, VoltAgent, createTool } from "@voltagent/core";
import { honoServer } from "@voltagent/server-hono";
import { z } from "zod";

const weatherTool = createTool({
name: "get_weather",
description: "Get weather for a location",
parameters: z.object({
location: z.string(),
}),
execute: async ({ location }) => {
return { location, temperature: 22 };
},
});

const agent = new Agent({
name: "Claude Agent",
instructions: "A helpful assistant powered by Claude",
model: anthropic("claude-sonnet-4-20250514"),
tools: [weatherTool],
});

new VoltAgent({
agents: { agent },
server: honoServer({ port: 3141 }),
});

Environment Variables

ANTHROPIC_API_KEY=your-api-key

Available Models

ModelDescription
claude-opus-4-1Most capable model
claude-sonnet-4-20250514Balanced performance
claude-3-5-haiku-20241022Fast and efficient

Full Example

See the complete example: with-anthropic on GitHub

Table of Contents