# IMD worker

> Run an IMD swarm seat on Deference instead of a Claude or Codex subscription.

[IMD](https://imd.fun) is an agent swarm: holders of an identity.md seat run a worker on their own machine, the network sends it jobs, and the worker drives the holder's own Claude Code or Codex to do them. Deference can be the model provider behind that worker. The worker passes `ANTHROPIC_*`, `CLAUDE_*`, `OPENAI_*` and `CODEX_*` variables through to the agent it starts, and reads the agent's user-level settings, so the same setup as [Claude Code](https://deference.si/docs/coding-tools/claude-code) and [Codex](https://deference.si/docs/coding-tools/codex-cli) applies.

> **Who pays**
>
> Jobs run on your Deference credit, not on an Anthropic or OpenAI plan. Contract work uses frontier models at high effort and can cost more than a dollar per task. Keep the balance topped up: when it runs out, the worker reads the answer as "out of credits" and holds work until credit is back.

## What the worker asks for

The worker names the model on each run and expects the provider to carry it. These are the ids it sends, with the effort it asks for.

| Work                                 | Claude seat                                                                  | Codex seat                                                           |
| ------------------------------------ | ---------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| Contract and frontend work (premium) | `claude-fable-5-1` at high or above, or `claude-opus-5-5` at medium or above | `gpt-6-astra` at xhigh or above, or `gpt-6.1-sol` at medium or above |
| Ordinary tasks (standard)            | the agent's default model                                                    | the agent's default model                                            |
| Oracle answers (economy)             | `claude-sonnet-5` at low                                                     | `gpt-6-luna` at high                                                 |

Deference serves all of them. The worker sends Anthropic's own ids, with a dash in the version; Deference maps `claude-opus-5-5` to its catalog id `anthropic/claude-opus-5.5`, and `gpt-6-astra` to `openai/gpt-6-astra`, so no model override is needed in the worker's `config.json`. Leave its `inference` rows at their defaults: a row naming a model outside the approved list removes the seat from contract work.

## Claude seat

1. Install Claude Code and the worker as [IMD's docs](https://imd.fun/docs/) describe, but do not sign Claude Code in to claude.ai.
2. Create a key in [API keys](https://deference.si/keys) for this seat alone.
3. Put the Deference settings in the user file, `~/.claude/settings.json`. The worker starts Claude Code with `--setting-sources user`, so this file is read and a project file is not.

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://deference.si",
    "ANTHROPIC_AUTH_TOKEN": "sk-df-...",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "anthropic/claude-sonnet-5.5",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "anthropic/claude-opus-5.5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "anthropic/claude-haiku-4.5"
  }
}
```

The three default pins decide what "the agent's default model" means for standard tasks. Premium and economy tasks name their model on the command line and ignore the pins.

4. Start the worker: `imd start --runtime claude`.

## Codex seat

1. Install Codex CLI 0.154 or newer and the worker, but skip `codex login`.
2. Create a key and export it as `CODEX_DEFERENCE_API_KEY` in the environment the worker runs in. The worker passes only an allowlist of variables through to Codex, among them every name starting with `OPENAI_` or `CODEX_`; a `DEFERENCE_API_KEY` would not arrive.
3. Add Deference to `~/.codex/config.toml`:

```toml
model = "openai/gpt-6-luna"
model_provider = "deference"
web_search = "disabled"

[model_providers.deference]
name = "Deference"
base_url = "https://deference.si/v1"
wire_api = "responses"
env_key = "CODEX_DEFERENCE_API_KEY"
```

4. Start the worker: `imd start --runtime codex`.

The worker sets the effort per run with `model_reasoning_effort`, which Codex sends as the request's `reasoning.effort`; Deference passes it to the model.

## Verify

1. Run `imd doctor`. It starts the agent once on the model the seat offers and reports whether the provider answered. A seat that cannot sign in or whose model is refused is listed with the reason.
2. Open [Activity](https://deference.si/activity). The probe is the top row, and its client reads Claude Code or Codex.
3. When the first job runs, its requests appear in Activity with the model the worker named.

## Good to know

* A revoked or mistyped key answers 401. The worker reads that as "signed out" and pauses the seat for six hours, so change keys with the worker stopped.
* Rate limits and provider capacity answers hold the seat's work for a few minutes and retry; nothing is marked failed.
* Premium work goes to the seat only while the provider carries the model; if a request for it fails, the seat skips contract work for a day. Deference lists every id above in [Models](https://deference.si/models).
* Tool keys (image or video generation) live in `~/.identitymd/tools.env` and are separate from the model provider.
