mistral-sdk-patterns

Featured

Apply production-ready Mistral AI SDK patterns for TypeScript and Python. Use when implementing Mistral integrations, refactoring SDK usage, or establishing team coding standards for Mistral AI. Trigger with phrases like "mistral SDK patterns", "mistral best practices", "mistral code patterns", "idiomatic mistral".

AI & Automation 2,266 stars 315 forks Updated today MIT

Install

View on GitHub

Quality Score: 99/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Mistral SDK Patterns ## Overview Production-ready patterns for the Mistral AI SDK. Covers singleton client, retry/backoff, structured output, streaming, function calling, batch embeddings, and async Python — all with proper error handling. SDK is ESM-only for TypeScript (`@mistralai/mistralai`), sync+async for Python (`mistralai`). ## Prerequisites - `@mistralai/mistralai` (TypeScript) or `mistralai` (Python) installed - `MISTRAL_API_KEY` environment variable set ## Instructions ### Step 1: Singleton Client with Configuration **TypeScript** ```typescript import { Mistral } from '@mistralai/mistralai'; let _client: Mistral | null = null; export function getMistralClient(): Mistral { if (!_client) { const apiKey = process.env.MISTRAL_API_KEY; if (!apiKey) throw new Error('MISTRAL_API_KEY not set'); _client = new Mistral({ apiKey, timeoutMs: 30_000, maxRetries: 3, }); } return _client; } // Reset for testing export function resetClient(): void { _client = null; } ``` **Python** ```python import os from mistralai import Mistral _client = None def get_client() -> Mistral: global _client if _client is None: api_key = os.environ.get("MISTRAL_API_KEY") if not api_key: raise RuntimeError("MISTRAL_API_KEY not set") _client = Mistral(api_key=api_key, timeout_ms=30_000, max_retries=3) return _client ``` ### Step 2: Structured Output with JSON Schema ```typescript import { z } from 'z...

Details

Author
jeremylongshore
Repository
jeremylongshore/claude-code-plugins-plus-skills
Created
7 months ago
Last Updated
today
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Featured

mistral-reference-architecture

Implement Mistral AI reference architecture with best-practice project layout. Use when designing new Mistral AI integrations, reviewing project structure, or establishing architecture standards for Mistral AI applications. Trigger with phrases like "mistral architecture", "mistral best practices", "mistral project structure", "how to organize mistral".

2,266 Updated today
jeremylongshore
AI & Automation Featured

mistral-webhooks-events

Implement Mistral AI async patterns, batch API, agents, and event-driven workflows. Use when building async workflows, using the Agents API, batch inference, or handling long-running Mistral AI operations. Trigger with phrases like "mistral events", "mistral async", "mistral agents", "mistral batch", "mistral queue", "mistral background jobs".

2,266 Updated today
jeremylongshore
AI & Automation Featured

mistral-hello-world

Create a minimal working Mistral AI chat completion example. Use when starting a new Mistral integration, testing your setup, or learning basic Mistral API patterns. Trigger with phrases like "mistral hello world", "mistral example", "mistral quick start", "simple mistral code", "mistral chat".

2,266 Updated today
jeremylongshore
AI & Automation Featured

mistral-install-auth

Install and configure the Mistral AI SDK with authentication. Use when setting up a new Mistral integration, configuring API keys, or initializing Mistral AI in your project. Trigger with phrases like "install mistral", "setup mistral", "mistral auth", "configure mistral API key".

2,266 Updated today
jeremylongshore
AI & Automation Featured

mistral-common-errors

Diagnose and fix Mistral AI common errors and exceptions. Use when encountering Mistral errors, debugging failed requests, or troubleshooting integration issues. Trigger with phrases like "mistral error", "fix mistral", "mistral not working", "debug mistral".

2,266 Updated today
jeremylongshore