Deploy your agent
agents deploy deploys the Quickstart's project with Studio, Mistral-managed, so you keep nothing running. Mistral stores each session, and any program with your API key calls the agent by name. You push the project, deploy it, chat with it, and call it from your app.
Before you start
- The
hello-agentproject from the Quickstart. - A GitHub repository for the project, and the GitHub connector connected on your account in Mistral Studio.
agents deploybuilds the commit you pushed, not your working copy. - A key whose user has a workspace role with Workflows access, such as Developer or Workspace Contributor. A workspace admin assigns it in the admin console: Organization > Workspaces > your workspace > Members. See Deploy.
1. Push the project
Commit your changes from the Quickstart and push the project:
git add --all && git commit -m "Add get_forecast"
git remote add origin <repository-url>
git push -u origin HEADThese commands assume agents init created the repository. If it did not:
- You answered no, passed
--no-git, or git was missing: rungit initfirst. The commit then takes every file,uv.lockincluded. - The project is inside a repository you already have, such as a monorepo: commit and push there, and skip
git remote add.
The Next steps box at the end of the agents init output lists the git commands for your case.
2. Deploy the agent
uv run --env-file .env agents deployA deploy builds the Dockerfile that agents init wrote. It uses the name= of your Agent, hello-agent. --name overrides it. The name is unique per workspace, so a later deploy of the same name replaces the agent. The deploy waits until the agent runs, then prints Agent hello-agent is live after and the time it took, and under Try the agent:, a link to chat with it in Vibe Code Web and one to the Session API docs.
agents deploy deploys the pushed commit, so commit and push your changes first: it refuses unpushed commits or a branch with no upstream. To build another Dockerfile, see Bring your own Dockerfile.
3. Chat with the deployed agent
Chat with the deployed agent by name. The session runs on Mistral, not in the agents chat process:
uv run --env-file .env agents chat hello-agentRead the deployed agent's logs with agents logs; --follow keeps printing new lines:
uv run --env-file .env agents logs hello-agent --followagents list shows the agents of your workspace and whether each one is running. See Agent lifecycle for everything agents chat, agents list and agents logs can do.
4. Call the deployed agent from your app
In your app, load the deployed agent by name with Agent.load_from. The rest of the code stays the same:
import asyncio
from mistralai import agents
async def main() -> None:
agent = agents.Agent.load_from(agent_name="hello-agent")
result = await agent.run("What's the weather in Lyon?")
print(result.text)
if __name__ == "__main__":
asyncio.run(main())uv run --env-file .env python app.pyThe turn runs on Mistral, not in your app. To let your app exit while a turn runs, start it with start_session and send_message and keep the session and turn ids: your app reads the result later from the stored ids. See Run in the background and Open a session by its id.
Self-host it instead
agents serve runs the same project on your own machine or servers, self-hosted, for example when the agent's tools must run inside your network. Mistral still stores the sessions:
uv run --env-file .env agents serveWhile it runs, agents chat hello-agent and Agent.load_from(agent_name="hello-agent") reach it as they reach a deployed agent. See Self-hosted (agents serve).
Common issues
| You see | Do this |
|---|---|
agents list shows the agent as not observed | Nothing is running the agent: deploy it again, or start agents serve |
Next steps
- Choose where it runs: Run modes.
- Pass secrets and trace the deployed agent: Deploy.
- Replace the agent, or shut it down: Agent lifecycle.
- Answer its approvals, then let the turn continue: Step through a session.
- Watch its turns and steer them: Build a session app.