Agent skill · Backend & API

api-ai-mistral-sdk

Official Mistral AI TypeScript SDK patterns — client setup, chat completions, streaming, function calling, structured outputs, embeddings, vision, Codestral FIM, and production best practices

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill api-ai-mistral-sdk --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 21 KB
Bundled scripts: none
Path: skills/ai-llm/api-ai-mistral-sdk/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

Review
written from the skill's own SKILL.md · Aug 5, 2026

What it does

Guides developers on using the Mistral SDK in TypeScript, detailing how to initialize the client, perform chat completions and streaming, parse structured outputs with Zod, handle function calling with a tool loop, create embeddings, process vision tasks with Pixtral, and use Codestral FIM. It presents concrete method names and patterns to implement production-ready interactions with Mistral models.

How it works

  • Client initialization examples show reading the API key from an environment variable and optional production configuration with timeout and retryConfig.
  • Chat completions use chat.complete() with a model like mistral-large-latest and a messages array; streaming uses chat.stream() with an async iteration pattern and accesses event.data.choices[0]?.delta?.content for content.
  • Structured outputs employ chat.parse() with a Zod schema passed via responseFormat and access result.choices?.[0]?.message?.parsed for typed results.
  • Function calling demonstrates defining tools, using toolChoice, and inspecting toolCalls to extract function arguments.
  • Embeddings are created with embeddings.create using inputs plural, and the resulting embeddings are read from result.data.
  • Vision patterns show sending image references via imageUrl within messages.
  • Codestral FIM uses fim.complete() with prompt and suffix to produce a completion.
  • Error handling and production patterns emphasize explicit retry configuration, timeout usage, and specific error types.

When to use it

  • Building applications that call Mistral models directly
  • Implementing chat completions with SSE streaming
  • Using Codestral for code generation and FIM
  • Extracting structured data with client.chat.parse() and Zod schemas
  • Implementing function calling / tool use
  • Creating embeddings for RAG pipelines or semantic search
  • Processing images with Pixtral / vision-capable models
  • Using Mistral Agents API for pre-configured agent completions

What it can touch

  • @mistralai/mistralai SDK usage including client.chat.complete, client.chat.stream, client.chat.parse, client.fim.complete, and client.embeddings.create.
  • Environment variable MISTRAL_API_KEY for authentication.
  • Zod schemas passed to responseFormat for structured outputs.
  • Tool definitions and toolCalls handling in the tool call loop.

Caveats

  • The SDK defaults to strategy: "none" for retries; retries must be configured explicitly for production.
  • Streaming results must be consumed with for await (const event of result) and access content via event.data.choices[0]?.delta?.content.
  • Do not use snake_case properties; the patterns require camelCase (e.g., responseFormat, maxTokens).
  • Keys must be read from process.env["MISTRAL_API_KEY"] using bracket notation.
From the SKILL.md

# Mistral SDK Patterns > **Quick Guide:** Use `@mistralai/mistralai` (ESM-only) to interact with Mistral's API. Use `client.chat.complete()` for chat, `client.chat.stream()` for streaming (async iterable via `for await`), `client.chat.parse()` with a Zod schema for structured outputs, and `client.fim.complete()` for Codestral fill-in-middle code completion. The SDK uses `responseFormat` (camelCase) not `response_format`. Streaming events expose content via `event.data.choices[0]?.delta?.content`. Retries default to `strategy: "none"` -- you must configure them explicitly for production. --- <critical_requirements> ## CRITICAL: Before Using This Skill > **All code must follow project conventions in CLAUDE.md** (kebab-case, named exports, import ordering, `import type`, named constants) **(You MUST use `responseFormat` (camelCase) in SDK calls -- NOT `response_format` (snake_case). The SDK uses camelCase property names throughout.)** **(You MUST configure retries explicitly -- the SDK defaults to `strategy: "none"` (no retries), unlike OpenAI's SDK which retries automatically)** **(You MUST consume streaming results with `for await (const event of result)` and access content via `eve

What's inside
Steps it walks through
  1. CRITICAL: Before Using This Skill
  2. Examples Index
  3. Philosophy
  4. Core Patterns
  5. Pattern 1: Client Setup
  6. Pattern 2: Chat Completions
  7. Pattern 3: Streaming
  8. Pattern 4: Structured Outputs with Zod
  9. Pattern 5: Function Calling / Tool Use
  10. Pattern 6: Embeddings
  11. Pattern 7: Vision (Pixtral)
  12. Pattern 8: Codestral FIM
  13. Pattern 9: Error Handling
  14. Performance Optimization
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the api-ai-mistral-sdk skill do?

Official Mistral AI TypeScript SDK patterns — client setup, chat completions, streaming, function calling, structured outputs, embeddings, vision, Codestral FIM, and production best practices

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill api-ai-mistral-sdk --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going