Mistral
Mistral file-backed text and embedding batch jobs in Batchwork with normalized results and the shared async client.
Mistral uses file-backed Batch Jobs for chat and embeddings. Its JSONL and create payload differ from OpenAI: each line contains only custom_id and body, while the endpoint and model are supplied when the job is created.
At a glance
| Property | Batchwork behavior |
|---|---|
| Output modalities | Text and embeddings |
| Text inputs | Messages, tools, images, and PDFs |
| Endpoints | /v1/chat/completions, /v1/embeddings |
| Submission | JSONL upload, then /batch/jobs |
| Results | Output and error JSONL files |
| Batch metadata | Forwarded |
| Webhooks | Managed polling only |
| Credential | MISTRAL_API_KEY |
| Default base URL | https://api.mistral.ai/v1 |
Text example
from batchwork import BatchRequest, Batchwork
async with Batchwork() as client:
job = await client.batch(
model="mistral/mistral-large-latest",
requests=[BatchRequest(custom_id="summary", prompt="Summarize this report.")],
)
Embeddings
from batchwork import BatchEmbeddingRequest
job = await client.batch_embeddings(
model="mistral/mistral-embed",
requests=[BatchEmbeddingRequest(custom_id="doc-1", value="Document text")],
)
Mistral does not support canonical dimensions. Public Python and CLI submissions reject unknown Mistral embedding provider options before upload.
Lifecycle
- Each JSONL line contains
{custom_id, body};modelandstreamare removed from the body. - Batchwork uploads the JSONL file.
/batch/jobsreceives the file ID, endpoint, model, and optional batch metadata.poll()retrieves/batch/jobs/{id}.results()streams the output file and then the error file when present.cancel()calls/batch/jobs/{id}/cancel.
Mistral-specific uppercase states, including timeout and cancellation-requested states, map to normalized BatchStatus values.
Request translation
| Input | Mistral behavior |
|---|---|
seed |
Renamed to random_seed |
| Frequency/presence penalties | Ignored |
| Assistant reasoning | Folded into assistant text |
| Final assistant message | Receives prefix=True |
| Named tool choice | Filters tools to the named function and sends tool_choice="any" |
| Required tool choice | Becomes "any" |
Mistral provider options include safe prompt, reasoning effort, document image/page limits, and parallel tool calls.
CLI capability contract
Exact text provider-option keys are documentImageLimit, documentPageLimit, parallelToolCalls, reasoningEffort, and safePrompt. Only chat-completions is a valid explicit --endpoint. Unknown keys fail locally; document limits are positive integers, parallelToolCalls and safePrompt are booleans, and reasoningEffort is a string. Canonical frequency/presence penalties and top_k are unsupported.
CLI embedding provider options: none. Canonical embedding dimensions is also unsupported and fails before upload. Batch metadata is supported and forwarded. Package hard bounds are 50,000 requests, 20 MiB per serialized request, and 200 MiB aggregate, subject to lower Mistral/model limits.
Media
Mistral text requests support images and PDFs. HTTPS PDF URLs can pass directly. Image URLs and other resolvable image sources are downloaded and inlined. Other file media types are rejected.
Results
Mistral output and error files use OpenAI-shaped result normalization for text, embeddings, usage, and item errors. Provider-specific fields remain in result.response.
Mistral does not support image-generation output through Batchwork.
Official references
See Embeddings, Results, and Provider overview.