Mistral
Run batches on Mistral's Batch API — a JSONL upload followed by a job that carries the model.
Mistral's Batch API uploads a JSONL file and then creates a job that references it. The defining difference from OpenAI: the model and endpoint live on the job, not on each request line — so Batchwork strips model out of every line and sets it once on the job.
| Property | Value |
|---|---|
| Shape | JSONL file upload → create job |
| Endpoint | /v1/batch/jobs |
| Results | Output + error files (JSONL) |
| Webhooks | Poll-only (managed by the server) |
| Env var | MISTRAL_API_KEY |
| Package | @ai-sdk/mistral |
| Base URL | https://api.mistral.ai/v1 |
Example
import { batch } from "batchwork";
import { mistral } from "@ai-sdk/mistral";
const job = await batch({
model: mistral("mistral-large-latest"),
requests: [
{ customId: "fr", prompt: "Capital of France? One word." },
{ customId: "jp", prompt: "Capital of Japan? One word." },
],
});How it works
- Build — each request becomes a
{ custom_id, body }JSONL line, withmodelremoved. - Upload — the JSONL is uploaded via the Files API (
purpose=batch). - Create —
POST /v1/batch/jobssets themodel,endpoint, andinput_fileson the job. - Poll — Mistral's job
status(QUEUED,RUNNING,SUCCESS,FAILED,TIMEOUT_EXCEEDED, …) maps onto the normalized status. - Read — the OpenAI-shaped
output_fileanderror_fileare streamed and parsed intoBatchResults.
Batchwork validates Mistral job and file ids before using them in API paths.
Notes
Mistral has no native batch webhook, so it is poll-only. Use the server layer for unified completion events.
Credentials
Set MISTRAL_API_KEY, or pass apiKey / baseURL / headers to batch(). Install the peer dependency:
bun add @ai-sdk/mistral