Call Mistral from your application
A server-side integration checklist, a minimal request, and streaming guidance.
On this page
Keep the provider key on your server
The browser sends a task to your server. Your server authenticates the user, checks allowance, and calls the provider. Never embed provider keys in browser JavaScript.
Make a first request
Set MISTRAL_API_KEY and verify the model ID in current provider documentation. This example has not been run against a paid provider in the local build.
curl https://api.mistral.ai/v1/chat/completions \
-H "Authorization: Bearer $MISTRAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"mistral-large-4","messages":[{"role":"user","content":"Explain a retry strategy."}],"max_tokens":1024}'
Handle streaming correctly
Network chunks do not necessarily align with SSE events. Buffer until an event delimiter arrives, parse data, and append incremental content. Handle errors and disconnects; do not execute incomplete tool arguments.
Verify output
Validate JSON against your schema. Run code before adopting it. Keep model limits separate from application limits.
Enable live service
Configure the database, authentication secret, provider key, and verified token prices. The local demo returns labeled fixtures.