mistralM

Docs

sideBar

Self-host workflows

Run workflow workers on your own infrastructure, grouped into named deployments.

A deployment is a named group of workers that owns a set of workflow definitions and receives all executions for those definitions. To self-host workflows, you run the workers yourself (on your machine for local development, or on your own infrastructure for production) and group them under a deployment name. It enables worker isolation in shared workspaces and automatic execution routing, while the platform keeps durability, scaling, and observability.

If you would rather not run workers at all, see managed deployments for workflows: Mistral Cloud builds and runs the worker for you, and the deployment concepts are the same.

Setting DEPLOYMENT_NAME

DEPLOYMENT_NAME is required at worker startup. The worker fails immediately at boot if it is not set.

DEPLOYMENT_NAME=invoice-service MISTRAL_API_KEY=your-key uv run python worker.py

Valid characters: letters, digits, hyphens, underscores, and dots (max 128 characters).

WORKER_NAME identifies the individual worker process and is visible in the console and API. It defaults to socket.gethostname().

Worker isolation

In a shared workspace, multiple developers can run workers simultaneously without interfering. Each deployment only receives executions for the workflow definitions it registered.

# Developer A
DEPLOYMENT_NAME=alice MISTRAL_API_KEY=shared-key uv run python worker.py

# Developer B
DEPLOYMENT_NAME=bob MISTRAL_API_KEY=shared-key uv run python worker.py

Alice's runs land on Alice's workers. Bob's runs land on Bob's workers.

Execution routing

When only one active deployment owns a workflow, executions route automatically — no extra configuration needed:

execution = client.workflows.execute_workflow(
    workflow_identifier="invoice_processor",
    input={"invoice_id": "INV-001"},
)

When two active deployments register the same workflow name, the platform cannot route automatically and returns 409 Conflict:

{
  "code": "AMBIGUOUS_WORKFLOW",
  "deployments": ["alice", "bob"]
}

Resolve by passing deployment_name explicitly:

execution = client.workflows.execute_workflow(
    workflow_identifier="invoice_processor",
    deployment_name="alice",
    input={"invoice_id": "INV-001"},
)

Conflict detection

When a worker registers a workflow name already owned by a different active deployment, the platform warns immediately. Registration is not blocked — the warning is returned in the registration response and appears in worker logs:

{
  "warnings": [
    "Workflow 'invoice_processor' is also registered by active deployment 'bob'"
  ]
}

The conflict resolves automatically when one of the deployments becomes inactive (its workers stop).

Multiple workers in the same deployment registering the same definitions is horizontal scaling — no warning is produced.

lightbulb

To restrict which users and service accounts can register workflows in a deployment, see Hardened deployments.

Deployment lifecycle

A deployment is active while at least one of its workers has heartbeated within the liveness window. Workers heartbeat every ~10 seconds automatically. When all workers stop, the deployment becomes inactive after the liveness window lapses (50 seconds in production, configurable).

Inactive deployments do not receive executions and are not counted as conflicting when checking for ambiguity.

Horizontal scaling

Run multiple workers under the same DEPLOYMENT_NAME to increase throughput. Executions are distributed across all active workers in the deployment.

For production, deploy workers as a Kubernetes Deployment or StatefulSet with replicas pointing at the same DEPLOYMENT_NAME. The platform load-balances tasks automatically.

Listing deployments

List all active deployments in your workspace:

from mistralai.client import Mistral

client = Mistral(api_key="your_api_key")

response = client.workflows.deployments.list_deployments()
for deployment in response.deployments:
    print(deployment.name, deployment.is_active)
Output
{
  "deployments": [
    {
      "id": "019d2585-21fc-7063-90ae-31a283c784a1",
      "name": "invoice-service",
      "is_active": true,
      "is_hardened": false,
      "created_at": "2026-03-25T15:02:55.234755Z",
      "last_heartbeat": "2026-04-02T17:42:34.960883Z",
      "updated_at": "2026-04-02T17:42:34.960883Z",
      "owner": null,
      "location": null,
      "worker_count": 1,
      "active_worker_count": 1,
      "locations": ["k8s"],
      "managed": null
    }
  ],
  "next_cursor": null,
  "workspace_id": "6f1d2c4e-8a3b-4f5d-9c7e-1a2b3c4d5e6f"
}

Pass workflow_name to filter by workflow, or active_only=false to include inactive deployments.

Inspect a specific deployment and its individual workers:

deployment = client.workflows.deployments.get_deployment(name="invoice-service")
print(deployment.name, deployment.is_active)
for worker in deployment.workers:
    print(worker.name, worker.last_heartbeat)
Output
{
  "id": "019d2585-21fc-7063-90ae-31a283c784a1",
  "name": "invoice-service",
  "is_active": true,
  "is_hardened": false,
  "created_at": "2026-03-25T15:02:55.234755Z",
  "last_heartbeat": "2026-04-02T17:42:41.828219Z",
  "updated_at": "2026-04-02T17:42:41.828219Z",
  "owner": null,
  "location": null,
  "worker_count": 1,
  "active_worker_count": 1,
  "locations": ["k8s"],
  "managed": null,
  "workers": [
    {
      "name": "my-worker-host",
      "created_at": "2026-03-25T15:15:07.911486Z",
      "last_heartbeat": "2026-04-02T17:42:13.679937Z",
      "updated_at": "2026-04-02T17:42:13.679937Z",
      "is_active": true,
      "location": {
        "location_type": "k8s",
        "k8s_cluster": "prod-eu",
        "k8s_namespace": "invoices"
      }
    }
  ]
}

Going further

Introduction to self-hosted deployments
illustrationServer

Introduction to self-hosted deployments

Run agents, workflows, and apps on your own infrastructure, with Mistral orchestration.

Managed deployments for workflows
illustrationWorkflow

Managed deployments for workflows

Deploy a workflow worker from a GitHub repository. Mistral Cloud builds the image and runs the worker for you.

Hardened deployments
illustrationShield

Hardened deployments

Restrict workflow registration to authorized users and service accounts with pins, as required for on-behalf-of workflows.

Secrets Manager
illustrationLock

Secrets Manager

Store credentials in Secrets Manager and reference them from your managed deployments without hardcoding.