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

Before you start

  • The hello-agent project from the Quickstart.
  • A GitHub repository for the project, and the GitHub connector connected on your account in Mistral Studio. agents deploy builds 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

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 HEAD

These commands assume agents init created the repository. If it did not:

  • You answered no, passed --no-git, or git was missing: run git init first. The commit then takes every file, uv.lock included.
  • 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

2. Deploy the agent

uv run --env-file .env agents deploy

A 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.

$ git add --all && git commit -m "Add get_forecast"
[main a1b2c3d] Add get_forecast
1 file changed, 9 insertions(+)
$ git push -u origin HEAD
To github.com:you/hello-agent.git
* [new branch] HEAD -> main
$ uv run --env-file .env agents deploy
Git configuration
┏━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
│ Repository │ https://github.com/you/hello-agent │
│ Revision │ a1b2c3d9f04e6b1c27d58e3a90b4f61c2d7e8a35 │
│ Working directory │ (root) │
│ Dockerfile │ Dockerfile │
│ Agents SDK │ 1.1.0 │
└───────────────────┴──────────────────────────────────────────┘
Deploying hello-agent to managed platform...
Created agent 0e7c51d2-8a4f-4b39-9d16-3f2a7b6c9e01 (managed deployment: 5b9d03e8-1c2f-4e7a-a6b4-8d0f2c3e4a51).
⠋ Queued · 0sAgent hello-agent is live after 2m31s.
Try the agent:
• in Vibe Code Web: https://…/hello-agent
• programmatically, using the Session API: https://docs.mistral.ai/studio/agents/learn/sessions/sessions
$ uv run --env-file .env agents chat hello-agent
Talking to hello-agent (session 9a41e2c7-3b5d-4f08-8e6a-1c2d3e4f5a6b). Ctrl+D or /exit to quit.
> What's the weather in Lyon?
■✓ get_weather {"city": "Lyon"}
⎣ {"weather": "sunny in Lyon"}
It's sunny in Lyon right now ☀️ — a lovely day to be outside!
Step 1 of 5. Commit and push first: agents deploy deploys the pushed commit, not the files on your laptop.
3. Chat with the deployed agent

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-agent

Read the deployed agent's logs with agents logs; --follow keeps printing new lines:

uv run --env-file .env agents logs hello-agent --follow

agents 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

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.py

The 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

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 serve

While 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

Common issues

You seeDo this
agents list shows the agent as not observedNothing is running the agent: deploy it again, or start agents serve
Next steps

Next steps