Skip to content

Mistral Integration

Mistral provides open-source and commercial AI models with European data compliance. GateFlow integrates seamlessly with Mistral's complete model portfolio for optimized routing and sustainability.

Available Models

Chat Completion Models

ModelContext WindowMax OutputInput CostOutput Cost
mistral-large-3128k8,192$2.00/1M$6.00/1M
mistral-large-latest128k8,192$2.00/1M$6.00/1M
mistral-small-3128k8,192$0.20/1M$0.60/1M
mistral-small-latest128k8,192$0.20/1M$0.60/1M
ministral-3b128k8,192$0.04/1M$0.04/1M
ministral-8b128k8,192$0.10/1M$0.10/1M
ministral-14b128k8,192$0.15/1M$0.15/1M
pixtral-large-latest128k8,192$2.00/1M$6.00/1M
devstral-2128k16,384$0.50/1M$1.50/1M
devstral-small-2128k16,384$0.10/1M$0.30/1M

Embedding Models

ModelDimensionsMax TokensCost
mistral-embed1,0248,192$0.10/1M

Speech-to-Text Models

ModelLanguagesCost
voxtral-mini-latest100+$0.02/min
voxtral-mini-2602100+$0.02/min

OCR Models

ModelCost
mistral-ocr-latest$0.01/page

Configuration

Provider Setup

bash
curl -X POST https://api.gateflow.ai/v1/management/providers \
  -H "Authorization: Bearer gw_admin_..." \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "mistral",
    "credentials": {
      "api_key": "..."
    }
  }'

Model Configuration

json
{
  "provider": "mistral",
  "credentials": {
    "api_key": "..."
  }
}

Sustainability Features

Mistral integration through GateFlow offers several sustainability benefits:

  • European Data Centers: GDPR-compliant data processing with renewable energy
  • Open-Source Options: Reduced licensing costs and environmental impact
  • Edge Deployment: Run models locally to minimize data transfer carbon footprint
  • Carbon-Optimized Routing: Automatically select the most energy-efficient EU data center
  • Time-Shifted Execution: Defer non-urgent requests to low-carbon periods

Example Usage

Basic Chat Completion

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.gateflow.ai/v1",
    api_key="gw_prod_your_key_here"
)

# Use Mistral for EU-compliant processing
response = client.chat.completions.create(
    model="mistral-large-3",
    messages=[{"role": "user", "content": "Process this GDPR-sensitive data"}],
    routing_mode="sustain_optimized",
    region="eu-west-1"
)

print(f"Response: {response.choices[0].message.content}")
print(f"Model used: {response.model}")
print(f"Carbon footprint: {response.sustainability.carbon_gco2e} gCO₂e")
print(f"Carbon saved: {response.sustainability.carbon_saved_gco2e} gCO₂e")

Coding Specialist

python
# Use Devstral for code generation
response = client.chat.completions.create(
    model="devstral-2",
    messages=[{"role": "user", "content": "Generate Python code for this algorithm"}],
    routing_mode="sustain_optimized"
)

print(f"Generated code:\n{response.choices[0].message.content}")

Using Embeddings

python
# Generate embeddings with Mistral
embedding_response = client.embeddings.create(
    model="mistral-embed",
    input=[
        "Document 1 content",
        "Document 2 content",
        "User query"
    ],
    routing_mode="sustain_optimized"
)

for i, embedding in enumerate(embedding_response.data):
    print(f"Embedding {i+1}: {len(embedding.embedding)} dimensions")
    print(f"Carbon footprint: {embedding.sustainability.carbon_gco2e} gCO₂e")

Speech-to-Text

python
# Use Voxtral for speech recognition
with open("audio.mp3", "rb") as audio_file:
    transcription = client.audio.transcriptions.create(
        model="voxtral-mini-latest",
        file=audio_file,
        routing_mode="sustain_optimized"
    )

print(f"Transcription: {transcription.text}")
print(f"Carbon saved: {transcription.sustainability.carbon_saved_gco2e} gCO₂e")

Mistral-Specific Features

Edge Deployment

python
# Configure for edge deployment
response = client.chat.completions.create(
    model="ministral-3b",
    messages=[{"role": "user", "content": "Process this locally"}],
    routing_mode="sustain_optimized",
    deployment_mode="edge"
)

Multi-modal Support

python
# Use Pixtral for vision tasks
response = client.chat.completions.create(
    model="pixtral-large-latest",
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "Analyze this image"},
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://example.com/image.jpg"
                    }
                }
            ]
        }
    ],
    routing_mode="sustain_optimized"
)

Function Calling

python
# Define functions for tool use
tools = [
    {
        "type": "function",
        "function": {
            "name": "search_database",
            "description": "Search company database",
            "parameters": {
                "type": "object",
                "properties": {
                    "query": {"type": "string"}
                }
            }
        }
    }
]

response = client.chat.completions.create(
    model="mistral-large-3",
    messages=[{"role": "user", "content": "Find sustainability data"}],
    tools=tools,
    routing_mode="sustain_optimized"
)

Model Selection Guide

Use CaseRecommended ModelKey FeaturesSustainability Benefits
Production usemistral-large-3675B parametersEU-based renewable energy
Cost-effectivemistral-small-3Balanced performanceLowest carbon footprint
Coding tasksdevstral-2123B coding specialistOptimized for development
Vision taskspixtral-large-latestMultimodalEU-based processing
Edge deploymentministral-3b3B ultra-fastMinimal energy consumption
Fast edgeministral-8b8B balancedLow-power optimization
Premium edgeministral-14b14B high-qualityEnergy-efficient architecture
EU embeddingsmistral-embed1,024 dimensionsGDPR-compliant processing
Speech-to-textvoxtral-mini-latest100+ languagesLow-carbon audio processing

Sustainability Best Practices

Optimization Strategies

  1. Leverage EU data centers: Process data in European regions for GDPR compliance and renewable energy
  2. Use edge models: Deploy Ministral models locally to minimize data transfer carbon footprint
  3. Right-size your model: Use mistral-small-3 for simple tasks instead of Large models
  4. Enable Sustain Mode: Let GateFlow automatically choose the most efficient Mistral model
  5. Use time-shifting: Defer non-urgent requests to low-carbon periods in Europe
  6. Batch requests: Process multiple items in single API calls to reduce overhead

Configuration Example

python
# Configure Mistral provider with sustainability settings
response = client.chat.completions.create(
    model="mistral:auto",  # Let GateFlow choose most efficient Mistral model
    messages=[{"role": "user", "content": "Process this sustainably in EU"}],
    routing_mode="sustain_optimized",
    minimum_quality_score=8,  # Balance quality and efficiency
    region_preference="eu-west-1",  # Prioritize EU renewable energy regions
    deployment_mode="edge"  # Use edge deployment when possible
)

Performance Characteristics

Latency Comparison

  • Fastest: ministral-3b (200ms)
  • Balanced: ministral-8b (350ms), mistral-small-3 (500ms)
  • Standard: mistral-large-3 (1,400ms)
  • Specialized: devstral-2 (1,200ms), pixtral-large-latest (900ms)

Token Limits

  • All chat models: 128K context window
  • Output limits: 8,192-16,384 tokens depending on model
  • Embedding models: 8K token input limit

Pricing Overview

  • Input prices: $0.04-$2.00 per 1M tokens
  • Output prices: $0.04-$6.00 per 1M tokens
  • Embeddings: $0.10 per 1M tokens
  • Speech-to-text: $0.02 per minute
  • OCR: $0.01 per page

Integration with Other GateFlow Features

Multi-Provider Fallbacks

python
# Configure Mistral as primary with fallbacks
response = client.chat.completions.create(
    model="mistral-large-3",  # Primary: Mistral
    messages=[{"role": "user", "content": "Important EU-compliant request"}],
    fallback_providers=["openai", "anthropic"],  # Fallback chain
    routing_mode="sustain_optimized",
    region_preference="eu-west-1"  # Keep in EU for compliance
)

Semantic Caching

python
# Cache frequent Mistral requests
response = client.chat.completions.create(
    model="mistral-small-3",
    messages=[{"role": "user", "content": "Frequently asked GDPR question"}],
    cache_ttl_seconds=3600,  # Cache for 1 hour
    embedding_model="mistral-embed"  # Use Mistral embeddings for semantic matching
)

Troubleshooting

"Mistral API key not configured"

Solution: Add your Mistral API key in the GateFlow Dashboard under Settings → Providers.

"Model not found: mistral-7b"

Solution: Use current models like mistral-small-3 instead of deprecated models.

"Rate limit exceeded"

Solution:

  1. Check your Mistral account limits
  2. Configure fallbacks to other providers
  3. Enable request queuing in GateFlow settings
  4. Use ministral-3b for high-volume applications

"Carbon savings lower than expected"

Solution:

  1. Verify Sustain Mode is properly configured
  2. Check EU grid carbon intensity
  3. Try different Mistral models for better efficiency
  4. Enable edge deployment for eligible workloads

Migration from Direct Mistral API

Key Differences

FeatureDirect Mistral APIGateFlow Mistral Integration
API FormatMistral-specificOpenAI-compatible
AuthenticationMistral API keyGateFlow API key
Model Namesmistral-7bmistral-small-3
Carbon TrackingManualAutomatic
Multi-providerNoYes
FallbacksManualAutomatic
SustainabilityBasicAdvanced optimization
Edge DeploymentLimitedFull support

Migration Example

Before (Direct Mistral API):

python
from mistralai.client import MistralClient
client = MistralClient(api_key="your-mistral-api-key")
response = client.chat(
    model="mistral-7b",
    messages=[{"role": "user", "content": "Hello from Mistral!"}]
)

After (GateFlow Integration):

python
from openai import OpenAI
client = OpenAI(
    base_url="https://api.gateflow.ai/v1",
    api_key="gw_prod_your_gateflow_key"
)
response = client.chat.completions.create(
    model="mistral-small-3",  # Use current models
    messages=[{"role": "user", "content": "Hello from Mistral via GateFlow with EU compliance!"}],
    routing_mode="sustain_optimized",  # Enable carbon optimization
    region="eu-west-1"  # Process in EU for compliance
)

Next Steps

Built with reliability in mind.