For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DiscordPlatform
DocumentationIntegrationsAPI referenceSDKsChangelog
DocumentationIntegrationsAPI referenceSDKsChangelog
    • Overview
  • Tracing
  • Gateway
      • OpenAI SDK
      • Instructor
      • Anthropic SDK
      • Google GenAI
      • LiteLLM
      • RubyLLM
      • Vertex AI
      • AWS Bedrock
      • Cohere
      • Groq
      • Mistral AI
      • Ollama
      • Watsonx
      • Together AI
      • Aleph Alpha
      • HuggingFace
      • Replicate
      • SageMaker
      • Respan API
  • Others
  • Migrating
    • Braintrust
    • Portkey
    • Langfuse
LogoLogo
DiscordPlatform
On this page
  • Setup
  • Gateway features
  • Switch models
  • Respan parameters
GatewayLLM SDKs

Mistral AI (gateway)

Was this page helpful?
Previous

Ollama (gateway)

Next
Built with

Setup

Install packages

OpenInference (Recommended)
Traceloop
$pip install respan-ai openinference-instrumentation-mistralai mistralai openai python-dotenv

Set environment variables

$export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No MISTRAL_API_KEY needed — the Respan gateway handles provider authentication.

Initialize and run

OpenInference (Recommended)
Traceloop
1import os
2from dotenv import load_dotenv
3
4load_dotenv()
5
6from openai import OpenAI
7from respan import Respan
8from openinference.instrumentation.mistralai import MistralAIInstrumentor
9
10# Initialize Respan with Mistral instrumentation
11respan = Respan(instrumentations=[MistralAIInstrumentor()])
12
13# Route all LLM calls through the Respan gateway
14client = OpenAI(
15 api_key=os.getenv("RESPAN_API_KEY"),
16 base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
17)
18
19response = client.chat.completions.create(
20 model="mistral-large-latest",
21 messages=[{"role": "user", "content": "Say hello in three languages."}],
22)
23print(response.choices[0].message.content)
24respan.flush()

Gateway features

The features below require routing requests through the Respan gateway — follow the setup steps above.

Switch models

Change the model parameter to use 250+ models from different providers through the same gateway.

1# Mistral
2response = client.chat.completions.create(model="mistral-large-latest", messages=messages)
3
4# OpenAI
5response = client.chat.completions.create(model="gpt-4.1-nano", messages=messages)
6
7# Anthropic
8response = client.chat.completions.create(model="claude-sonnet-4-5-20250929", messages=messages)

See the full model list.

Respan parameters

Pass additional Respan parameters via extra_body for gateway features.

1response = client.chat.completions.create(
2 model="mistral-large-latest",
3 messages=[{"role": "user", "content": "Hello"}],
4 extra_body={
5 "customer_identifier": "user_123",
6 "fallback_models": ["gpt-4.1-nano"],
7 "metadata": {"session_id": "abc123"},
8 "thread_identifier": "conversation_456",
9 },
10)

See Respan params & metadata for the full list.