# Crush

> Wire Charm's Crush CLI to HeyEly with a clean, keyless crushrc configuration.

Crush (built by Charm) configures custom providers through a `crushrc` script that executes Crush's own setup commands on startup. Using the `openai-compat` provider type targets Chat Completions at `https://heyely.si/v1`.

## Set up

1. Generate an API key in [Developers](https://heyely.si/keys) and export it as `HEYELY_API_KEY`.
2. Add a `crushrc` file inside `~/.config/crush/` (or `%USERPROFILE%\.config\crush\crushrc` on Windows). You can also place `.crushrc` directly inside a project directory and safely commit it since it references the environment variable rather than storing the secret.

```bash
provider add heyely \
  --name HeyEly \
  --type openai-compat \
  --base-url "https://heyely.si/v1" \
  --api-key "${HEYELY_API_KEY:?set HEYELY_API_KEY}"

model add heyely/anthropic/claude-sonnet-5.5 \
  --name "Claude Sonnet 5.5" \
  --context-window 1000000 \
  --default-max-tokens 128000

model large heyely/anthropic/claude-sonnet-5.5
model small heyely/anthropic/claude-sonnet-5.5
```

3. Launch Crush.

Because `crushrc` reads `HEYELY_API_KEY` at runtime, your key never gets written to disk inside the config. Crush separates heavy reasoning (`model large`) from lighter helper tasks (`model small`), so feel free to assign a smaller model to `model small`.

Registering models explicitly with `model add` ensures accurate context window and output token limits. If you prefer automatic catalog discovery for an OpenAI-compatible provider, Crush can query models automatically when none are declared, or you can pass `--discover-models true` to combine discovered entries with your manual declarations (explicit entries always win). See [Crush's configuration guide](https://github.com/charmbracelet/crush/blob/main/docs/config/README.md) for more options.

## Verify

1. Run `crush models` and confirm `heyely/anthropic/claude-sonnet-5.5` appears.
2. Fire off a quick test run:

```bash
crush run -m heyely/anthropic/claude-sonnet-5.5 \
  "Reply with exactly: gateway-ok"
```

3. Open [Credit and usage](https://heyely.si/usage) and look for the request at the top of **Spend** under your selected model.

Need to inspect an error? Run `crush logs --tail 50` to view recent provider responses.

## Pick a model

* Crush parses `provider/model` at the very first slash. For `heyely/anthropic/claude-sonnet-5.5`, `heyely` is the provider and `anthropic/claude-sonnet-5.5` is the model ID sent to HeyEly. Leaving off `heyely/` causes Crush to look for an `anthropic` provider and fail with "model not found".
* Switch models interactively during a session using Ctrl L.
* Always set `--type openai-compat` for HeyEly; the `openai` type is reserved for OpenAI directly.

## Troubleshooting

| You see                        | Cause                                          | Fix                                       |
| ------------------------------ | ---------------------------------------------- | ----------------------------------------- |
| `set HEYELY_API_KEY` on launch | `HEYELY_API_KEY` is unset in the current shell | Export it before launching Crush          |
| `401 invalid_api_key`          | The variable holds an invalid or unrelated key | Export your `sk-df-` key                  |
| "model not found"              | Missing `heyely/` provider prefix              | Prefix the model ID with `heyely/`        |
| Model missing from list        | Not declared or discovered                     | Add a `model add` entry using the full ID |
| `404 model_not_found`          | Catalog ID typo                                | Copy the exact ID from the Models page    |
