#API Key does Not work

2 messages · Page 1 of 1 (latest)

halcyon bay
#

from mistralai.client import MistralClient
from mistralai.models.chat_completion import ChatMessage
import os

api_key = os.environ["xxxxxxxxxxxxx"]
model = "mistral-tiny"

client = MistralClient(api_key=api_key)

messages = [
ChatMessage(role="user", content="What is the best French cheese?")
]

No streaming

chat_response = client.chat(
model=model,
max_tokens=256,
messages=messages,
)

With streaming

for chunk in client.chat_stream(model=model, messages=messages):
print(chunk)

hoary lichen
#

Try a curl to the api. Quick way to see if it’s working.