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,926 stars 433 forks Updated yesterday 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
1 years ago
Last Updated
yesterday
Language
Python
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category