High severity beginner · Fix: 2-5 min

InvalidModelNameError

mistral.client.errors.InvalidModelNameError

What this error means
The Mistral client failed to find the specified model because the model name is invalid or misspelled.

Stack trace

traceback
mistral.client.errors.InvalidModelNameError: Model 'mistral-unknown-1' not found. Please verify the model name and try again.
  File "app.py", line 23, in <module>
    response = client.chat.completions.create(model="mistral-unknown-1", messages=messages)
  File "mistral/client/chat.py", line 45, in create
    raise InvalidModelNameError(f"Model '{model}' not found.")
QUICK FIX
Check and correct the model name string passed to client.chat.completions.create() to a valid Mistral model name.

Why it happens

This error occurs when the Mistral SDK is called with a model name that does not exist or is misspelled. The client validates the model name against available models and raises this error if no match is found. It can also happen if the SDK version is outdated and does not recognize newer model names.

Detection

Catch InvalidModelNameError exceptions when calling Mistral client methods and log the model name used to quickly identify invalid or unsupported model names before retrying.

Causes & fixes

1

Typo or incorrect model name passed to the Mistral client

✓ Fix

Verify the exact model name from the official Mistral documentation or SDK and update your code to use the correct model string.

2

Using a model name not supported by the installed Mistral SDK version

✓ Fix

Upgrade the Mistral SDK to the latest version that supports the desired model name.

3

Missing or incorrect environment variable for Mistral API key causing fallback to invalid defaults

✓ Fix

Set the MISTRAL_API_KEY environment variable correctly before running your application.

Code: broken vs fixed

Broken - triggers the error
python
from mistral import Client

client = Client()
messages = [{"role": "user", "content": "Hello"}]
response = client.chat.completions.create(model="mistral-unknown-1", messages=messages)  # Invalid model name triggers error
print(response)
Fixed - works correctly
python
import os
from mistral import Client

client = Client()
messages = [{"role": "user", "content": "Hello"}]
response = client.chat.completions.create(model="mistral-7b-instruct", messages=messages)  # Correct model name
print(response)
Corrected the model name to 'mistral-7b-instruct' and ensured the MISTRAL_API_KEY environment variable is set so the client can authenticate and find the model.

Workaround

Wrap the call in try/except InvalidModelNameError, then log the invalid model name and fallback to a default known valid model name programmatically.

Prevention

Always verify model names against the official Mistral SDK documentation and keep the SDK updated to support new models; use environment variables for API keys to avoid fallback errors.

Python 3.9+ · mistral-client >=1.0.0 · tested on 1.2.0
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.