# Codestral API — pricing & specs

Mistral AI's Codestral — a model specialized for code generation and completion, including fill-in-the-middle; the "latest" alias tracks the newest release. On KeepRouter, Codestral costs $0.30 per 1M input tokens and $0.90 per 1M output tokens, billed at cost with no markup and no monthly fee (e.g. a 1,000-token prompt with a 500-token reply costs about $0.0008). Call it through the OpenAI- or Anthropic-compatible API with the model id `codestral-latest`.

| Spec | Value |
|---|---|
| Maker | Mistral AI |
| Modality | Text |
| Input price | $0.30 per 1M tokens |
| Output price | $0.90 per 1M tokens |
| Capabilities | Streaming, Tool / function calling |
| APIs | OpenAI-compatible, Anthropic-compatible |
| Model id | `codestral-latest` |

## Call it via the OpenAI API (cURL)

```bash
curl https://keeprouter.com/v1/chat/completions \
  -H "Authorization: Bearer $KEEPROUTER_KEY" -H "Content-Type: application/json" \
  -d '{"model":"codestral-latest","messages":[{"role":"user","content":"Hello"}]}'
```

## Python

```python
from openai import OpenAI
client = OpenAI(base_url="https://keeprouter.com/v1", api_key="$KEEPROUTER_KEY")
r = client.chat.completions.create(model="codestral-latest", messages=[{"role":"user","content":"Hello"}])
```

## JavaScript

```js
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://keeprouter.com/v1", apiKey: process.env.KEEPROUTER_KEY });
const r = await client.chat.completions.create({ model: "codestral-latest", messages: [{ role: "user", content: "Hello" }] });
```

## Frequently asked questions

### How much does Codestral cost on KeepRouter?

Codestral is $0.30 per 1M input tokens and $0.90 per 1M output tokens, billed at cost with no markup and no monthly fee.

### How much does a typical Codestral request cost?

On KeepRouter, a 1,000-token prompt with a 500-token reply costs about $0.0008 — billed at cost with no markup.

### Who makes Codestral?

Codestral is made by Mistral AI. KeepRouter provides it through one OpenAI- and Anthropic-compatible API.

### How do I call Codestral via API?

Point your OpenAI- or Anthropic-compatible client at KeepRouter and set the model to "codestral-latest". It works with the OpenAI SDK, the Anthropic SDK, and Claude Code — no provider-specific SDK needed.

### Does Codestral support streaming?

Yes. KeepRouter streams Codestral responses over both the OpenAI and Anthropic APIs.

### Does Codestral support tool (function) calling?

Yes. KeepRouter passes tool calls through to Codestral and translates them between the OpenAI and Anthropic formats.

## Guides

- [Call Codestral with the OpenAI SDK](https://keeprouter.com/use-cases/openai-sdk.md)
- [Use Codestral in Claude Code](https://keeprouter.com/use-cases/claude-code.md)

## Related models from Mistral AI

- [Devstral Medium](https://keeprouter.com/models/devstral-medium-latest.md) — $0.40 per 1M input tokens and $2 per 1M output tokens
- [Magistral Medium](https://keeprouter.com/models/magistral-medium-latest.md) — $2 per 1M input tokens and $5 per 1M output tokens
- [Magistral Small](https://keeprouter.com/models/magistral-small-latest.md) — $0.50 per 1M input tokens and $1.50 per 1M output tokens
- [Ministral 14B](https://keeprouter.com/models/ministral-14b-latest.md) — $0.20 per 1M input tokens and $0.20 per 1M output tokens
- [Ministral 3B](https://keeprouter.com/models/ministral-3b-latest.md) — $0.10 per 1M input tokens and $0.10 per 1M output tokens
- [Ministral 8B](https://keeprouter.com/models/ministral-8b-latest.md) — $0.15 per 1M input tokens and $0.15 per 1M output tokens

## More

- [All models & pricing](https://keeprouter.com/models.md)
- [Quickstart](https://keeprouter.com/docs/quickstart.md)
- [Get an API key](https://keeprouter.com/login)

_Prices as of 2026-07-05._
