From c77d50fe7d663591c6fecd304d6d0b18b04ec4b7 Mon Sep 17 00:00:00 2001 From: jean-malo Date: Thu, 15 Jan 2026 20:28:09 +0100 Subject: [PATCH 1/2] feat(mistral): add async batch job chat completion example Adds a new example demonstrating how to use Mistral's async batch job API for chat completion. The example creates a batch job with multiple requests, monitors its status, and prints the results once completed. This provides a practical implementation of asynchronous batch processing with Mistral's API. --- .../async_batch_job_chat_completion_inline.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/mistral/jobs/async_batch_job_chat_completion_inline.py diff --git a/examples/mistral/jobs/async_batch_job_chat_completion_inline.py b/examples/mistral/jobs/async_batch_job_chat_completion_inline.py new file mode 100644 index 00000000..94a01c6f --- /dev/null +++ b/examples/mistral/jobs/async_batch_job_chat_completion_inline.py @@ -0,0 +1,40 @@ +from mistralai import Mistral, BatchRequest, UserMessage +import os +import asyncio + + +async def main(): + client = Mistral(api_key=os.environ["MISTRAL_API_KEY"]) + + requests = [BatchRequest( + custom_id=str(i), + body=dict( + model="mistral-medium-latest", + messages=[UserMessage( + content=f"What's i + {i}" + )] + ) + ) for i in range(5) + ] + + job = await client.batch.jobs.create_async( + requests=requests, + model="mistral-small-latest", + endpoint="/v1/chat/completions", + metadata={"job_type": "testing"} + ) + + print(f"Created job with ID: {job.id}") + + while job.status not in ["SUCCESS", "FAILED"]: + await asyncio.sleep(1) + job = await client.batch.jobs.get_async(job_id=job.id) + print(f"Job status: {job.status}") + + print(f"Job is done, status {job.status}") + for res in job.outputs: + print(res["response"]["body"]) + +if __name__ == "__main__": + asyncio.run(main()) + From 82cd8afe825b689536909dde1a0d9fdbf470c332 Mon Sep 17 00:00:00 2001 From: jean-malo Date: Thu, 15 Jan 2026 20:38:26 +0100 Subject: [PATCH 2/2] fix --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3c5b4574..52aef0bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mistralai" -version = "1.10.0" +version = "1.10.1" description = "Python Client SDK for the Mistral AI API." authors = [{ name = "Mistral" }] requires-python = ">=3.10"