# Factory Droid

> Register HeyEly models in Factory Droid using Chat Completions, Responses, or Messages.

Factory's Droid agent reads custom model entries from `~/.factory/settings.json` for both its CLI and desktop app. The example below wires Droid to HeyEly via Chat Completions at `https://heyely.si/v1`.

## Set up

1. Generate a key in [Developers](https://heyely.si/keys) and export it as `HEYELY_API_KEY` in the shell launching Droid.
2. Add a custom model entry to `~/.factory/settings.json` (or `%USERPROFILE%\.factory\settings.json` on Windows).

```json
{
  "customModels": [
    {
      "model": "anthropic/claude-sonnet-5.5",
      "displayName": "HeyEly Claude Sonnet 5.5",
      "baseUrl": "https://heyely.si/v1",
      "apiKey": "${HEYELY_API_KEY}",
      "provider": "generic-chat-completion-api",
      "maxOutputTokens": 128000
    }
  ]
}
```

Droid live-reloads `settings.json`, so no restart is needed. Referencing `${HEYELY_API_KEY}` keeps the actual key out of the JSON file.

Choose the `provider` value matching the API wire format you prefer:

| `provider`                    | Format           | `baseUrl`                          |
| ----------------------------- | ---------------- | ---------------------------------- |
| `generic-chat-completion-api` | Chat Completions | `https://heyely.si/v1`             |
| `openai`                      | Responses        | `https://heyely.si/v1`             |
| `anthropic`                   | Messages         | `https://heyely.si`, without `/v1` |

## Verify

1. Start `droid` and run `/model`. Your entry appears under **Custom models** using its `displayName`.
2. Pick it and send a brief test prompt.
3. Run `/cost` to inspect session metering.
4. Check [Credit and usage](https://heyely.si/usage) to confirm the request shows at the top of **Spend** under your chosen model.

If your custom model does not appear, run `/diagnostics` to view config validation details.

For headless execution via `droid exec`, pass the generated custom model ID: `custom:`, followed by `displayName` with spaces replaced by hyphens, followed by a hyphen and its zero-based array index in `customModels`.

```bash
droid exec --model "custom:HeyEly-Claude-Sonnet-5.5-0" \
  "Reply with exactly: gateway-ok"
```

## Pick a model

* Droid forwards `model` verbatim, including the provider slash.
* Factory formally tests Anthropic and OpenAI models on their native APIs; other catalog models may vary, and Factory recommends models above 30B parameters for reliable agent workflows.
* `maxOutputTokens` controls output length. Add `"noImageSupport": true` for text-only models.
* Changing the order of items in `customModels` shifts the trailing index used by `droid exec`.

## Troubleshooting

| You see                                                            | Cause                                                            | Fix                                                         |
| ------------------------------------------------------------------ | ---------------------------------------------------------------- | ----------------------------------------------------------- |
| Model missing from `/model`                                        | Malformed JSON or omitted required property                      | Validate JSON syntax and run `/diagnostics`                 |
| "Invalid provider"                                                 | Unrecognized `provider` value                                    | Use `generic-chat-completion-api`, `openai`, or `anthropic` |
| `401 missing_api_key` or `401 authentication_error` on `anthropic` | `HEYELY_API_KEY` is missing in Droid's launch shell              | Export the variable and relaunch Droid                      |
| `404` on every request                                             | `baseUrl` includes or omits `/v1` inconsistently with `provider` | Match the URL format table above                            |
| `404 model_not_found`                                              | `model` does not match HeyEly's catalog                          | Copy the exact ID from the Models page                      |
| Custom models blocked                                              | Disabled by organization policy                                  | Ask your admin to allow custom models and HeyEly's base URL |
