> Discover all available pages from the documentation index: https://mastra.ai/llms.txt

# ![DeepSeek logo](https://models.dev/logos/deepseek.svg)DeepSeek

Access 5 DeepSeek models through Mastra's model router. Authentication is handled automatically using the `DEEPSEEK_API_KEY` environment variable.

Learn more in the [DeepSeek documentation](https://api-docs.deepseek.com/quick_start/pricing).

```bash
DEEPSEEK_API_KEY=your-api-key
```

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

const agent = new Agent({
  id: "my-agent",
  name: "My Agent",
  instructions: "You are a helpful assistant",
  model: "deepseek/deepseek-chat"
});

// 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

| Model                                   | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
| --------------------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
| `deepseek/deepseek-chat`                | 1.0M    |       |           |       |       |       | $0.14      | $0.28       |
| `deepseek/deepseek-reasoner`            | 1.0M    |       |           |       |       |       | $0.14      | $0.28       |
| `deepseek/deepseek-v4-flash`            | 1.0M    |       |           |       |       |       | $0.14      | $0.28       |
| `deepseek/deepseek-v4-flash-vision-exp` | 1.0M    |       |           |       |       |       | $0.14      | $0.28       |
| `deepseek/deepseek-v4-pro`              | 1.0M    |       |           |       |       |       | $0.43      | $0.87       |

## Advanced configuration

### Custom headers

```typescript
const agent = new Agent({
  id: "custom-agent",
  name: "custom-agent",
  model: {
    url: "https://api.deepseek.com",
    id: "deepseek/deepseek-chat",
    apiKey: process.env.DEEPSEEK_API_KEY,
    headers: {
      "X-Custom-Header": "value"
    }
  }
});
```

### Dynamic model selection

```typescript
const agent = new Agent({
  id: "dynamic-agent",
  name: "Dynamic Agent",
  model: ({ requestContext }) => {
    const useAdvanced = requestContext.task === "complex";
    return useAdvanced
      ? "deepseek/deepseek-v4-pro"
      : "deepseek/deepseek-chat";
  }
});
```

## Provider Options

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

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

### Available Options

**thinking** (`{ type?: "adaptive" | "enabled" | "disabled" | undefined; } | undefined`)

**reasoningEffort** (`"low" | "medium" | "high" | "xhigh" | "max" | undefined`)

**strictJsonSchema** (`boolean | undefined`)