/** * ============================================================================= * MISTRAL PAGE - SDK Examples Dashboard * ============================================================================= * * Showcases all Mistral SDK integration patterns with real-world examples. * * INTERVIEW NOTES: * - Demonstrates familiarity with Mistral's API capabilities * - Shows proper React patterns for AI integrations * - Includes streaming, function calling, and code generation */ import ChatExample from '@/components/examples/ChatExample'; import StreamingExample from '@/components/examples/StreamingExample'; import ConversationExample from '@/components/examples/ConversationExample'; import CodeExample from '@/components/examples/CodeExample'; import FunctionCallingExample from '@/components/examples/FunctionCallingExample'; const MISTRAL_FEATURES = [ { name: 'Chat Completion', description: 'Single-turn request/response pattern', model: 'mistral-small-latest', }, { name: 'Streaming', description: 'Real-time token-by-token generation', model: 'mistral-small-latest', }, { name: 'Conversations', description: 'Multi-turn with maintained context', model: 'mistral-small-latest', }, { name: 'Code Generation', description: 'Specialized coding model', model: 'codestral-latest', }, { name: 'Function Calling', description: 'Tool use and external integrations', model: 'mistral-large-latest', }, ]; export default function MistralPage() { return (
{/* Header */}

Mistral AI SDK Examples

Real-world integration patterns using the official @mistralai/mistralai SDK.

{/* Feature overview */}

Available Features

{MISTRAL_FEATURES.map((feature) => (

{feature.name}

{feature.description}

{feature.model}
))}
{/* API Key notice */}

Configuration Required

Set your MISTRAL_API_KEY in the server environment to enable these examples. Get your API key from{' '} console.mistral.ai

{/* Examples grid */}
{/* Basic Chat */} {/* Streaming */} {/* Conversation */} {/* Code Generation */}
{/* Function Calling - Full width */} {/* SDK Reference */}

SDK Quick Reference

Installation

              npm install @mistralai/mistralai
            

Basic Usage

{`import { Mistral } from '@mistralai/mistralai';

const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });

// Chat completion
const response = await client.chat.complete({
  model: 'mistral-small-latest',
  messages: [
    { role: 'system', content: 'You are helpful.' },
    { role: 'user', content: 'Hello!' }
  ]
});

// Streaming
const stream = await client.chat.stream({
  model: 'mistral-small-latest',
  messages: [{ role: 'user', content: 'Tell me a story' }]
});

for await (const chunk of stream) {
  process.stdout.write(chunk.data.choices[0].delta.content || '');
}`}
            

Available Models

{[ 'open-mistral-7b', 'mistral-small-latest', 'mistral-large-latest', 'codestral-latest', 'mistral-embed', ].map((model) => ( {model} ))}
); }