Back to Models
Codestral
mistralmistral/codestral
API guide
Chat completion
Standard OpenAI-compatible chat completion. Codestral responds best to explicit code-generation prompts.
cURL
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mistral/codestral",
"messages": [
{"role": "user", "content": "Write a Python function to merge two sorted arrays into one sorted array."}
],
"temperature": 0.2
}'Streaming
Stream responses token-by-token for faster IDE inline suggestions or progressive code output.
cURL
curl https://api.therouter.ai/v1/chat/completions \
-H "Authorization: Bearer $THEROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "mistral/codestral",
"messages": [{"role": "user", "content": "Explain how binary search works in Python"}],
"stream": true
}'Fact ledger β every claim on this page traces here
| source | URL | retrieved | |
|---|---|---|---|
| Release date | mistral.ai β | 2026-05-27 | verified |
| Architecture | huggingface.co β | 2026-05-27 | to verify |
| Context window | mistral.ai β | 2026-05-27 | verified |
| Native fill-in-the-middle (FIM) | mistral.ai β | 2026-05-27 | verified |
| Languages | mistral.ai β | 2026-05-27 | verified |
| License | huggingface.co β | 2026-05-27 | verified |
| Successor | β | β | verified |
| HumanEval pass@1 | mistral.ai β | 2026-05-27 | verified |
| HumanEval pass@1 | mistral.ai β | 2026-05-27 | verified |
| HumanEval FIM average | mistral.ai β | 2026-05-27 | verified |
| MBPP sanitized pass@1 | mistral.ai β | 2026-05-27 | verified |
| CruxEval | mistral.ai β | 2026-05-27 | verified |
| RepoBench EM | mistral.ai β | 2026-05-27 | verified |
| Spider SQL | overchat.ai β | 2026-05-27 | to verify |
| Codestral 25.08: +30% accepted suggestions, complete Mistral coding stack | mistral.ai β | 2026-05-27 | verified |
| Codestral 25.01: 256K context, 2x speed, improved FIM | mistral.ai β | 2026-05-27 | verified |
| Is Codestral a good general-purpose chatbot? | mistral.ai β | 2026-05-27 | to verify |
| What is fill-in-the-middle (FIM) and why does it matter? | mistral.ai β | 2026-05-27 | to verify |
| Can I fine-tune Codestral on my own codebase? | huggingface.co β | 2026-05-27 | to verify |
| How does Codestral compare to Devstral 2? | mistral.ai β | 2026-05-27 | to verify |