Open LLM API 5 min read

Mistral AI API Not Working?

Model not found (mistral-tiny removed), Codestral on the wrong endpoint, 401 auth error, rate limit 429, tool calling with wrong tool_choice values, or Pixtral vision not working? Check live status and fix step by step.

Mistral AI live status

Mistral AI — live status

Updated every 5 minutes. Full history at prismix.dev/service/mistral. API and Le Chat tracked separately.

Full status →

Current Mistral model IDs

Model ID Best for Context Endpoint
mistral-large-latest Complex reasoning, tool calling 128k api.mistral.ai
mistral-small-latest Fast + affordable (preferred default) 32k api.mistral.ai
open-mistral-nemo Free tier, multilingual 7B 128k api.mistral.ai
codestral-latest Code completion, FIM 256k codestral.mistral.ai ⚠
pixtral-12b-2409 Vision (images) 128k api.mistral.ai
pixtral-large-latest Vision + reasoning 128k api.mistral.ai
mistral-embed Embeddings (1024-dim) 8k api.mistral.ai

⚠️ Codestral uses a different base URL and different API key. See below.

Removed models (will return 404)

mistral-tiny, mistral-small (original), mistral-medium — migrate to mistral-small-latest or mistral-large-latest.

Common issues and fixes

Model not found (404)

mistral-tiny, mistral-small (v1), mistral-medium removed. Use mistral-small-latest (affordable, fast), mistral-large-latest (complex tasks), or open-mistral-nemo (free tier). Always use -latest aliases for future compatibility.

🔗

Codestral wrong endpoint

Codestral = different base URL + different key. URL: codestral.mistral.ai/v1. Key: CODESTRAL_API_KEY (separate from MISTRAL_API_KEY, create at console.mistral.ai). FIM (fill-in-middle): POST /v1/fim/completions with {"prompt":"...","suffix":"...", "model":"codestral-latest"}.

🔒

401 Unauthorized

Generate key at console.mistral.ai > API Keys. Header: Authorization: Bearer YOUR_KEY. Do NOT mix up MISTRAL_API_KEY and CODESTRAL_API_KEY — two different keys, two different endpoints.

🛑

Rate limit 429

Free tier limits: 1 req/sec, 2k tokens/min, 500k tokens/month. On 429: exponential backoff (1s → 2s → 4s). Upgrade at console.mistral.ai for higher limits. Switch to mistral-small-latest (cheaper, same limit ceiling).

🛠

Tool calling not working

Mistral tool_choice values differ from OpenAI: use "none", "auto", or "any" (NOT "required"). Tool calling only on mistral-large-latest, mistral-small-latest, codestral-latest. Not on open-mistral-nemo or mistral-embed.

🌍

EU data residency endpoint

For GDPR EU data processing: use api.eu.mistral.ai/v1 instead of api.mistral.ai/v1. Same API key works on both. Enterprise plan required for EU residency guarantee. Le Chat EU: chat.eu.mistral.ai.

Code quick reference

Standard API (Python + OpenAI SDK)

from openai import OpenAI
import os

# Mistral is fully OpenAI SDK compatible — just change base_url
client = OpenAI(
    api_key=os.environ["MISTRAL_API_KEY"],
    base_url="https://api.mistral.ai/v1",
)

response = client.chat.completions.create(
    model="mistral-small-latest",  # or mistral-large-latest
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

Codestral — code completion (different endpoint + key)

from openai import OpenAI
import os

# Codestral: DIFFERENT base_url AND different api_key!
codestral = OpenAI(
    api_key=os.environ["CODESTRAL_API_KEY"],  # NOT MISTRAL_API_KEY
    base_url="https://codestral.mistral.ai/v1",  # NOT api.mistral.ai
)

# Regular chat completions
resp = codestral.chat.completions.create(
    model="codestral-latest",
    messages=[{"role": "user", "content": "Write a Python function to sort a list"}],
)

# FIM (fill-in-middle) — unique to Codestral
import requests
fim_resp = requests.post(
    "https://codestral.mistral.ai/v1/fim/completions",
    headers={"Authorization": f"Bearer {os.environ['CODESTRAL_API_KEY']}"},
    json={
        "model": "codestral-latest",
        "prompt": "def fibonacci(",
        "suffix": "
    return result",
    },
)
print(fim_resp.json()["choices"][0]["message"]["content"])

Tool calling — use "any" not "required"

response = client.chat.completions.create(
    model="mistral-large-latest",
    messages=[{"role": "user", "content": "What's the weather in Paris?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get current weather",
            "parameters": {
                "type": "object",
                "properties": {"city": {"type": "string"}},
                "required": ["city"]
            }
        }
    }],
    tool_choice="any",  # Mistral: "any" forces tool use (NOT "required" like OpenAI)
                        # Other values: "auto" (model decides), "none" (disable tools)
)

Pixtral vision (image input)

# Vision: use pixtral-12b-2409 or pixtral-large-latest
response = client.chat.completions.create(
    model="pixtral-12b-2409",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "What's in this image?"},
            {
                "type": "image_url",
                "image_url": {
                    "url": "https://example.com/image.jpg"
                    # OR base64: "url": "data:image/jpeg;base64,..."
                }
            }
        ]
    }]
)

Step-by-step fix

  1. 1

    Check live Mistral status

    Visit prismix.dev/service/mistral. Also status.mistral.ai. API and Le Chat have separate indicators.

  2. 2

    Fix deprecated model ID

    If getting 404: replace mistral-tinyopen-mistral-nemo; mistral-small/mistral-mediummistral-small-latest. Use -latest aliases to avoid future breaking.

  3. 3

    Fix Codestral endpoint

    Codestral needs codestral.mistral.ai/v1 (NOT api.mistral.ai) and a CODESTRAL_API_KEY (create a separate key at console.mistral.ai).

  4. 4

    Fix 401 — check API key

    Go to console.mistral.ai → API Keys → create/copy key. Set header Authorization: Bearer YOUR_KEY. Do NOT swap Codestral and Mistral keys.

  5. 5

    Fix tool calling

    Use tool_choice: "any" to force tool use (Mistral uses "any" where OpenAI uses "required"). Only works on mistral-large-latest, mistral-small-latest, and codestral-latest.

🔔

Get alerted when Mistral goes down

Star Mistral on Prismix and get emailed the moment status changes. Free, no credit card.

Frequently asked questions

Why is Mistral AI API not working?

Most common causes: (1) deprecated model ID — mistral-tiny, mistral-small, mistral-medium removed; use mistral-small-latest or mistral-large-latest; (2) Codestral on wrong endpoint — needs codestral.mistral.ai/v1 and CODESTRAL_API_KEY; (3) 401 — check key at console.mistral.ai; (4) rate limit 429 — free tier 1 req/sec, 500k tok/mo; (5) outage — check prismix.dev/service/mistral.

Is Mistral AI down right now?

Check prismix.dev/service/mistral for live status. Also status.mistral.ai. The API and Le Chat are tracked independently.

Codestral not working — what's the correct base URL and API key?

Codestral uses a completely separate endpoint: https://codestral.mistral.ai/v1 (NOT api.mistral.ai). It requires a CODESTRAL_API_KEY created at console.mistral.ai — this is a different key from your regular Mistral API key. FIM (fill-in-middle): POST to /v1/fim/completions with prompt and suffix fields.

Mistral tool calling tool_choice "required" not working?

Mistral uses "any" instead of "required" to force tool use. Valid values: "none" (no tools), "auto" (model decides), "any" (must call at least one tool). Tool calling is only available on mistral-large-latest, mistral-small-latest, and codestral-latest — not on open-mistral-nemo.

Mistral JSON mode — how to enable it?

Add response_format={"type": "json_object"} to your request AND include the word "json" in your prompt/system message. Mistral (like OpenAI) requires the word in the prompt or it may ignore the format instruction. Example: {"role": "system", "content": "Respond in JSON format."} + response_format={"type": "json_object"}.

Mistral EU data residency — which endpoint?

For EU GDPR data processing: use https://api.eu.mistral.ai/v1 instead of https://api.mistral.ai/v1. Same MISTRAL_API_KEY works on both endpoints. EU residency guarantee requires Enterprise plan. Le Chat EU is at chat.eu.mistral.ai. Codestral EU: there is no separate EU Codestral endpoint as of mid-2025.

Related AI model API guides