mistral-api
Mistral AI API — European LLM provider with strong code and reasoning models. Use when you need GDPR-compliant AI inference, code generation with Codestral, multilingual tasks, cost-efficient inference, or a European data-residency option.
What this skill does
# Mistral AI API
## Overview
Mistral AI is a French AI company providing high-quality, cost-efficient language models with EU data residency and GDPR compliance. Their models excel at code generation (Codestral), multilingual tasks, and reasoning. Mistral's API follows OpenAI conventions closely, making integration straightforward.
## Setup
```bash
# Python
pip install mistralai
# TypeScript/Node
npm install @mistralai/mistralai
```
```bash
export MISTRAL_API_KEY=...
```
## Available Models
| Model | Context | Best For |
|---|---|---|
| `mistral-large-latest` | 128k | Most capable, complex reasoning |
| `mistral-small-latest` | 128k | Cost-efficient, everyday tasks |
| `codestral-latest` | 256k | Code generation & completion |
| `mistral-embed` | 8k | Text embeddings |
| `open-mistral-nemo` | 128k | Open-weight, edge deployment |
## Instructions
### Basic Chat Completion (Python)
```python
from mistralai import Mistral
client = Mistral(api_key="your_api_key") # or reads 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
```typescript
import Mistral from "@mistralai/mistralai";
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
```python
from mistralai 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
```python
import json
from mistralai 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"}]
response = client.chat.complete(
model="mistral-large-latest",
messages=messages,
tools=tools,
tool_choice="auto",
)
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)
messages.append({
"role": "tool",
"tool_call_id": tool_call.id,
"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
```python
from mistralai 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[0].message.content)
print(data) # {"title": "1984", "author": "George Orwell", "year": 1949}
```
### Text Embeddings
```python
from mistralai import Mistral
client = Mistral()
response = client.embeddings.create(
model="mistral-embed",
inputs=["Machine learning is transforming industries.", "AI is the future of technology."],
)
embeddings = [item.embedding for item in response.data]
print(f"Embedding dimension: {len(embeddings[0])}") # 1024
# Compute cosine similarity
import numpy as np
def cosine_similarity(a, b):
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
similarity = cosine_similarity(embeddings[0], embeddings[1])
print(f"Similarity: {similarity:.3f}")
```
### Codestral for Code Completion
```python
from mistralai import Mistral
client = Mistral()
# Fill-in-the-middle (FIM) — Codestral's signature feature
response = client.fim.complete(
model="codestral-latest",
prompt="def fibonacci(n):\n if n <= 1:\n return n\n ",
suffix="\n\nresult = fibonacci(10)\nprint(result)",
)
print(response.choices[0].message.content)
# Returns the middle code that connects prompt to suffix
```
```python
# Standard code generation
response = client.chat.complete(
model="codestral-latest",
messages=[
{
"role": "user",
"content": "Write a Python class for a rate limiter using token bucket algorithm.",
}
],
)
print(response.choices[0].message.content)
```
## GDPR Compliance Notes
- All API data processed in EU data centers by default.
- Mistral AI is headquartered in Paris, France — subject to EU/GDPR jurisdiction.
- For enterprise data residency guarantees, use Mistral's Azure or GCP deployments.
- No training on user data by default — check your plan's DPA for details.
## Guidelines
- Use `mistral-large-latest` for complex tasks, `mistral-small-latest` for cost savings.
- Codestral is specialized for code and significantly outperforms general models on FIM tasks.
- The `mistral-embed` model produces 1024-dimensional vectors.
- Mistral models have strong multilingual performance, especially in French, Spanish, Italian, German, and Portuguese.
- Function calling requires `tool_choice` to be set — use `"auto"` for model-driven decisions.
- JSON mode requires the system or user prompt to explicitly mention JSON output.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.