In case you want to use a specific agent from the deprecated agents api for batch inference, you can specify the agent ID here.













Batch Endpoints
Batch API












Examples
Real world code examples
Playground
Test the endpoints live
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.list({});
console.log(result);
}
run();
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.list({});
console.log(result);
}
run();
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.list(page=0, page_size=100, created_by_me=False, order_by="-created")
# Handle response
print(res)
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.list(page=0, page_size=100, created_by_me=False, order_by="-created")
# Handle response
print(res)
curl https://api.mistral.ai/v1/batch/jobs \
-X GET \
-H 'Authorization: Bearer YOUR_APIKEY_HERE'curl https://api.mistral.ai/v1/batch/jobs \
-X GET \
-H 'Authorization: Bearer YOUR_APIKEY_HERE'200
{
"total": 87
}{
"total": 87
}Create Batch Job
POST /v1/batch/jobs#
Create a new batch job, it will be queued for processing.
endpoint#
input_files#
A list of .jsonl files for batch inference.
Each line must be a JSON object with a body field containing the request payload:
\{"custom_id": "0", "body": \{"max_tokens": 100, "messages": [\{"role": "user", "content": "What is the best French cheese?"\}]\}\}
\{"custom_id": "1", "body": \{"max_tokens": 100, "messages": [\{"role": "user", "content": "What is the best French wine?"\}]\}\}\{"custom_id": "0", "body": \{"max_tokens": 100, "messages": [\{"role": "user", "content": "What is the best French cheese?"\}]\}\}
\{"custom_id": "1", "body": \{"max_tokens": 100, "messages": [\{"role": "user", "content": "What is the best French wine?"\}]\}\}metadata#
The metadata of your choice to be associated with the batch inference job.
requests#
200
OK
agent_id#
completed_at#
error_file#
metadata#
model#
object#
Default Value: "batch"
output_file#
outputs#
started_at#
status#
Playground
Test the endpoints live
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.create({
endpoint: "/v1/moderations",
model: "mistral-small-latest",
});
console.log(result);
}
run();
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.create({
endpoint: "/v1/moderations",
model: "mistral-small-latest",
});
console.log(result);
}
run();
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.create(endpoint="/v1/moderations", model="mistral-small-latest", timeout_hours=24)
# Handle response
print(res)
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.create(endpoint="/v1/moderations", model="mistral-small-latest", timeout_hours=24)
# Handle response
print(res)
curl https://api.mistral.ai/v1/batch/jobs \
-X POST \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"endpoint": "/v1/chat/completions"
}'curl https://api.mistral.ai/v1/batch/jobs \
-X POST \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json' \
-d '{
"endpoint": "/v1/chat/completions"
}'200
{
"completed_requests": "10",
"created_at": 14,
"endpoint": "/v1/chat/completions",
"errors": [
{
"message": "Example message."
}
],
"failed_requests": "0",
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
"input_files": [
"019b2bd7-96e7-7219-8c0b-45a73da50088"
],
"status": "QUEUED",
"succeeded_requests": "10",
"total_requests": "10"
}{
"completed_requests": "10",
"created_at": 14,
"endpoint": "/v1/chat/completions",
"errors": [
{
"message": "Example message."
}
],
"failed_requests": "0",
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
"input_files": [
"019b2bd7-96e7-7219-8c0b-45a73da50088"
],
"status": "QUEUED",
"succeeded_requests": "10",
"total_requests": "10"
}Get Batch Job
GET /v1/batch/jobs/{job_id}#
Get a batch job details by its UUID.
Args: inline: If True, return results inline in the response.
200
OK
agent_id#
completed_at#
error_file#
metadata#
model#
object#
Default Value: "batch"
output_file#
outputs#
started_at#
status#
Playground
Test the endpoints live
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.get({
jobId: "4017dc9f-b629-42f4-9700-8c681b9e7f0f",
});
console.log(result);
}
run();
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.get({
jobId: "4017dc9f-b629-42f4-9700-8c681b9e7f0f",
});
console.log(result);
}
run();
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.get(job_id="4017dc9f-b629-42f4-9700-8c681b9e7f0f")
# Handle response
print(res)
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.get(job_id="4017dc9f-b629-42f4-9700-8c681b9e7f0f")
# Handle response
print(res)
curl https://api.mistral.ai/v1/batch/jobs/{job_id} \
-X GET \
-H 'Authorization: Bearer YOUR_APIKEY_HERE'curl https://api.mistral.ai/v1/batch/jobs/{job_id} \
-X GET \
-H 'Authorization: Bearer YOUR_APIKEY_HERE'200
{
"completed_requests": "10",
"created_at": 14,
"endpoint": "/v1/chat/completions",
"errors": [
{
"message": "Example message."
}
],
"failed_requests": "0",
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
"input_files": [
"019b2bd7-96e7-7219-8c0b-45a73da50088"
],
"status": "QUEUED",
"succeeded_requests": "10",
"total_requests": "10"
}{
"completed_requests": "10",
"created_at": 14,
"endpoint": "/v1/chat/completions",
"errors": [
{
"message": "Example message."
}
],
"failed_requests": "0",
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
"input_files": [
"019b2bd7-96e7-7219-8c0b-45a73da50088"
],
"status": "QUEUED",
"succeeded_requests": "10",
"total_requests": "10"
}Playground
Test the endpoints live
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.delete({
jobId: "d9e71426-5791-49ad-b8d1-cf0d90d1b7d0",
});
console.log(result);
}
run();
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.delete({
jobId: "d9e71426-5791-49ad-b8d1-cf0d90d1b7d0",
});
console.log(result);
}
run();
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.delete(job_id="d9e71426-5791-49ad-b8d1-cf0d90d1b7d0")
# Handle response
print(res)
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.delete(job_id="d9e71426-5791-49ad-b8d1-cf0d90d1b7d0")
# Handle response
print(res)
curl https://api.mistral.ai/v1/batch/jobs/{job_id} \
-X DELETE \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json'curl https://api.mistral.ai/v1/batch/jobs/{job_id} \
-X DELETE \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json'200
{
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088"
}{
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088"
}Cancel Batch Job
POST /v1/batch/jobs/{job_id}/cancel#
Request the cancellation of a batch job.
200
OK
agent_id#
completed_at#
error_file#
metadata#
model#
object#
Default Value: "batch"
output_file#
outputs#
started_at#
status#
Playground
Test the endpoints live
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.cancel({
jobId: "4fb29d1c-535b-4f0a-a1cb-2167f86da569",
});
console.log(result);
}
run();
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: "MISTRAL_API_KEY",
});
async function run() {
const result = await mistral.batch.jobs.cancel({
jobId: "4fb29d1c-535b-4f0a-a1cb-2167f86da569",
});
console.log(result);
}
run();
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.cancel(job_id="4fb29d1c-535b-4f0a-a1cb-2167f86da569")
# Handle response
print(res)
from mistralai.client import Mistral
import os
with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:
res = mistral.batch.jobs.cancel(job_id="4fb29d1c-535b-4f0a-a1cb-2167f86da569")
# Handle response
print(res)
curl https://api.mistral.ai/v1/batch/jobs/{job_id}/cancel \
-X POST \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json'curl https://api.mistral.ai/v1/batch/jobs/{job_id}/cancel \
-X POST \
-H 'Authorization: Bearer YOUR_APIKEY_HERE' \
-H 'Content-Type: application/json'200
{
"completed_requests": "10",
"created_at": 14,
"endpoint": "/v1/chat/completions",
"errors": [
{
"message": "Example message."
}
],
"failed_requests": "0",
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
"input_files": [
"019b2bd7-96e7-7219-8c0b-45a73da50088"
],
"status": "QUEUED",
"succeeded_requests": "10",
"total_requests": "10"
}{
"completed_requests": "10",
"created_at": 14,
"endpoint": "/v1/chat/completions",
"errors": [
{
"message": "Example message."
}
],
"failed_requests": "0",
"id": "019b2bd7-96e7-7219-8c0b-45a73da50088",
"input_files": [
"019b2bd7-96e7-7219-8c0b-45a73da50088"
],
"status": "QUEUED",
"succeeded_requests": "10",
"total_requests": "10"
}