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

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

Learn more in the [Mistral documentation](https://docs.mistral.ai/getting-started/models/).

```bash
MISTRAL_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: "mistral/codestral-latest"
});

// 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": "mistral/codestral-latest",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 256000,
    "maxOutput": 4096,
    "inputCost": 0.3,
    "outputCost": 0.9
  },
  {
    "model": "mistral/devstral-medium-2507",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.4,
    "outputCost": 2
  },
  {
    "model": "mistral/devstral-small-2505",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.1,
    "outputCost": 0.3
  },
  {
    "model": "mistral/devstral-small-2507",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.1,
    "outputCost": 0.3
  },
  {
    "model": "mistral/magistral-medium-latest",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 128000,
    "maxOutput": 16384,
    "inputCost": 2,
    "outputCost": 5
  },
  {
    "model": "mistral/magistral-small",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": true,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.5,
    "outputCost": 1.5
  },
  {
    "model": "mistral/ministral-3b-latest",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.04,
    "outputCost": 0.04
  },
  {
    "model": "mistral/ministral-8b-latest",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.1,
    "outputCost": 0.1
  },
  {
    "model": "mistral/mistral-large-latest",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 16384,
    "inputCost": 2,
    "outputCost": 6
  },
  {
    "model": "mistral/mistral-medium-2505",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 131072,
    "maxOutput": 131072,
    "inputCost": 0.4,
    "outputCost": 2
  },
  {
    "model": "mistral/mistral-medium-2508",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 262144,
    "maxOutput": 262144,
    "inputCost": 0.4,
    "outputCost": 2
  },
  {
    "model": "mistral/mistral-medium-latest",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 16384,
    "inputCost": 0.4,
    "outputCost": 2
  },
  {
    "model": "mistral/mistral-nemo",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.15,
    "outputCost": 0.15
  },
  {
    "model": "mistral/mistral-small-latest",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 16384,
    "inputCost": 0.1,
    "outputCost": 0.3
  },
  {
    "model": "mistral/open-mistral-7b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 8000,
    "maxOutput": 8000,
    "inputCost": 0.25,
    "outputCost": 0.25
  },
  {
    "model": "mistral/open-mixtral-8x22b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 64000,
    "maxOutput": 64000,
    "inputCost": 2,
    "outputCost": 6
  },
  {
    "model": "mistral/open-mixtral-8x7b",
    "imageInput": false,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 32000,
    "maxOutput": 32000,
    "inputCost": 0.7,
    "outputCost": 0.7
  },
  {
    "model": "mistral/pixtral-12b",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 0.15,
    "outputCost": 0.15
  },
  {
    "model": "mistral/pixtral-large-latest",
    "imageInput": true,
    "audioInput": false,
    "videoInput": false,
    "toolUsage": true,
    "reasoning": false,
    "contextWindow": 128000,
    "maxOutput": 128000,
    "inputCost": 2,
    "outputCost": 6
  }
]}
/>

## Advanced Configuration

### Custom Headers

```typescript
const agent = new Agent({
  name: "custom-agent",
  model: {
    url: "https://api.mistral.ai/v1",
    id: "mistral/codestral-latest",
    apiKey: process.env.MISTRAL_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
      ? "mistral/pixtral-large-latest"
      : "mistral/codestral-latest";
  }
});
```



## 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/mistral) for more details.

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

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


---
title: "ModelScope | Models | Mastra"
description: "Use ModelScope models with Mastra. 7 models available."
---

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