# IMD worker

> Power an IMD swarm seat's Claude Code or Codex worker with your HeyEly credit balance.

[IMD](https://imd.fun) runs a distributed agent swarm where identity.md seat holders operate a local worker that executes network jobs through Claude Code or Codex. You can back that worker with HeyEly directly. Because the worker forwards `ANTHROPIC_*`, `CLAUDE_*`, `OPENAI_*`, and `CODEX_*` environment variables and respects each agent's user-level config, the standard [Claude Code](https://heyely.si/docs/coding-tools/claude-code) and [Codex](https://heyely.si/docs/coding-tools/codex-cli) setups apply cleanly here.

> **Who pays**
>
> Every job draws from your HeyEly credit balance rather than an Anthropic or OpenAI subscription. Frontier contract work runs at high reasoning effort and can easily exceed a dollar per task, so keep your balance funded. If your credit runs dry, the worker interprets the error as "out of credits" and pauses new jobs until funds return.

## What the worker asks for

On each job, the worker specifies the exact model and reasoning effort it expects your provider to serve:

| 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                                                 |

HeyEly carries every model listed above. Even though the worker sends hyphenated Anthropic version names, HeyEly automatically resolves `claude-opus-5-5` to `anthropic/claude-opus-5.5` and `gpt-6-astra` to `openai/gpt-6-astra`, so you do not need custom overrides in the worker's `config.json`. Keep the `inference` entries untouched, since pointing to an unapproved model disqualifies the seat from contract work.

## Claude seat

1. Follow [IMD's docs](https://imd.fun/docs/) to install Claude Code and the IMD worker, leaving Claude Code signed out of claude.ai.
2. Mint a dedicated API key in [Developers](https://heyely.si/keys) for this seat.
3. Configure HeyEly inside your user settings file at `~/.claude/settings.json`. Because the worker launches Claude Code with `--setting-sources user`, it loads only this file and skips repository settings.

```json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://heyely.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"
  }
}
```

Those three default class variables govern what "the agent's default model" resolves to on standard jobs. Premium and economy jobs pass an explicit CLI model flag and bypass these pins.

4. Launch the worker with `imd start --runtime claude`.

## Codex seat

1. Install Codex CLI 0.154 or later alongside the worker, skipping `codex login`.
2. Create an API key and export it as `CODEX_HEYELY_API_KEY` in the worker's environment. The worker filters environment variables through an allowlist that permits `OPENAI_*` and `CODEX_*` prefixes, so a plain `HEYELY_API_KEY` will not reach Codex.
3. Register HeyEly in `~/.codex/config.toml`.

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

[model_providers.heyely]
name = "HeyEly"
base_url = "https://heyely.si/v1"
wire_api = "responses"
env_key = "CODEX_HEYELY_API_KEY"
```

4. Launch the worker with `imd start --runtime codex`.

For each run, the worker sets `model_reasoning_effort`, which Codex translates into `reasoning.effort` and HeyEly forwards straight to the model.

## Verify

1. Run `imd doctor` to trigger a live probe on the seat's model and verify the provider responds cleanly. Any auth or model rejection prints with its cause.
2. Visit [Credit and usage](https://heyely.si/usage) to confirm the probe shows at the top of **Spend**, with **From** reporting Claude Code or Codex.
3. Once real swarm jobs begin arriving, their individual requests appear in Credit and usage tagged with each model the worker requested.

## Good to know

* A mistyped or revoked key triggers a `401`, which the worker treats as "signed out" and backs off the seat for six hours. Stop the worker before rotating keys.
* Temporary rate limits or upstream capacity spikes simply pause the seat for a few minutes and retry cleanly without failing the job.
* Seats only stay eligible for premium contract work while the provider serves the requested premium models. A failure on a premium model pauses contract routing for a day. Every ID above is listed in [Models](https://heyely.si/docs/models).
* Separate tool keys for image or video generation stay in `~/.identitymd/tools.env` and are independent of your HeyEly model config.
