---
name: mistral-deploy-integration-c67a9171b835
description: |
  Deploy Mistral AI integrations to Vercel, Fly.io, and Cloud Run platforms.
  Use when deploying Mistral AI-powered applications to production,
  configuring platform-specific secrets, or setting up deployment pipelines.
  Trigger with phrases like "deploy mistral", "mistral Vercel",
  "mistral production deploy", "mistral Cloud Run", "mistral Fly.io".
allowed-tools: Read, Write, Edit, Bash(vercel:*), Bash(fly:*), Bash(gcloud:*)
version: 1.0.0
license: MIT
author: Jeremy Longshore <jeremy@intentsolutions.io>
---

# Mistral AI Deploy Integration

## Overview
Deploy Mistral AI-powered applications to popular platforms with proper secrets management.

## Prerequisites
- Mistral AI API keys for production environment
- Platform CLI installed (vercel, fly, or gcloud)
- Application code ready for deployment
- Environment variables documented

## Vercel Deployment

### Environment Setup

```bash
# Add Mistral secrets to Vercel
vercel env add MISTRAL_API_KEY production
# Enter your API key when prompted

# Or use CLI with secret
vercel secrets add mistral-api-key "your-api-key"

# Link to project
vercel link

# Deploy preview
vercel

# Deploy production
vercel --prod
```

### vercel.json Configuration

```json
{
  "env": {
    "MISTRAL_API_KEY": "@mistral-api-key"
  },
  "functions": {
    "api/**/*.ts": {
      "maxDuration": 60
    }
  },
  "regions": ["iad1", "sfo1"]
}
```

### Vercel Edge Function Example

```typescript
// api/chat/route.ts (Next.js App Router)
import { NextRequest } from 'next/server';
import Mistral from '@mistralai/mistralai';

const client = new Mistral({
  apiKey: process.env.MISTRAL_API_KEY!,
});

export async function POST(request: NextRequest) {
  const { messages } = await request.json();

  const stream = await client.chat.stream({
    model: 'mistral-small-latest',
    messages,
  });

  const encoder = new TextEncoder();
  const readable = new ReadableStream({
    async start(controller) {
      for await (const event of stream) {
        const content = event.data?.choices?.[0]?.delta?.content;
        if (content) {
          controller.enqueue(encoder.encode(`data: ${JSON.stringify({ content })}\n\n`));
        }
      }
      controller.enqueue(encoder.encode('data: [DONE]\n\n'));
      controller.close();
    },
  });

  return new Response(readable, {
    headers: {
      'Content-Type': 'text/event-stream',
      'Cache-Control': 'no-cache',
      'Connection': 'keep-alive',
    },
  });
}
```

## Fly.io Deployment

### fly.toml Configuration

```toml
app = "my-mistral-app"
primary_region = "iad"

[env]
  NODE_ENV = "production"
  LOG_LEVEL = "info"

[http_service]
  internal_port = 3000
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true
  min_machines_running = 1

[http_service.concurrency]
  type = "connections"
  hard_limit = 100
  soft_limit = 80

[[services.http_checks]]
  interval = 10000
  timeout = 2000
  path = "/health"
```

### Deploy to Fly.io

```bash
# Set Mistral secrets
fly secrets set MISTRAL_API_KEY="your-api-key"

# Deploy
fly deploy

# View logs
fly logs

# Scale
fly scale count 2 --region iad
```

## Google Cloud Run

### Dockerfile

```dockerfile
FROM node:20-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build

FROM node:20-slim
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./

ENV NODE_ENV=production
EXPOSE 8080
CMD ["node", "dist/index.js"]
```

### Deploy Script

```bash
#!/bin/bash
# deploy-cloud-run.sh

PROJECT_ID="${GOOGLE_CLOUD_PROJECT}"
SERVICE_NAME="mistral-service"
REGION="us-central1"

# Create secret in Secret Manager
echo -n "your-api-key" | gcloud secrets create mistral-api-key --data-file=-

# Grant Cloud Run access to secret
gcloud secrets add-iam-policy-binding mistral-api-key \
  --member="serviceAccount:${PROJECT_ID}-compute@developer.gserviceaccount.com" \
  --role="roles/secretmanager.secretAccessor"

# Build and push image
gcloud builds submit --tag gcr.io/$PROJECT_ID/$SERVICE_NAME

# Deploy to Cloud Run
gcloud run deploy $SERVICE_NAME \
  --image gcr.io/$PROJECT_ID/$SERVICE_NAME \
  --region $REGION \
  --platform managed \
  --allow-unauthenticated \
  --set-secrets="MISTRAL_API_KEY=mistral-api-key:latest" \
  --memory 512Mi \
  --cpu 1 \
  --timeout 60s \
  --concurrency 80
```

## Environment Configuration Pattern

```typescript
// config/mistral.ts
interface MistralConfig {
  apiKey: string;
  model: string;
  timeout: number;
  maxRetries: number;
}

export function getMistralConfig(): MistralConfig {
  const env = process.env.NODE_ENV || 'development';

  return {
    apiKey: process.env.MISTRAL_API_KEY!,
    model: process.env.MISTRAL_MODEL || 'mistral-small-latest',
    timeout: parseInt(process.env.MISTRAL_TIMEOUT || '30000'),
    maxRetries: parseInt(process.env.MISTRAL_MAX_RETRIES || '3'),
  };
}
```

## Health Check Endpoint

```typescript
// api/health.ts
import Mistral from '@mistralai/mistralai';

export async function GET() {
  const start = Date.now();

  try {
    const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY! });
    await client.models.list();

    return Response.json({
      status: 'healthy',
      services: {
        mistral: {
          connected: true,
          latencyMs: Date.now() - start,
        },
      },
      timestamp: new Date().toISOString(),
    });
  } catch (error) {
    return Response.json({
      status: 'degraded',
      services: {
        mistral: {
          connected: false,
          latencyMs: Date.now() - start,
          error: 'Connection failed',
        },
      },
      timestamp: new Date().toISOString(),
    }, { status: 503 });
  }
}
```

## Instructions

### Step 1: Choose Deployment Platform
Select the platform that best fits your infrastructure needs.

### Step 2: Configure Secrets
Store Mistral API keys securely using the platform's secrets management.

### Step 3: Deploy Application
Use the platform CLI to deploy your application.

### Step 4: Verify Health
Test the health check endpoint to confirm Mistral connectivity.

## Output
- Application deployed to production
- Mistral secrets securely configured
- Health check endpoint functional
- Environment-specific configuration in place

## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Secret not found | Missing configuration | Add secret via platform CLI |
| Deploy timeout | Large build | Increase build timeout |
| Health check fails | Wrong API key | Verify environment variable |
| Cold start slow | No warm-up | Configure minimum instances |

## Examples

### Quick Deploy Script

```bash
#!/bin/bash
# Platform-agnostic deploy helper
case "$1" in
  vercel)
    vercel env add MISTRAL_API_KEY production <<< "$MISTRAL_API_KEY"
    vercel --prod
    ;;
  fly)
    fly secrets set MISTRAL_API_KEY="$MISTRAL_API_KEY"
    fly deploy
    ;;
  cloudrun)
    gcloud run deploy mistral-app \
      --set-env-vars="MISTRAL_API_KEY=$MISTRAL_API_KEY"
    ;;
  *)
    echo "Usage: $0 {vercel|fly|cloudrun}"
    ;;
esac
```

## Resources
- [Vercel Documentation](https://vercel.com/docs)
- [Fly.io Documentation](https://fly.io/docs)
- [Cloud Run Documentation](https://cloud.google.com/run/docs)
- [Mistral AI API Reference](https://docs.mistral.ai/api/)

## Next Steps
For event handling, see `mistral-webhooks-events`.


---
Source attribution: Dicklesworthstone
Original project: https://github.com/Dicklesworthstone/pi_agent_rust/blob/f28fc46ee0db8e710d95b8b55592cd38d60f2b26/tests/ext_conformance/artifacts/plugins-community/plugins/saas-packs/mistral-pack/skills/mistral-deploy-integration/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License (with OpenAI/Anthropic Rider)

Copyright (c) 2026 Jeffrey Emanuel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

ADDITIONAL RIDER / RESTRICTION (OpenAI / Anthropic):

This rider is part of the "conditions" of this License. In the event of any
conflict between this rider and any other portion of this License, this rider
controls.

"Restricted Parties" means OpenAI, L.L.C.; Anthropic, PBC; any of their
respective Affiliates; and any person or entity acting directly or indirectly
on behalf of, for the benefit of, or under the direction of any of the
foregoing (including any officer, director, employee, contractor, agent,
consultant, service provider, or representative).

Notwithstanding any other provision of this License, no rights are granted to
any Restricted Party. Any purported license, sublicense, assignment, transfer,
or other permission to any Restricted Party is null and void absent the
express prior written permission of Jeffrey Emanuel.

You may not provide, disclose, distribute, sublicense, sell, lease, lend,
host, make available, or otherwise permit access to the Software or any
derivative work of the Software (as defined in applicable copyright law)
(collectively, "Derivative Works") to or for any Restricted Party.

For purposes of this rider, "use" includes, without limitation: copying,
modifying, merging, publishing, distributing, sublicensing, selling,
transferring, making available, hosting, deploying, executing, benchmarking,
testing, analyzing, indexing, or incorporating the Software or any Derivative
Works into any dataset, training corpus, evaluation harness, or pipeline for
machine learning or other automated systems.

This rider applies to the Software and all Derivative Works. As a condition of
use, you agree that this rider is a precondition to exercising any rights
under this License, and you agree that any distribution of the Software or any
Derivative Works must include this rider provision unmodified.

Any breach of this rider automatically and immediately terminates the
permissions granted by this License. Upon termination, you must immediately
cease all use and distribution of the Software and any Derivative Works and
destroy all copies under your control.

You agree that a breach of this rider would cause irreparable harm and that
Jeffrey Emanuel may seek injunctive or other equitable relief to enforce this
rider, in addition to any other remedies available at law. To the maximum
extent permitted by applicable law, the prevailing party in any action to
enforce this rider shall be entitled to recover reasonable attorneys' fees and
costs.

For purposes of this rider, "Affiliate" means any entity that directly or
indirectly controls, is controlled by, or is under common control with the
specified party. "Control" means ownership of more than 50% of the voting
securities or other ownership interest, or the power to direct management or
policies by contract or otherwise.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: Dicklesworthstone
Original project: https://github.com/Dicklesworthstone/pi_agent_rust/blob/f28fc46ee0db8e710d95b8b55592cd38d60f2b26/tests/ext_conformance/artifacts/plugins-community/plugins/saas-packs/mistral-pack/skills/mistral-deploy-integration/SKILL.md
Attribution basis: Source repository record

Fields of work: Development & Engineering, Product Management
Roles: Backend Developer, DevOps / SRE, Growth Product Manager, ML / AI Engineer, Product Manager
Specialties: API, Backend
Tools: Vercel
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 74f657984bdc9ff64fce7d1957274df43170d2fe5c33e757f221543bf89f6941
