Mistral Agents SDK - build and serve agents in Python
Actively maintained. Last release 2 weeks ago. A safe choice.
pip install mistralai-agentsMistral Managed Agents
Build an agent in Python. Try it on your laptop, then run the same code in production with one command.
An agent is a model and its instructions, plus the tools, sandboxes, connectors, skills and subagents it can use. The same agent runs in your process, on your own server with agents serve, or on Mistral with agents deploy.
Install
You need Python 3.12, 3.13 or 3.14, and a Mistral API key from Studio.
uv init --python 3.12 my_agent && cd my_agent
uv add mistralai-agents
export MISTRAL_API_KEY="<your-key>"
With pip: pip install mistralai-agents.
Hello world
import asyncio
from mistralai import agents
agent = agents.Agent(model="mistral-large-4")
async def main() -> None:
result = await agent.run("Say hello")
print(result.text)
asyncio.run(main())
agent.run sends one message and returns the result when the agent has answered.
Create a project
agents init creates a project with an agent, a tool and a Dockerfile. Chat with the agent in your terminal. Then push the project to a GitHub repository and deploy it:
uvx --python 3.12 --from mistralai-agents agents init hello-agent
cd hello-agent
uv run --env-file .env agents chat
git remote add origin <repository-url>
git push -u origin HEAD
uv run --env-file .env agents deploy
These git commands assume agents init created the repository and committed the project. If it did not, the Next steps panel it prints has the commands for your case.
Learn more
Feedback
Ask questions and report bugs on the Mistral AI Discord. For a private or account issue, contact Mistral support. Never paste an API key in a report.