! pip install mistralaiOur API is currently available through La Plateforme. You need to activate payments on your account to enable your API keys. After a few moments, you will be able to use our chat endpoint:
from mistralai import Mistral
api_key = "TYPE YOUR API KEY"
model = "mistral-large-latest"
client = Mistral(api_key=api_key)
chat_response = client.chat.complete(
model=model,
messages=[{"role":"user", "content":"What is the best French cheese?"}]
)
print(chat_response.choices[0].message.content)Or our embeddings endpoint:
model = "mistral-embed"
embeddings_response = client.embeddings.create(
model=model,
inputs=["Embed this sentence.", "As well as this one."]
)
print(embeddings_response)