mistral-api
БесплатноБез исполняемых скриптовНе проверенMistral AI API gives access to Mistral's chat, code, embedding, OCR and speech models from a Paris-based provider, with an optional EU regional endpoint. Use…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Mistral AI API
Overview
Mistral AI is a French AI company whose API serves chat, reasoning, code (Codestral), embedding, OCR and speech models. The chat endpoint (/v1/chat/completions) follows OpenAI conventions. Requests go to api.mistral.ai by default; EU or US processing is available through paid regional endpoints (see Regional inference). The official SDKs are mistralai (2.x and 3.x; 3.3.0 is current) for Python and @mistralai/mistralai for TypeScript.
Setup
# Python 3.10+
pip install mistralai
# TypeScript/Node
npm install @mistralai/mistralai
export MISTRAL_API_KEY=...
Available Models
| Model (alias) | Context | Best for |
|---|---|---|
mistral-large-latest |
256k | Large 3, flagship general model (Large 4 is mistral-large-4, 1M context) |
mistral-medium-latest |
256k | Medium 3.5, multimodal, agentic and coding work |
mistral-small-latest |
256k | Small 4, cheapest everyday chat, reasoning and code |
codestral-latest |
128k | Code generation and fill-in-the-middle |
mistral-embed |
8k | Text embeddings (1024 dimensions) |
Aliases move to newer versions; pin a dated name (mistral-small-2603, codestral-2508) in production. open-mistral-nemo was deprecated in May 2026 with retirement scheduled for 2026-07-31 (docs.mistral.ai/models still lists it as Deprecated). The full list with status and retirement dates is at docs.mistral.ai/models.
Instructions
Basic Chat Completion (Python)
In mistralai 2.x and later the import is from mistralai.client import Mistral; from mistralai import Mistral raises ImportError. On the old 1.x line pin pip install "mistralai<2".
import os
from mistralai.client import Mistral
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
response = client.chat.complete(
model="mistral-large-latest",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain the difference between async and sync programming."},
],
)
print(response.choices[0].message.content)
print(f"Prompt tokens: {response.usage.prompt_tokens}")
print(f"Completion tokens: {response.usage.completion_tokens}")
TypeScript/Node.js
import { Mistral } from "@mistralai/mistralai"; // named export; there is no default export
const client = new Mistral({ apiKey: process.env.MISTRAL_API_KEY });
const response = await client.chat.complete({
model: "mistral-large-latest",
messages: [{ role: "user", content: "Hello from TypeScript!" }],
});
console.log(response.choices[0].message.content);
Streaming
from mistralai.client import Mistral
client = Mistral()
stream = client.chat.stream(
model="mistral-small-latest",
messages=[{"role": "user", "content": "Write a haiku about programming."}],
)
for event in stream:
chunk = event.data.choices[0].delta.content
if chunk:
print(chunk, end="", flush=True)
print()
Function Calling
import json
from mistralai.client import Mistral
client = Mistral()
tools = [
{
"type": "function",
"function": {
"name": "search_products",
"description": "Search for products in a catalog",
"parameters": {
"type": "object",
"properties": {
"query": {"type": "string"},
"max_price": {"type": "number"},
"category": {"type": "string"},
},
"required": ["query"],
},
},
}
]
messages = [{"role": "user", "content": "Find laptops under 1000 dollars"}]
response = client.chat.complete(
model="mistral-large-latest",
messages=messages,
tools=tools,
tool_choice="auto", # default; "any" forces a call, "none" forbids one
)
if response.choices[0].finish_reason == "tool_calls":
tool_call = response.choices[0].message.tool_calls[0]
args = json.loads(tool_call.function.arguments)
print(f"Function: {tool_call.function.name}, Args: {args}")
# Add tool result and continue
messages.append(response.choices[0].message) # keep the assistant message with its tool_calls
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"name": tool_call.function.name,
"content": json.dumps([{"name": "ThinkPad X1", "price": 899}]),
})
final = client.chat.complete(model="mistral-large-latest", messages=messages)
print(final.choices[0].message.content)
JSON Mode
from mistralai.client import Mistral
import json
client = Mistral()
response = client.chat.complete(
model="mistral-small-latest",
messages=[
{
"role": "user",
"content": "Return a JSON object with fields: title, author, year for the book '1984'",
}
],
response_format={"type": "json_object"},
)
data = json.loads(response.choices
Установить mistral-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mistral-api?
Mistral AI API gives access to Mistral's chat, code, embedding, OCR and speech models from a Paris-based provider, with an optional EU regional endpoint. Use when you need chat completions, streaming, function calling, JSON output, Codestral fill-in-the-middle, embeddings, or EU-region inference.
Как установить скилл mistral-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mistral-api запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic