| name | mistral-hello-world |
| description | 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".
|
| allowed-tools | Read, Write, Edit |
| version | 1.12.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","mistral","api","testing"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Mistral AI Hello World
Overview
Minimal working examples demonstrating Mistral AI chat completions, streaming, multi-turn conversation, and JSON mode. Uses the official @mistralai/mistralai TypeScript SDK and mistralai Python SDK.
Prerequisites
- Completed
mistral-install-auth setup
- Valid
MISTRAL_API_KEY environment variable set
- Node.js 18+ or Python 3.9+
Instructions
Step 1: Basic Chat Completion
TypeScript (hello-mistral.ts)
import { Mistral } from '@mistralai/mistralai';
const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
async function main() {
const response = await client.chat.complete({
model: 'mistral-small-latest',
messages: [
{ role: 'user', content: 'Say "Hello, World!" in a creative way.' },
],
});
console.log(response.choices?.[0]?.message?.content);
console.log('Tokens used:', response.usage);
}
main().catch(console.);