Skip to main content

Mistral AI API

https://docs.mistral.ai/api/

API Key​

# env variable
os.environ['MISTRAL_API_KEY']

Sample Usage​

from litellm import completion
import os

os.environ['MISTRAL_API_KEY'] = ""
response = completion(
model="mistral/mistral-tiny"",
messages=[
{"role": "user", "content": "hello from litellm"}
],
)
print(response)

Sample Usage - Streaming​

from litellm import completion
import os

os.environ['MISTRAL_API_KEY'] = ""
response = completion(
model="mistral/mistral-tiny",
messages=[
{"role": "user", "content": "hello from litellm"}
],
stream=True
)

for chunk in response:
print(chunk)

Supported Models​

All models listed here https://docs.mistral.ai/platform/endpoints are supported. We actively maintain the list of models, pricing, token window, etc. here.

Model NameFunction Call
mistral-tinycompletion(model="mistral/mistral-tiny", messages)
mistral-smallcompletion(model="mistral/mistral-small", messages)
mistral-mediumcompletion(model="mistral/mistral-medium", messages)