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
sourceURLretrieved
Release datemistral.ai β†—2026-05-27verified
Architecturehuggingface.co β†—2026-05-27to verify
Context windowmistral.ai β†—2026-05-27verified
Native fill-in-the-middle (FIM)mistral.ai β†—2026-05-27verified
Languagesmistral.ai β†—2026-05-27verified
Licensehuggingface.co β†—2026-05-27verified
Successorβ€”β€”verified
HumanEval pass@1mistral.ai β†—2026-05-27verified
HumanEval pass@1mistral.ai β†—2026-05-27verified
HumanEval FIM averagemistral.ai β†—2026-05-27verified
MBPP sanitized pass@1mistral.ai β†—2026-05-27verified
CruxEvalmistral.ai β†—2026-05-27verified
RepoBench EMmistral.ai β†—2026-05-27verified
Spider SQLoverchat.ai β†—2026-05-27to verify
Codestral 25.08: +30% accepted suggestions, complete Mistral coding stackmistral.ai β†—2026-05-27verified
Codestral 25.01: 256K context, 2x speed, improved FIMmistral.ai β†—2026-05-27verified
Is Codestral a good general-purpose chatbot?mistral.ai β†—2026-05-27to verify
What is fill-in-the-middle (FIM) and why does it matter?mistral.ai β†—2026-05-27to verify
Can I fine-tune Codestral on my own codebase?huggingface.co β†—2026-05-27to verify
How does Codestral compare to Devstral 2?mistral.ai β†—2026-05-27to verify
Help & contact