# Chat service (/platform/self-hosting/chat)

Chat, the Sim Chat workflow block, and Inbox run on a separate service, the Mothership. A self-hosted Sim either connects to the Mothership Sim hosts or to one you run beside it. Without either, set `NEXT_PUBLIC_CHAT_DISABLED=true` to hide Chat.

| | Sim-hosted Mothership | Your own Mothership |
| - | - | - |
| You run | Sim only | Sim, the Mothership, its PostgreSQL database, Redis, and model provider accounts |
| From Sim you need | A customer API key | A runtime license, a registry token for the private image, and the release bundle |
| Model inference | Sim's model providers | The providers you configure, such as Amazon Bedrock in your own account |

## Connection settings \[#connection-settings]

These are set on **Sim**, not on the Mothership.

| Variable | Description |
| - | - |
| `COPILOT_API_KEY` | Sim-hosted: the customer API key issued to your account. Your own: the Mothership's `COPILOT_INBOUND_API_KEY`. A runtime license is never an API key |
| `SIM_AGENT_API_URL` | The Mothership origin as the Sim server reaches it. Defaults to `https://www.copilot.sim.ai`, the Sim-hosted service |
| `MOTHERSHIP_SIM_TRANSPORT` | How the Mothership reaches Sim. `direct`: it calls Sim at its own `SIM_ENDPOINT`. `checkpoint`: Sim collects workspace tool calls by polling the Mothership over outbound HTTPS, so the Sim-hosted service needs no route into Sim. A Mothership you run still reaches `SIM_ENDPOINT` for account validation and usage reporting with either transport. Self-hosted Sim defaults to `checkpoint` |
| `INTERNAL_API_SECRET` | Sim's existing secret. Your own Mothership uses the same value |

For the Sim-hosted service, set `COPILOT_API_KEY` and keep the defaults. Chat attachments also need an object storage bucket; see [Object storage](/platform/self-hosting/object-storage).

## Run the Mothership \[#run-the-mothership]

Tab: Helm

The chart's `copilot` values deploy the Mothership, its own PostgreSQL (bundled, or external through `copilot.database`), and a migrations Job. Start from `helm/sim/examples/values-copilot.yaml`.

| Value | Notes |
| - | - |
| `copilot.enabled` | `true` |
| `copilot.server.image.tag` or `.digest` | Required. The image is versioned apart from the chart: pin the `main-<commit>` tag from the Mothership release notes |
| `copilot.server.imagePullSecrets` | A `docker.io` pull Secret with username `simstudioai` and the registry token from Sim. Applies to the Mothership pods only |
| `copilot.server.env.LICENSE_KEY` | The runtime license, beginning `lic-` |
| `copilot.server.env.COPILOT_INBOUND_API_KEY` | A random value, for example `openssl rand -hex 32` |
| `copilot.server.env.INTERNAL_API_SECRET` | The app's `INTERNAL_API_SECRET` |
| `copilot.server.env.SIM_ENDPOINT` | The Sim origin as the Mothership pod reaches it, without a trailing slash |
| `copilot.server.env.REDIS_URL` | Required, even with one replica |
| Provider credentials | For the models you route, for example `OPENAI_API_KEY` and `ANTHROPIC_API_KEY_1`. Claude on Bedrock signs with the pod's AWS identity and needs no key |

With the Mothership enabled, the chart points the app at it: `SIM_AGENT_API_URL` is the in-cluster Service, `MOTHERSHIP_SIM_TRANSPORT` is `direct`, and `COPILOT_API_KEY` comes from the Mothership's Secret. A key you set in `app.env` or map through `externalSecrets.remoteRefs.app` wins. With `app.secrets.existingSecret`, the chart sets none of them, so store them in that Secret. The app's NetworkPolicy also allows traffic to and from the Mothership pods.

Each Mothership pod gets 120 seconds to hand its in-flight chats to another replica on shutdown (`copilot.server.terminationGracePeriodSeconds`). Keep it about 30 seconds above the Mothership's `COPILOT_SHUTDOWN_HANDOFF_MS`.

Tab: Docker

Run the image from the release bundle as its `ENTERPRISE.md` describes, with a dedicated PostgreSQL 16+ database and Redis 7+, then set the [connection settings](#connection-settings) on Sim: `SIM_AGENT_API_URL` to the Mothership origin, `COPILOT_API_KEY` to its `COPILOT_INBOUND_API_KEY`, and `MOTHERSHIP_SIM_TRANSPORT=direct` when the Mothership can reach Sim.

Model routing, provider hosts (Anthropic, Amazon Bedrock, OpenAI, Azure OpenAI, and others), and every Mothership setting are documented in `ENTERPRISE.md` in the release bundle.

## Network access \[#network-access]

Warning:

Running the Mothership yourself does not make Chat offline. It validates its runtime license with `www.license.copilot.sim.ai` over HTTPS at startup and every hour, and stops if the license is invalid. Chat content goes to the model providers you configure.

| From | To | Why |
| - | - | - |
| Sim | The Mothership origin | Chat requests, with long-lived streaming responses |
| The Mothership | `SIM_ENDPOINT` | Account validation and usage reporting with either transport, and workspace tools with `direct` |
| The Mothership | `www.license.copilot.sim.ai:443` | Runtime license |
| The Mothership | Your model providers | Inference |
| Your nodes | `docker.io` | Pulling the private image, unless you mirror it |

For AWS GovCloud (US), see [Reference architectures](/platform/self-hosting/reference-architectures#aws-govcloud-us).

## Verify \[#verify]

Open a new chat in a test workspace, ask it to list a workspace resource, and have it create a test workflow. Then reload the browser during a longer response and confirm the chat recovers. A health check alone does not exercise the license, provider credentials, or the connection back to Sim.
