Skip to content

Crush

Add Tokens to Charm's Crush as an openai-compat provider, using the new crushrc format or the older crush.json the Tokens CLI writes, then pick large and small models.

Works withCrushTerminal
On this page

Crush is Charm's open-source terminal coding agent. It connects to Tokens as an openai-compat provider, sending chat completions to https://tokens.bd/v1.

Quick setup with the Tokens CLI#

The Tokens CLI signs you in through the browser, creates a key, lets you choose a default model and registers Tokens in Crush. It needs Node 18 or newer.

curl -fsSL https://tokens.bd/cli/tokens.mjs -o tokens.mjs && node tokens.mjs setup --base-url https://tokens.bd --agents crush

The CLI merges a tokens provider into ~/.config/crush/crush.json and backs up the old file as crush.json.tokens-backup-<timestamp>. What it writes:

/.config/crush/crush.json written by the Tokens CLI
{
  "$schema": "https://charm.land/crush.json",
  "providers": {
    "tokens": {
      "name": "Tokens",
      "type": "openai-compat",
      "base_url": "https://tokens.bd/v1",
      "api_key": "tok_live_your_key",
      "models": [
        {
          "id": "deepseek/deepseek-v4.1-flash",
          "name": "deepseek/deepseek-v4.1-flash",
          "context_window": 128000,
          "default_max_tokens": 8192
        }
      ]
    }
  }
}

Three things to know about it:

  • The key is stored in the file. Keep this file out of any repository.
  • context_window and default_max_tokens are placeholders. Edit them to the real values from the model's page in /models.
  • Crush now calls crush.json deprecated, though still supported. It works today; if you'd rather use the current format, set Tokens up in crushrc as below and remove the tokens provider from crush.json so you don't maintain it in two places.

After setup, open Crush and choose the Tokens model from the model menu (Ctrl+P).

Configure crushrc manually#

Install Crush if you haven't:

bash
brew install charmbracelet/tap/crush
# or
npm install -g @charmland/crush

On Windows, winget install charmbracelet.crush or scoop install crush also work.

Export your key (API keys explains how to create one with a spend cap):

export TOKENS_API_KEY="tok_live_your_key"

A crushrc is Bash with Crush builtins. Crush looks for one in this order, highest priority first:

  1. ./.crushrc in the project
  2. ./crushrc in the project
  3. ~/.config/crush/crushrc (%USERPROFILE%\.config\crush\crushrc on Windows)

CRUSH_GLOBAL_CONFIG and CRUSH_GLOBAL_DATA override the global locations.

/.config/crush/crushrc
provider add tokens --type openai-compat \
  --name "Tokens" \
  --base-url "https://tokens.bd/v1" \
  --api-key "${TOKENS_API_KEY:?set TOKENS_API_KEY}"

model add tokens/deepseek/deepseek-v4.1-flash \
  --name "DeepSeek V4.1 Flash" \
  --context-window 128000 \
  --default-max-tokens 8192

model large tokens/deepseek/deepseek-v4.1-flash
model small tokens/deepseek/deepseek-v4.1-flash

${TOKENS_API_KEY:?...} makes Crush stop with a clear message if the variable isn't set, instead of sending an empty key. Replace the two numbers with the model's real limits.

Use openai-compat, not openai. Crush's docs reserve the openai type for OpenAI itself.

Let Crush discover models#

Instead of model add, you can add --discover-models true to provider add. Crush then merges in the models your key can use from GET /v1/models. It also discovers automatically when an openai-compat provider has no models defined.

Switch models#

model large sets the main model and model small the one Crush uses for lighter work. Point them at any id you've added, then restart Crush. Inside a session, Ctrl+P opens the menu with model switching.

To add a model, repeat model add tokens/<model id> with an exact id from /models or node tokens.mjs models. In crush.json, add another object to the models array. Choosing a model can help you pick a large and a small model.

Verify it works#

bash
crush models

Your Tokens models should be listed in <provider>/<id> form. Then start crush, send a short prompt, and check that it appears in Usage analytics on the dashboard. Logs are in ./.crush/logs/crush.log in the project folder.

Troubleshooting#

The model id gets split wrongly. model add <provider>/<id> separates the provider from the id, and Crush's docs don't say how it handles an id that itself contains a slash, like tokens/deepseek/deepseek-v4.1-flash. If the model doesn't show in crush models, remove the model add lines and use --discover-models true instead, then reference the id exactly as crush models prints it.

401 missing_api_key. The variable isn't set where Crush runs. With the :? form above, Crush stops with "set TOKENS_API_KEY" instead.

Changes don't take effect. A project .crushrc or crushrc outranks your global file. Check the project folder.

404 model_not_found or 403 model_not_allowed_on_key. The id is misspelled, or the key's allow-list excludes the model. Allow-lists can't be edited, so create a new key if you need a different set.

The Tokens CLI skipped Crush. Your crush.json has comments or invalid JSON, so the CLI didn't touch it. Use the crushrc setup above, or copy the snippet from /dashboard/connect.

Config files run as code

A crushrc is executed as shell, and $(...) inside crush.json runs when Crush loads it. Only use config files you wrote or have read, especially project-level ones in cloned repositories.

For other error codes, see Troubleshooting.

Was this page helpful?

Still stuck? Open a support ticket

Need help configuring your agent?

Test your connection with the connection tester, or create an API key.