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.

PropertyValue
ShapeJSONL file upload → create job
Endpoint/v1/batch/jobs
ResultsOutput + error files (JSONL)
WebhooksPoll-only (managed by the server)
Env varMISTRAL_API_KEY
Package@ai-sdk/mistral
Base URLhttps://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

  1. Build — each request becomes a { custom_id, body } JSONL line, with model removed.
  2. Upload — the JSONL is uploaded via the Files API (purpose=batch).
  3. CreatePOST /v1/batch/jobs sets the model, endpoint, and input_files on the job.
  4. Poll — Mistral's job status (QUEUED, RUNNING, SUCCESS, FAILED, TIMEOUT_EXCEEDED, …) maps onto the normalized status.
  5. Read — the OpenAI-shaped output_file and error_file are streamed and parsed into BatchResults.

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

On this page