> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic Provider

> Use Anthropic Claude models with PraisonAI TypeScript

# Anthropic Provider

Use Anthropic's Claude models including Claude 4, Claude 3.5 Sonnet, and Claude 3 Opus.

## Environment Variables

```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
export ANTHROPIC_API_KEY=sk-ant-...
```

| Variable            | Required | Description            |
| ------------------- | -------- | ---------------------- |
| `ANTHROPIC_API_KEY` | Yes      | Your Anthropic API key |

## Supported Modalities

| Modality   | Supported |
| ---------- | --------- |
| Text/Chat  | ✅         |
| Embeddings | ❌         |
| Image      | ✅         |
| Audio      | ❌         |
| Speech     | ❌         |
| Tools      | ✅         |

## Quick Start

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';

const agent = new Agent({
  name: 'Claude',
  instructions: 'You are a helpful assistant.',
  llm: 'anthropic/claude-sonnet-4-20250514'
});

const response = await agent.chat('Hello!');
console.log(response);
```

## Available Models

| Model                        | Description            | Context |
| ---------------------------- | ---------------------- | ------- |
| `claude-sonnet-4-20250514`   | Latest Claude 4 Sonnet | 200K    |
| `claude-opus-4-5`            | Most capable           | 200K    |
| `claude-3-5-sonnet-20241022` | Claude 3.5 Sonnet      | 200K    |
| `claude-3-opus-20240229`     | Claude 3 Opus          | 200K    |
| `claude-3-haiku-20240307`    | Fast, efficient        | 200K    |

## Advanced Configuration

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';

const agent = new Agent({
  name: 'AnalystClaude',
  instructions: 'You are an expert analyst.',
  llm: 'anthropic/claude-sonnet-4-20250514',
  llmConfig: {
    temperature: 0.7,
    maxTokens: 8192,
  }
});
```

## With Tools

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';

const calculatorTool = {
  name: 'calculator',
  description: 'Perform calculations',
  parameters: {
    type: 'object',
    properties: {
      expression: { type: 'string', description: 'Math expression' }
    },
    required: ['expression']
  },
  execute: async ({ expression }) => {
    return eval(expression).toString();
  }
};

const agent = new Agent({
  name: 'MathClaude',
  instructions: 'Help with calculations.',
  llm: 'anthropic/claude-sonnet-4-20250514',
  tools: [calculatorTool]
});
```

## Vision (Image Input)

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';

const agent = new Agent({
  name: 'VisionClaude',
  instructions: 'Analyze images.',
  llm: 'anthropic/claude-sonnet-4-20250514'
});

const response = await agent.chat({
  content: 'What is in this image?',
  images: ['https://example.com/image.jpg']
});
```

## Streaming

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent } from 'praisonai';

const agent = new Agent({
  name: 'StreamClaude',
  instructions: 'You are helpful.',
  llm: 'anthropic/claude-sonnet-4-20250514'
});

for await (const chunk of agent.stream('Tell me a story')) {
  process.stdout.write(chunk);
}
```

## Multi-Agent Workflow

```typescript theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
import { Agent, AgentTeam } from 'praisonai';

const researcher = new Agent({
  name: 'Researcher',
  instructions: 'Research topics thoroughly.',
  llm: 'anthropic/claude-sonnet-4-20250514'
});

const writer = new Agent({
  name: 'Writer',
  instructions: 'Write clear summaries.',
  llm: 'anthropic/claude-3-haiku-20240307'
});

const agents = new AgentTeam({
  agents: [researcher, writer],
  tasks: [
    { agent: researcher, description: 'Research {topic}' },
    { agent: writer, description: 'Summarize the research' }
  ]
});

const result = await agents.start({ topic: 'quantum computing' });
```

## Troubleshooting

### Invalid API Key

```
Error: Authentication failed
```

**Solution**: Verify your `ANTHROPIC_API_KEY` starts with `sk-ant-`.

### Rate Limits

```
Error: Rate limit exceeded
```

**Solution**: Implement retry logic or contact Anthropic for higher limits.

### Model Not Found

```
Error: Model not found
```

**Solution**: Check the model name includes the date suffix (e.g., `claude-sonnet-4-20250514`).

## Related

* [Anthropic CLI Usage](/docs/js/providers/anthropic-cli)
* [Providers Overview](/docs/js/providers)
