Quickstart: deploy a workflow to Mistral
In this quickstart, you deploy a project scaffolded by the Mistral CLI as a managed deployment: you push the project to GitHub, and Mistral Cloud builds and runs the worker for you. There are no servers to manage and no API key in the repository: the worker authenticates with a service-account token that the platform injects.
If you are new to Workflows, start with Build your first workflow. It explains the concepts this quickstart builds on.
Prerequisites
- A Mistral account with pay-as-you-go enabled, or an Enterprise plan. The Free plan cannot run managed deployments, and paid Pro or Team plans alone don't qualify — pay-as-you-go must be enabled on the organization. See Quotas.
- The Mistral CLI and uv. To install the CLI, run
curl -fsSL https://mistral.ai/cli/install.sh | bash, then sign in withmistral login. - A GitHub account, with permission to create a repository in an organization or your personal account.
- An organization where
mistral apps deployis enabled. The command is rolled out per organization; without it, use the Studio and API path.
Step 1: Scaffold the project
Follow Your first workflow to scaffold a project with mistral workflows init and add the hello-world workflow. The scaffold includes deploy/docker/Dockerfile.worker, which builds the worker image for managed deployments.
Check that the worker runs before deploying. From the project directory:
mistral apps devOnce the worker registers its workflows, stop it with Ctrl+C, then commit the workflow:
git add .
git commit -m "Add hello-world workflow"Step 2: Push the project to GitHub
Managed deployments build from a GitHub repository. Scaffolding already initialized a Git repository in the project directory and committed the project.
Managed deployments build from repositories on github.com. GitLab and GitHub Enterprise aren't supported.
Create an empty repository on GitHub, then push:
git remote add origin https://github.com/<your-org>/<your-repo-name>.git
git branch -M main
git push -u origin mainThe repository can be public or private: Mistral Cloud clones it through the Mistral GitHub App, not through public HTTPS.
Step 3: Install the Mistral GitHub App
Managed deployments clone your code through the Mistral GitHub App, and two things must be in place before you deploy:
- Install the Mistral GitHub App on the repositories you want to deploy. Go to github.com/apps/mistralai, click Configure, select your organization, and choose the repositories.
- Connect GitHub in the console. Open Studio›GitHub App settings ↗ and add a credential.
If your repository already appears in the deployment creation dialog in the next step, the App is installed and you can skip ahead. For an organization repository you do not administer, ask an organization owner to install the App.
The repository list shown when you create a deployment contains only repositories where the App is installed and that your account can access. If a repository is missing from the list, the App is not installed on it.
Step 4: Create the deployment
Choose a unique deployment name. Two deployments with the same name steal each other's executions.
# /// script
# dependencies = [
# "mistralai>=3.0",
# ]
# ///
import os
from mistralai.client import Mistral
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
deployment = client.workflows.deployments.create_deployment(
name="<your-deployment-name>",
spec={
"github_url": "https://github.com/<your-org>/<your-repo-name>",
"revision": "main",
"backend_spec": {
"type": "mistral_cloud",
"dockerfile_path": "deploy/docker/Dockerfile.worker",
},
},
)
print(deployment.name)The call returns the created deployment. Mistral Cloud then clones the repository, builds the image, and starts the worker.
.env is gitignored and never uploaded: the deployed worker gets its own credential and needs no API key.
Step 5: Verify and run a workflow
Wait for the deployment to become Active. This means the worker registered its workflows, which are listed on the deployment page. If the build fails, open the deployment details to read the error — most failures are Docker build or startup issues you can reproduce with Test the image locally.
Run the hello-world workflow like any other workflow:
# /// script
# dependencies = [
# "mistralai>=3.0",
# ]
# ///
import os
from mistralai.client import Mistral
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
execution = client.workflows.execute_workflow(
workflow_identifier="hello-world",
input={"name": "World"},
)
print(execution.execution_id)To wait for the workflow to finish and read its output, call client.workflows.execute_workflow_and_wait with the same arguments.
The execution lands on your managed worker and returns the greeting from the hello-world workflow.
Step 6: Ship a new version
Commit and push your changes to the deployed branch, then run mistral apps deploy again. It builds the pushed commit and updates my-workflow-worker to it: Mistral Cloud resolves the branch to its latest commit, rebuilds the image, and restarts the worker.
# /// script
# dependencies = [
# "mistralai>=3.0",
# ]
# ///
import os
from mistralai.client import Mistral
client = Mistral(api_key=os.environ["MISTRAL_API_KEY"])
deployment = client.workflows.deployments.restart_deployment(
name="<your-deployment-name>",
)
print(deployment.name)Create and restart a deployment in Studio or through the API
You can also create and restart the deployment in Studio or through the API, with the Console, curl, and Python tabs of Step 4 and Step 6. The result is the same hosted worker, except that the deployment takes the name you give it instead of <app>-worker and is not hardened unless you set hardened.
Troubleshooting
Each entry below starts from a message the CLI prints.
Not signed in. Run `mistral login` first.Runmistral login, or save an API key withmistral login --api-key -on a machine without a browser.No deploy target.The deploy needs an organization and workspace and has none saved. Run the command on a terminal to pick both, or find them withmistral context showand pass them with--organizationand--workspace(ID or name).No git remote named "origin".The project has no GitHub repository yet. Create one and push, as in Step 2.Your Mistral account is not connected to GitHuborThe Mistral GitHub app cannot see <owner>/<repo>. Connect GitHub in Studio›GitHub App settings ↗ and install the Mistral GitHub App on the repository, as described in Step 3.A new app has to be created in a workspace. Pass `--workspace <id or name>` with one of: <names>.The organization has more than one workspace. Run the command again on a terminal to pick one, or pass--workspacewith one of the listed names.The app's directory has <n> uncommitted change(s).ormistral.json has uncommitted changes. Commit and push everything in the app directory, untracked files included, then deploy again.Commit <sha> is not on any origin branch.Push the commit, then deploy again. If you pushed it from another machine, rungit fetch originfirst.Unknown subcommand "deploy" for "mistral apps"Your CLI predates the command. Runmistral upgradeand deploy again.`mistral apps deploy` is not enabled for <organization> yetThe command is enabled per organization by a feature flag, which the message names. Checkmistral context showand switch withmistral context setif the wrong organization is selected, or use the Studio and API path.Workflow deployment my-workflow-worker failed (build_failed: ...)The worker image did not build. Read its build logs with:
mistral apps logs worker --buildNext steps
- To give the worker credentials for external services, see Secrets.
- To use your own
Dockerfileor a worker in a subdirectory, see How it works. - If something goes wrong, see Troubleshooting.