# <img src="https://models.dev/logos/anthropic.svg" alt="Anthropic logo" className="inline w-8 h-8 mr-2 align-middle dark:invert dark:brightness-0 dark:contrast-200" />Anthropic
[EN] Source: https://mastra.ai/models/providers/anthropic

Access 19 Anthropic models through Mastra's model router. Authentication is handled automatically using the `ANTHROPIC_API_KEY` environment variable.

Learn more in the [Anthropic documentation](https://docs.anthropic.com/en/docs/about-claude/models).

```bash
ANTHROPIC_API_KEY=your-api-key
```

```typescript
import { Agent } from "@mastra/core";

const agent = new Agent({
  name: "my-agent",
  instructions: "You are a helpful assistant",
  model: "anthropic/claude-3-5-haiku-20241022"
});

// Generate a response
const response = await agent.generate("Hello!");

// Stream a response
const stream = await agent.stream("Tell me a story");
for await (const chunk of stream) {
  console.log(chunk);
}
```

## Models

<ProviderModelsTable
  models={[
  {
    "model": "anthropic/claude-3-5-haiku-20241022",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 200000,
    "maxOutput": 8192,
    "inputCost": 0.8,
    "outputCost": 4
  },
  {
    "model": "anthropic/claude-3-5-haiku-latest",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 200000,
    "maxOutput": 8192,
    "inputCost": 0.8,
    "outputCost": 4
  },
  {
    "model": "anthropic/claude-3-5-sonnet-20240620",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 200000,
    "maxOutput": 8192,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-3-5-sonnet-20241022",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 200000,
    "maxOutput": 8192,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-3-7-sonnet-20250219",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-3-7-sonnet-latest",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-3-haiku-20240307",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 200000,
    "maxOutput": 4096,
    "inputCost": 0.25,
    "outputCost": 1.25
  },
  {
    "model": "anthropic/claude-3-opus-20240229",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 200000,
    "maxOutput": 4096,
    "inputCost": 15,
    "outputCost": 75
  },
  {
    "model": "anthropic/claude-3-sonnet-20240229",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 200000,
    "maxOutput": 4096,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-haiku-4-5",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 1,
    "outputCost": 5
  },
  {
    "model": "anthropic/claude-haiku-4-5-20251001",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 1,
    "outputCost": 5
  },
  {
    "model": "anthropic/claude-opus-4-0",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 32000,
    "inputCost": 15,
    "outputCost": 75
  },
  {
    "model": "anthropic/claude-opus-4-1",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 32000,
    "inputCost": 15,
    "outputCost": 75
  },
  {
    "model": "anthropic/claude-opus-4-1-20250805",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 32000,
    "inputCost": 15,
    "outputCost": 75
  },
  {
    "model": "anthropic/claude-opus-4-20250514",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 32000,
    "inputCost": 15,
    "outputCost": 75
  },
  {
    "model": "anthropic/claude-sonnet-4-0",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-sonnet-4-20250514",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-sonnet-4-5",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 3,
    "outputCost": 15
  },
  {
    "model": "anthropic/claude-sonnet-4-5-20250929",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 200000,
    "maxOutput": 64000,
    "inputCost": 3,
    "outputCost": 15
  }
]}
/>

## Advanced Configuration

### Custom Headers

```typescript
const agent = new Agent({
  name: "custom-agent",
  model: {
    id: "anthropic/claude-3-5-haiku-20241022",
    apiKey: process.env.ANTHROPIC_API_KEY,
    headers: {
      "X-Custom-Header": "value"
    }
  }
});
```

### Dynamic Model Selection

```typescript
const agent = new Agent({
  name: "dynamic-agent",
  model: ({ runtimeContext }) => {
    const useAdvanced = runtimeContext.task === "complex";
    return useAdvanced
      ? "anthropic/claude-sonnet-4-5-20250929"
      : "anthropic/claude-3-5-haiku-20241022";
  }
});
```

## Provider Options

Anthropic supports the following provider-specific options via the `providerOptions` parameter:

```typescript
const response = await agent.generate("Hello!", {
  providerOptions: {
    anthropic: {
      // See available options in the table below
    }
  }
});
```

### Available Options

<PropertiesTable
  content={[
    {
        "name": "sendReasoning",
        "type": "boolean | undefined",
        "description": "",
        "isOptional": true
    },
    {
        "name": "thinking",
        "type": "{ type: \"enabled\" | \"disabled\"; budgetTokens?: number | undefined; } | undefined",
        "description": "",
        "isOptional": true
    },
    {
        "name": "disableParallelToolUse",
        "type": "boolean | undefined",
        "description": "",
        "isOptional": true
    },
    {
        "name": "cacheControl",
        "type": "{ type: \"ephemeral\"; ttl?: \"5m\" | \"1h\" | undefined; } | undefined",
        "description": "",
        "isOptional": true
    },
    {
        "name": "container",
        "type": "{ id?: string | undefined; skills?: { type: \"anthropic\" | \"custom\"; skillId: string; version?: string | undefined; }[] | undefined; } | undefined",
        "description": "",
        "isOptional": true
    }
]}
/>



## Direct Provider Installation

This provider can also be installed directly as a standalone package, which can be used instead of the Mastra model router string. View the [package documentation](https://www.npmjs.com/package/@ai-sdk/anthropic) for more details.

```bash npm2yarn copy
npm install @ai-sdk/anthropic
```

For detailed provider-specific documentation, see the [AI SDK Anthropic provider docs](https://ai-sdk.dev/providers/ai-sdk-providers/anthropic).


---
title: "Azure"
description: "Use Azure models via the AI SDK."
---

{/* This file is auto-generated by generate-model-docs.ts - DO NOT EDIT MANUALLY */}