원클릭으로
mistral
Setup Mistral AI integration for a project. Use for EU-friendly, fast, cost-effective LLM access with PDF/document analysis.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Setup Mistral AI integration for a project. Use for EU-friendly, fast, cost-effective LLM access with PDF/document analysis.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Cross-project audit and sync. Backs up, bootstraps, promotes, syncs, and verifies all downstream projects.
Structured pre-planning research. Explores codebase, asks clarifying questions, and produces a brainstorm output file for /plan-feature input.
Capture knowledge from development sessions. Debug patterns, architecture decisions, framework gotchas, and integration learnings compound over time.
Load project context and show current status. Use at the start of a session or when context is needed.
Run parallel code reviews using specialized agents (security, performance, simplicity, nextjs-react). Produces a structured report.
Initialize a new project from Agent Kit boilerplate. Use when creating a new downstream project.
| name | mistral |
| description | Setup Mistral AI integration for a project. Use for EU-friendly, fast, cost-effective LLM access with PDF/document analysis. |
| disable-model-invocation | true |
| allowed-tools | Read, Write, Edit, Bash, AskUserQuestion |
| argument-hint | ["setup|pdf"] |
Setup Mistral AI für schnelle, GDPR-freundliche LLM-Nutzung mit PDF-Analyse.
| Vorteil | Details |
|---|---|
| EU-Unternehmen | Paris-basiert, GDPR-freundlich |
| Schnell | Niedrige Latenz, hoher Throughput |
| Günstig | Gutes Preis-Leistungs-Verhältnis |
| PDF-Analyse | Pixtral-Modelle für Vision/Dokumente |
setup - Vollständige Mistral-Integration einrichtenpdf - Nur PDF-Analyse Setup (schnell)1. Gehe zu: https://console.mistral.ai/
2. Erstelle Account oder Login
3. API Keys → Create new key
4. Key sicher speichern
Füge zu .env.local hinzu:
# Mistral AI
MISTRAL_API_KEY=your-mistral-api-key
cd mastra
pnpm add @ai-sdk/mistral
cd frontend
pnpm add @ai-sdk/mistral
Erstelle frontend/lib/ai/mistral.ts:
/**
* Mistral AI Provider Configuration
* EU-based LLM provider for GDPR-friendly AI applications
*/
import { createMistral } from "@ai-sdk/mistral";
// Initialize Mistral provider
export const mistral = createMistral({
apiKey: process.env.MISTRAL_API_KEY,
});
// Available models
export const mistralModels = {
// Text models
large: mistral("mistral-large-latest"), // Best quality
medium: mistral("mistral-medium-latest"), // Balanced
small: mistral("mistral-small-latest"), // Fast & cheap
// Vision/Document models (PDF analysis)
pixtralLarge: mistral("pixtral-large-latest"), // Best for documents
pixtral: mistral("pixtral-12b-2409"), // Fast vision
// Code model
codestral: mistral("codestral-latest"), // Code generation
} as const;
// Model selection helper
export type MistralModelKey = keyof typeof mistralModels;
export function getMistralModel(key: MistralModelKey = "large") {
return mistralModels[key];
}
Erstelle frontend/lib/ai/pdf-analyzer.ts:
/**
* PDF Analysis with Mistral Pixtral
* Analyzes PDF documents using vision capabilities
*/
import { generateText } from "ai";
import { mistralModels } from "./mistral";
interface PDFAnalysisResult {
summary: string;
keyPoints: string[];
rawResponse: string;
}
interface AnalyzePDFOptions {
prompt?: string;
model?: "pixtralLarge" | "pixtral";
}
/**
* Analyze a PDF document using Mistral Pixtral
*
* @param pdfBase64 - Base64 encoded PDF or image
* @param options - Analysis options
*/
export async function analyzePDF(
pdfBase64: string,
options: AnalyzePDFOptions = {}
): Promise<PDFAnalysisResult> {
const {
prompt = "Analysiere dieses Dokument. Fasse den Inhalt zusammen und extrahiere die wichtigsten Punkte.",
model = "pixtralLarge",
} = options;
const result = await generateText({
model: mistralModels[model],
messages: [
{
role: "user",
content: [
{
type: "text",
text: prompt,
},
{
type: "image",
image: pdfBase64,
},
],
},
],
});
// Parse response for structured output
const lines = result.text.split("\n").filter(Boolean);
return {
summary: result.text,
keyPoints: lines.slice(0, 5), // First 5 lines as key points
rawResponse: result.text,
};
}
/**
* Analyze multiple pages of a PDF
*/
export async function analyzeMultiPagePDF(
pages: string[], // Array of base64 encoded pages
prompt?: string
): Promise<PDFAnalysisResult[]> {
const results = await Promise.all(
pages.map((page) => analyzePDF(page, { prompt }))
);
return results;
}
Erstelle frontend/app/api/analyze-pdf/route.ts:
/**
* PDF Analysis API Route
* POST /api/analyze-pdf
*/
import { NextRequest, NextResponse } from "next/server";
import { analyzePDF } from "@/lib/ai/pdf-analyzer";
export async function POST(request: NextRequest) {
try {
const formData = await request.formData();
const file = formData.get("file") as File;
const prompt = formData.get("prompt") as string | null;
if (!file) {
return NextResponse.json(
{ error: "No file provided" },
{ status: 400 }
);
}
// Convert file to base64
const bytes = await file.arrayBuffer();
const buffer = Buffer.from(bytes);
const base64 = buffer.toString("base64");
const mimeType = file.type || "application/pdf";
const dataUrl = `data:${mimeType};base64,${base64}`;
// Analyze with Mistral Pixtral
const result = await analyzePDF(dataUrl, {
prompt: prompt || undefined,
});
return NextResponse.json(result);
} catch (error) {
console.error("[analyze-pdf] Error:", error);
return NextResponse.json(
{ error: "Failed to analyze PDF" },
{ status: 500 }
);
}
}
export const config = {
api: {
bodyParser: false,
},
};
Erstelle mastra/src/tools/mistral-pdf.ts:
/**
* Mistral PDF Analysis Tool for Mastra Agents
*/
import { createTool } from "@mastra/core";
import { z } from "zod";
export const analyzePDFTool = createTool({
id: "analyze-pdf",
description: "Analyze a PDF document using Mistral Pixtral vision model",
inputSchema: z.object({
documentUrl: z.string().describe("URL or base64 of the PDF/image"),
question: z.string().optional().describe("Specific question about the document"),
}),
outputSchema: z.object({
analysis: z.string(),
confidence: z.number(),
}),
execute: async ({ context }) => {
const { documentUrl, question } = context;
// Call Mistral Pixtral API
const response = await fetch("https://api.mistral.ai/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${process.env.MISTRAL_API_KEY}`,
},
body: JSON.stringify({
model: "pixtral-large-latest",
messages: [
{
role: "user",
content: [
{
type: "text",
text: question || "Analysiere dieses Dokument detailliert.",
},
{
type: "image_url",
image_url: { url: documentUrl },
},
],
},
],
}),
});
const data = await response.json();
return {
analysis: data.choices[0]?.message?.content || "No analysis available",
confidence: 0.9,
};
},
});
import { generateText } from "ai";
import { getMistralModel } from "@/lib/ai/mistral";
const result = await generateText({
model: getMistralModel("large"),
prompt: "Erkläre mir die DSGVO in einfachen Worten.",
});
console.log(result.text);
import { analyzePDF } from "@/lib/ai/pdf-analyzer";
// From file input
const file = event.target.files[0];
const reader = new FileReader();
reader.onload = async (e) => {
const base64 = e.target.result as string;
const analysis = await analyzePDF(base64, {
prompt: "Was sind die Hauptpunkte dieses Vertrags?",
});
console.log(analysis.summary);
};
reader.readAsDataURL(file);
import { streamText } from "ai";
import { getMistralModel } from "@/lib/ai/mistral";
const result = await streamText({
model: getMistralModel("medium"),
messages: [
{ role: "user", content: "Schreibe eine Produktbeschreibung für..." },
],
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}
| Model | Use Case | Preis | Speed |
|---|---|---|---|
mistral-large-latest | Complex tasks, reasoning | $$$ | Medium |
mistral-medium-latest | Balanced quality/speed | $$ | Fast |
mistral-small-latest | Simple tasks, high volume | $ | Very Fast |
pixtral-large-latest | PDF/Document analysis | $$$ | Medium |
pixtral-12b-2409 | Fast vision tasks | $$ | Fast |
codestral-latest | Code generation | $$ | Fast |
Nach Abschluss:
MISTRAL_API_KEY in .env.local@ai-sdk/mistral installiertlib/ai/mistral.ts)| Problem | Lösung |
|---|---|
| "Invalid API key" | Key in .env.local prüfen, Server neu starten |
| "Model not found" | Model-Namen auf aktuelle Version prüfen |
| PDF-Analyse fehlerhaft | Pixtral-Large für bessere Qualität nutzen |
| Rate Limit | Mistral hat großzügige Limits, aber bei Bedarf throttling einbauen |