mistral-multi-env-setup
Configure Mistral AI across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific Mistral AI configurations. Trigger with phrases like "mistral environments", "mistral staging", "mistral dev prod", "mistral environment setup", "mistral config by env".
- License 许可
- MIT
- 最近更新
- 2026-03-20
- Stars
- ★ 4
- Forks
- 0
01 前言 Front Matter
- name
- mistral-multi-env-setup
- author
- Jeremy Longshore <jeremy@intentsolutions.io>
- license
- MIT
- version
- 1.0.0
- description
- Configure Mistral AI across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific Mistral AI configurations. Trigger with phrases like "mistral environments", "mistral staging", "mistral dev prod", "mistral environment setup", "mistral config by env".
- allowed-tools
- Read, Write, Edit, Bash(aws:*), Bash(gcloud:*), Bash(vault:*)
- compatible-with
- claude-code, codex, openclaw
03 SKILL.md 正文
Mistral AI Multi-Environment Setup
Overview
Configure Mistral AI across development, staging, and production environments.
Prerequisites
- Separate Mistral AI API keys per environment
- Secret management solution (Vault, AWS Secrets Manager, GCP Secret Manager)
- CI/CD pipeline with environment variables
- Environment detection in application
Environment Strategy
| Environment | Purpose | API Keys | Model Selection |
|---|---|---|---|
| Development | Local dev | Test keys | mistral-small-latest |
| Staging | Pre-prod testing | Staging keys | Same as prod |
| Production | Live traffic | Production keys | Optimized selection |
Instructions
Step 1: Configuration Structure
config/
├── mistral/
│ ├── base.ts # Shared configuration
│ ├── development.ts # Dev overrides
│ ├── staging.ts # Staging overrides
│ └── production.ts # Prod overrides
Step 2: Base Configuration
// config/mistral/base.ts
export const baseConfig = {
defaultModel: 'mistral-small-latest',
timeout: 30000, # 30000: 30 seconds in ms
maxRetries: 3,
cache: {
enabled: true,
ttlSeconds: 300, # 300: timeout: 5 minutes
},
rateLimits: {
requestsPerMinute: 60,
tokensPerMinute: 500000, # 500000 = configured value
},
};
Step 3: Environment-Specific Configs
// config/mistral/development.ts
import { baseConfig } from './base';
export const developmentConfig = {
...baseConfig,
apiKey: process.env.MISTRAL_API_KEY_DEV,
debug: true,
cache: {
enabled: false, // Disable cache in dev for testing
ttlSeconds: 60,
},
rateLimits: {
requestsPerMinute: 10,
tokensPerMinute: 100000, # 100000 = configured value
},
};
// config/mistral/staging.ts
import { baseConfig } from './base';
export const stagingConfig = {
...baseConfig,
apiKey: process.env.MISTRAL_API_KEY_STAGING,
debug: false,
cache: {
enabled: true,
ttlSeconds: 300, # 300: timeout: 5 minutes
},
};
// config/mistral/production.ts
import { baseConfig } from './base';
export const productionConfig = {
...baseConfig,
apiKey: process.env.MISTRAL_API_KEY_PROD,
debug: false,
timeout: 60000, # 60000: 1 minute in ms
maxRetries: 5,
cache: {
enabled: true,
ttlSeconds: 600, # 600: timeout: 10 minutes
},
};
Step 4: Environment Detection
// config/mistral/index.ts
import { developmentConfig } from './development';
import { stagingConfig } from './staging';
import { productionConfig } from './production';
type Environment = 'development' | 'staging' | 'production';
const configs = {
development: developmentConfig,
staging: stagingConfig,
production: productionConfig,
};
export function detectEnvironment(): Environment {
const env = process.env.NODE_ENV || 'development';
if (env === 'production') return 'production';
if (env === 'staging' || process.env.VERCEL_ENV === 'preview') return 'staging';
return 'development';
}
export function getMistralConfig() {
const env = detectEnvironment();
const config = configs[env];
if (!config.apiKey) {
throw new Error(`MISTRAL_API_KEY not set for environment: ${env}`);
}
return {
...config,
environment: env,
};
}
Step 5: Secret Management
Local Development (.env.local)
# .env.local (git-ignored)
MISTRAL_API_KEY_DEV=your-dev-api-key
GitHub Actions (secrets)
# .github/workflows/deploy.yml
jobs:
deploy-staging:
environment: staging
env:
MISTRAL_API_KEY_STAGING: ${{ secrets.MISTRAL_API_KEY_STAGING }}
deploy-production:
environment: production
env:
MISTRAL_API_KEY_PROD: ${{ secrets.MISTRAL_API_KEY_PROD }}
AWS Secrets Manager
# Store secrets
aws secretsmanager create-secret \
--name mistral/production/api-key \
--secret-string "your-api-key"
# Retrieve in code
aws secretsmanager get-secret-value \
--secret-id mistral/production/api-key
import { SecretsManager } from '@aws-sdk/client-secrets-manager';
const sm = new SecretsManager({ region: 'us-east-1' });
async function getMistralApiKey(env: string): Promise<string> {
const { SecretString } = await sm.getSecretValue({
SecretId: `mistral/${env}/api-key`,
});
return SecretString!;
}
GCP Secret Manager
# Store secret
echo -n "your-api-key" | gcloud secrets create mistral-api-key-prod --data-file=-
# Grant access
gcloud secrets add-iam-policy-binding mistral-api-key-prod \
--member="serviceAccount:your-sa@project.iam.gserviceaccount.com" \
--role="roles/secretmanager.secretAccessor"
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
const client = new SecretManagerServiceClient();
async function getMistralApiKey(env: string): Promise<string> {
const [version] = await client.accessSecretVersion({
name: `projects/my-project/secrets/mistral-api-key-${env}/versions/latest`,
});
return version.payload?.data?.toString()!;
}
Step 6: Environment Isolation
// Prevent accidental cross-environment operations
function validateEnvironment(operation: string, requiredEnv: Environment): void {
const currentEnv = detectEnvironment();
if (currentEnv !== requiredEnv) {
throw new Error(
`Operation "${operation}" requires ${requiredEnv} but running in ${currentEnv}`
);
}
}
// Protect production-only operations
function requireProduction(operation: string): void {
validateEnvironment(operation, 'production');
}
// Usage
async function deployModel() {
requireProduction('deployModel');
// Production-only code
}
Step 7: Feature Flags by Environment
interface FeatureFlags {
useNewModel: boolean;
enableFunctionCalling: boolean;
maxConcurrentRequests: number;
}
const featureFlags: Record<Environment, FeatureFlags> = {
development: {
useNewModel: true,
enableFunctionCalling: true,
maxConcurrentRequests: 2,
},
staging: {
useNewModel: true,
enableFunctionCalling: true,
maxConcurrentRequests: 5,
},
production: {
useNewModel: false, // Gradual rollout
enableFunctionCalling: true,
maxConcurrentRequests: 10,
},
};
export function getFeatureFlags(): FeatureFlags {
const env = detectEnvironment();
return featureFlags[env];
}
Output
- Multi-environment config structure
- Environment detection logic
- Secure secret management
- Production safeguards enabled
Error Handling
| Issue | Cause | Solution |
|---|---|---|
| Wrong environment | Missing NODE_ENV | Set environment variable |
| Secret not found | Wrong secret path | Verify secret manager config |
| Config validation | Invalid settings | Use Zod schema validation |
| Cross-env leak | Missing guards | Add environment checks |
Examples
Quick Environment Check
const config = getMistralConfig();
console.log(`Running in ${config.environment}`);
console.log(`Model: ${config.defaultModel}`);
console.log(`Cache enabled: ${config.cache.enabled}`);
Vercel Environment Detection
function getVercelEnvironment(): Environment {
const vercelEnv = process.env.VERCEL_ENV;
if (vercelEnv === 'production') return 'production';
if (vercelEnv === 'preview') return 'staging';
return 'development';
}
Resources
Next Steps
For observability setup, see mistral-observability.
04 同仓库更多 Skills
azure-apim-architecture
Analyzes and explains Azure API Management architecture decisions for enterprise API marketplace implementations using VNet Internal mode, Front Door, hybrid authentication, and multi-environment strategies. Use when discussing APIM component selection, network topology, cost optimization, or comparing alternatives like workspaces vs instances, VNet Internal vs External mode, or Front Door vs Application Gateway.
apiops-deployment
Guides deployment of Azure API Management infrastructure using Infrastructure as Code (Bicep/Terraform), CI/CD pipelines (GitHub Actions/Azure DevOps), and APIOps workflows. Use when deploying APIM, creating pipelines, or implementing dev→test→prod promotion strategies.
apim-policy-authoring
Creates production-ready Azure API Management policy XML for authentication (OAuth 2.0, JWT validation, subscription keys), rate limiting, CORS configuration, error handling, and API transformations. Use when implementing API security, access control, or request/response processing logic.
api-security-review
Reviews Azure API Management configurations for security vulnerabilities, OWASP API Security Top 10 compliance, VNet Internal mode validation, Private Link verification, and Azure Security Benchmark alignment. Use when performing security audits, pre-deployment validation, or compliance reviews.
jira-cli
Interact with Jira from the command line to create, list, view, edit, and transition issues, manage sprints and epics, and perform common Jira workflows. Use when the user asks about Jira tasks, tickets, issues, sprints, or needs to manage project work items.
calculator
Performs arbitrary-precision arithmetic calculations including addition, subtraction, multiplication, division, and exponents. Use when the user asks to calculate, compute, or evaluate math expressions, or when precise decimal arithmetic is needed to avoid floating-point errors.