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".
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".
allowed-tools
Read, Write, Edit, Bash(curl:*)
version
1.12.0
license
MIT
author
Jeremy Longshore <jeremy@intentsolutions.io>
tags
["saas","mistral","webhooks","workflow"]
compatibility
Designed for Claude Code, also compatible with Codex and OpenClaw
Mistral AI Events, Agents & Async Patterns
Overview
Async and event-driven patterns for Mistral AI: the Agents API for stateful multi-turn workflows, Batch API for cost-effective bulk inference (50% cheaper), SSE streaming endpoints, background job queues, and Python async processing. Mistral does not have native webhooks — this skill covers the patterns that replace them.
Prerequisites
@mistralai/mistralai SDK installed
MISTRAL_API_KEY configured
For agents: La Plateforme access to create agents
For batch: JSONL file preparation
Instructions
Step 1: Mistral Agents API
Create stateful agents with instructions, tools, and model configuration:
import { Mistral } from'@mistralai/mistralai';
const client = newMistral({ apiKey: process.env.MISTRAL_API_KEY });
// Create an agent on La Plateformeconst agent = await client.agents.create({
name: 'Code Reviewer',
model: 'mistral-large-latest',
instructions: `You are an expert code reviewer. Analyze code for:
- Security vulnerabilities
- Performance issues
- Best practice violations
Provide actionable feedback with severity ratings.`,
description: 'Reviews code for security, performance, and best practices',
tools: [
{
type: 'function',
function: {
name: 'search_codebase',
description: 'Search the codebase for patterns',
parameters: {
: ,
: { : { : } },
: [],
},
},
},
],
});
response = client..({
: agent.,
: [
{ : , : },
],
});
.(response.?.[]?.?.);
type
'object'
properties
query
type
'string'
required
'query'
// Chat with the agent (stateful conversation)
const
await
agents
complete
agentId
id
messages
role
'user'
content
'Review this function:\n```\nfunction auth(pwd) { return pwd === "admin123"; }\n```'
console
log
choices
0
message
content
Step 2: Batch API for Bulk Inference
50% cost reduction for non-time-sensitive workloads: