# OpenClaw

> Configure HeyEly as a custom provider inside OpenClaw's JSON5 config and Gateway environment.

OpenClaw loads custom providers from `~/.openclaw/openclaw.json` (JSON5), where each provider declares its wire protocol and base URL. The configuration below routes OpenClaw to HeyEly over Chat Completions at `https://heyely.si/v1`.

## Set up

1. Generate an API key in [Developers](https://heyely.si/keys).
2. Store your key inside `~/.openclaw/.env`. Because OpenClaw's Gateway runs as a background service, variables exported only in your interactive shell may never reach it.

```bash
HEYELY_API_KEY=sk-df-...
```

3. Register the HeyEly provider and default model inside `~/.openclaw/openclaw.json`.

```json5
{
  agents: {
    defaults: {
      model: { primary: "heyely/anthropic/claude-sonnet-5.5" },
      models: {
        "heyely/anthropic/claude-sonnet-5.5": { alias: "Sonnet" },
      },
    },
  },
  models: {
    mode: "merge",
    providers: {
      heyely: {
        baseUrl: "https://heyely.si/v1",
        apiKey: "${HEYELY_API_KEY}",
        api: "openai-completions",
        models: [
          {
            id: "anthropic/claude-sonnet-5.5",
            name: "Claude Sonnet 5.5",
            reasoning: true,
            input: ["text", "image", "file"],
            cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
            contextWindow: 1000000,
            maxTokens: 128000,
          },
        ],
      },
    },
  },
}
```

OpenClaw hot-reloads provider edits automatically. If the new provider does not take effect immediately, run `openclaw gateway restart`.

Make sure every model you plan to call has a full entry inside `models`; creating an alias under `agents.defaults.models` alone does not register it. Leave `cost` fields set to zero because HeyEly's Credit and usage dashboard tracks actual billing.

## Verify

1. Run `openclaw models list --provider heyely` to confirm your configured model is registered.
2. Run `openclaw models status --probe` to execute a live probe and verify it prints `ok` (otherwise it flags categories like `auth`, `billing`, or `timeout`).
3. Send a quick message to your agent.
4. Open [Credit and usage](https://heyely.si/usage) to confirm the call sits at the top of **Spend** under your selected model.

## Pick a model

* OpenClaw references models as `provider/model-id` and splits on the first slash, so `heyely/anthropic/claude-sonnet-5.5` maps to provider `heyely` and catalog ID `anthropic/claude-sonnet-5.5`.
* Lock in a model with `openclaw models set heyely/anthropic/claude-sonnet-5.5`, or switch inside chat with `/model heyely/anthropic/claude-sonnet-5.5`.
* Supported `api` values are `openai-completions` (default), `openai-responses`, and `anthropic-messages`. When using `anthropic-messages`, set `baseUrl` to `https://heyely.si` (OpenClaw appends `/v1`). Custom hosts disable implicit beta headers, so pass `headers: { "anthropic-beta": "..." }` if a model requires them.
* Increase `timeoutSeconds` on the provider block when calling slower reasoning models.

## Troubleshooting

| You see                        | Cause                                                                     | Fix                                                                                              |
| ------------------------------ | ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `401 invalid_api_key`          | Background Gateway did not load `HEYELY_API_KEY`                          | Save it in `~/.openclaw/.env` and restart the Gateway                                            |
| Model missing from list        | Only added as an alias without a provider `models` entry                  | Add a full entry under `models.providers.heyely.models`                                          |
| Model refuses to switch        | Invalid JSON5 caused OpenClaw to keep the last valid config               | Run `openclaw doctor`, repair the config, and recheck                                            |
| `404 model_not_found`          | `id` does not match HeyEly's catalog                                      | Copy the exact ID from the Models page                                                           |
| `402 insufficient_credit`      | No credit remaining on the account                                        | [Add credit](https://heyely.si/credit?step=add)                                                                   |
| `402 free_credit_not_eligible` | Account holds only free credit and this model or request does not qualify | Choose an eligible open-weight text model, lower `max_tokens`, or [add credit](https://heyely.si/credit?step=add) |
| `402 key_limit_reached`        | This API key hit its dollar cap                                           | Raise the cap in Developers or swap keys                                                         |
