---
title: "First run"
description: "Start a leader on one machine, serve a model, send the first request, and add a second machine."
url: "https://opod.io/docs/core/first-run/"
markdown_url: "https://opod.io/docs/core/first-run.md"
section: "Core"
last_updated: "2026-10-30"
---

# First run

> Start a leader on one machine, serve a model, send the first request, and add a second machine.

## In short

This page starts a one-machine cluster: the leader and the engine on the same host. You send it a chat request, then add a second machine as a worker. You need `opod` and Ollama installed ([Install](https://opod.io/docs/core/install/)). It takes a few minutes, most of it the model download.

1. **Start the leader**

   By default a leader is **router-only**: it loads no model and serves from the workers that join it. On a single machine, tell it to serve a model itself with `OPOD_PULL_DEFAULT_MODEL=1`:

   ```bash
   # Ollama must be running (macOS: open -a Ollama; Linux: systemctl start ollama)
   OPOD_DEFAULT_MODEL=llama-3.2-1b OPOD_PULL_DEFAULT_MODEL=1 opod up
   ```

   Expected output, shortened:

   ```text
   ▶ detected darwin/arm64 · 24 GB RAM · 8 cores
   ▶ no node-join token yet — run `opod token create --node` (or set OPOD_JOIN_TOKEN) before `opod join` on a worker
   ✔ default model: llama-3.2-1b
   ✔ engine: ollama at http://127.0.0.1:11434

     First run. Pick a starter model to install — chat works as soon as it's done.
     Recommended for your hardware (24 GB RAM): llama-3.2-1b — Llama 3.2 1B Instruct (1.3 GB)
     Install llama-3.2-1b now? [Y/n/o=pick another]
   ✔ model ready: llama-3.2-1b

     Opod is ready.

     API:        http://localhost:8080/v1
     Health:     http://localhost:8080/healthz

     Admin API key (shown once — store it now):
       sk-orc-<printed once>

     Next steps:
       →  Wire up Aider:            opod connect aider
       →  Wire up Cursor:           opod connect cursor
       →  See all clients:          opod connect --list
       →  Mint another admin key:   opod token create ops --admin

     Quick test from the shell:
       curl http://localhost:8080/v1/chat/completions \
         …

     Press Ctrl-C to stop.
   ```

   After the key, `opod up` also lists every outbound network call this process can make, so you can check its privacy posture at a glance.

   The first `opod up` creates an **admin key**, prints it once and saves it to `~/.opod/admin.key` (mode `0600`). Later CLI commands on this host read that file, so you do not type the key. The key is minted only when the store holds **no key at all**: a later start names the file it is saved in (`Admin API key:  saved in ~/.opod/admin.key`), and when that file is gone it says so and points at `opod token create ops --admin`. The store keeps hashes only, so a lost key cannot be recovered.

   > **Up to and including 0.2.1, the key is printed on every start**
   >
   > In 0.2.1, every `opod up` prints the admin key from `~/.opod/admin.key` to stdout. When the leader's output goes to a log (a service unit, a container), that log holds the admin key: treat it as a secret, or run the leader under a manager that sets `auth.admin_token`, which writes no key file. From 0.3.0 only the start that creates the key prints it; later starts print the file's path.

   Without `OPOD_DEFAULT_MODEL`, the leader picks the largest catalog model that fits the detected hardware and prints `auto-selected model: …`; with nothing that fits, it warns `no catalog entry fits this hardware; set router.default_model in config`. The model is pulled only with `OPOD_PULL_DEFAULT_MODEL=1` and a reachable engine. On an interactive terminal with no model installed yet, the first run asks before it pulls: `Y` (or Enter) installs the recommended model, `n` skips, `o` opens a picker. `--no-wizard` skips the prompt; with no terminal it pulls without asking.

   ### What the first run writes

   | File                | Content                                                                    |
   | ------------------- | -------------------------------------------------------------------------- |
   | `~/.opod/state.db`  | The SQLite store: nodes, models, placements, keys (hashes), usage, events. |
   | `~/.opod/admin.key` | The admin key, mode `0600`.                                                |
   | `~/.opod/opod.pid`  | The leader's PID, read by `opod down`; removed on exit.                    |
   | `~/.opod/models/`   | Weights pulled by opod (an Ollama engine keeps its own store).             |

   The leader also writes its own node row, id `local`, which `opod node ls` shows.

   > **llama.cpp on one machine**
   >
   > With `OPOD_ENGINE=llamacpp OPOD_PULL_DEFAULT_MODEL=1 opod up`, opod launches `llama-server -hf <repo>` for the default model when nothing listens on the llama.cpp endpoint (`http://127.0.0.1:8089`), and stops it on shutdown. A watchdog restarts it after three failed health checks in a row.

2. **Send a request**

   `opod up` stays in the foreground. Run the next commands in a second terminal.

   ```bash
   curl http://localhost:8080/v1/chat/completions \
     -H "Authorization: Bearer sk-orc-<your-admin-key>" \
     -H "Content-Type: application/json" \
     -d '{"model":"auto","messages":[{"role":"user","content":"hi in 5 words"}]}'
   ```

   `"model": "auto"` resolves to the leader's default model. Any catalog id the cluster holds works too. `GET /v1/models` lists them.

   Point an OpenAI-compatible tool at the same URL:

   ```bash
   export OPENAI_BASE_URL=http://localhost:8080/v1
   export OPENAI_API_KEY=sk-orc-<your-admin-key>
   ```

   `opod connect <tool>` prints the exact settings for 15 tools. See [`opod connect`](https://opod.io/docs/core-cli/connect/).

3. **Give a teammate a key**

   Do not share the admin key. Mint a `user` key per person:

   ```bash
   opod token create alice --ttl 30d
   ```

   The key is printed once. A `user` key can call `/v1/*` only.

4. **Add a worker: mint a join token on the leader**

   ```bash
   opod token create --node
   ```

   A `node` key is the shared secret between the leader and a worker. Mint it only on a network you trust.

5. **Join from the new machine**

   Install opod and an engine on the new machine, then:

   ```bash
   opod join "http://leader.example.com:8080?token=sk-orc-<node-token>"
   ```

   The worker registers its hardware and engine, starts its own API on port `8081`, and heartbeats every 5 seconds. The leader must be able to reach the worker on that address. On a host with several interfaces, set `OPOD_ADVERTISE_ADDR=host:port`.

6. **Put a model on the worker**

   On the leader:

   ```bash
   opod node ls                                  # find the worker's node id
   opod model add qwen-coder-7b --node n_abc123  # the worker pulls and loads it
   ```

   The model is routable once the worker's next heartbeat reports it loaded.

7. **Stop**

   ```bash
   opod down              # stop the leader and unload models from the local engine
   opod down --no-unload  # stop only
   ```

   Ctrl-C on `opod up` stops it without unloading, so a restart is fast. A worker stops on Ctrl-C or `SIGTERM`: it tells the leader it is leaving, lets running requests finish (10 seconds by default), then stops its engine.

## Check it worked

```bash
opod status
opod node ls
curl -s http://localhost:8080/v1/models -H "Authorization: Bearer sk-orc-<your-admin-key>"
```

- `opod node ls` lists the leader as `local` and the new worker as `n_…`, both `ready`.
- `GET /v1/models` lists `llama-3.2-1b` and `qwen-coder-7b` once the worker's next heartbeat reports the model loaded.
- The chat request in step 2 answers `200` with `choices[0].message.content`.

## If it fails

| Output                                                                             | Fix                                                                                                                                                                            |
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `⚠ engine (ollama) at http://127.0.0.1:11434 is not reachable` and a start command | Start the engine, then `opod status`. The leader still starts and serves from workers.                                                                                         |
| `opod: config: parse ~/.opod/config.yaml: …`                                       | Fix the YAML.                                                                                                                                                                  |
| `opod: server: listen tcp :8080: bind: address already in use`                     | Another process holds the port. `opod down`, or set `listen`.                                                                                                                  |
| `opod: catalog: …`                                                                 | A catalog override file is broken or unsigned under your signature policy. `opod doctor` names it.                                                                             |
| `401` `missing_api_key` or `invalid_api_key` on the chat request                   | Send `Authorization: Bearer` with the admin key from the banner, or from `~/.opod/admin.key`.                                                                                  |
| The worker is not in `opod node ls`                                                | The token is wrong or revoked, or the leader cannot reach the worker on port `8081`. See [Troubleshooting](https://opod.io/docs/core/troubleshooting/#a-worker-does-not-join). |

## Next

- [Concepts](https://opod.io/docs/core/concepts/) explains placement, gangs and front doors.
- [Clusters](https://opod.io/docs/core/clusters/) covers drain, remove and model moves.
- [Configuration](https://opod.io/docs/core-reference/configuration/) lists every `config.yaml` field.
