Connect Your Coding Agents in One Command
Run one command to point Claude Code, Claude Desktop, Codex, OpenCode, Grok CLI, OpenClaw and Hermes Agent at GreenTokens, with backups and a one-step undo.
What you'll need
- A GreenTokens account with some balance. Sign in and top up from the Billing page.
- At least one supported app installed, or about to be: the script can also prepare an app's settings in advance.
- A terminal: Terminal on macOS, any shell on Linux, PowerShell on Windows.
What you'll end up with
Your coding agents sending their requests through GreenTokens with your key, and a backup of every file that changed.
Every coding agent keeps its settings somewhere different: a JSON file for Claude Code, TOML for Codex and Grok CLI, YAML for Hermes, a settings profile for Claude Desktop. The GreenTokens setup script knows where each one lives. You pick the apps, confirm each file, paste your key once, and it makes the changes our client docs describe.
Create an API key
Open the API Keys page and create a key for your coding tools, for example "laptop agents". Copy it: it starts with sk-gt- and is shown only once.
Set a spend limit
Agents can use a lot of tokens in a long session. A daily spend limit on this key keeps a runaway session within a budget you choose.
Run the setup script
Open a terminal and run the command for your system. On macOS and Linux:
curl -fsSL https://www.greentokens.io/setup.sh | bashOn Windows, in PowerShell:
irm https://www.greentokens.io/setup.ps1 | iexPrefer to read a script before running it? Open setup.sh or setup.ps1 in your browser: each is one plain-text file, with comments explaining every step.
Pick your apps
Choose 1 to connect apps. The script lists every app it supports and marks the ones it found on your computer:
Which apps should use GreenTokens?
1) Claude Code found
2) Claude Desktop found
3) Codex CLI found
4) OpenCode not found
5) Grok CLI not found
6) OpenClaw not found
7) Hermes Agent found
Type the numbers (for example: 1 3), "all", or press Enter for the found ones [1 2 3 7]:Press Enter to set up everything it found, or type the numbers you want. Claude Desktop is listed on macOS and Windows only.
Confirm each file
For each app, the script shows the file it's about to change and asks whether it's the right one. Press Enter to accept it. If you keep the app's settings somewhere else, answer n and type the path; press Enter on an empty path to skip that app.
Codex, OpenCode, Grok CLI, OpenClaw and Hermes read your key from a GREENTOKENS_API_KEY environment variable. On macOS and Linux the script saves it in your shell's startup file, such as ~/.zshrc, and asks you to confirm that file too. On Windows it saves it as a user environment variable.
Paste your key
Paste the key you created earlier. It stays hidden as you type. The script checks it with a token-counting request, which is free and never billed, so a mistyped key is caught before anything changes.
Finish up in each app
The script then updates each app and ends with a short list of what to do next. Most apps need nothing more than a fresh start:
| App | What changes | What to do next |
|---|---|---|
| Claude Code | GreenTokens variables in settings.json | Start a new session with claude |
| Claude Desktop | A settings profile (macOS) or user policy (Windows) | Approve the profile in System Settings on macOS, or the administrator prompt on Windows; restart the app and pick the third-party option |
| Codex CLI | A GreenTokens provider in config.toml | Open a new terminal and run codex |
| OpenCode | A GreenTokens provider in opencode.json | Open a new terminal and run opencode |
| Grok CLI | GreenTokens models in config.toml | Open a new terminal and run grok |
| OpenClaw | A GreenTokens provider, set with openclaw config | Open a new terminal |
| Hermes Agent | The model section of config.yaml, and .env | Open a new terminal and run hermes |
Before changing a file, the script saves a copy next to it, named like settings.json.backup-20260928-101500. Only the GreenTokens parts change; your other settings stay as they were.
Undo or change your key
- To undo, run the same command and choose 2, Remove GreenTokens settings. It removes what it added and offers to delete the saved key.
- To switch to a new key, run the command again, choose 1 and paste the new key. It replaces the old one everywhere.
- The apps' previous default models aren't restored automatically. Copy them back from the backup files if you want them.
If something doesn't work
- "Couldn't update … it couldn't be read as JSON": the file has comments or isn't valid JSON, so the script left it alone. Add the settings by hand from the app's client docs.
- An app still uses its old provider: open a new terminal window. Terminals that were already open don't see the new GREENTOKENS_API_KEY.
- On Linux, Claude Code and OpenCode setup needs python3 to edit their JSON files. Install it and run the script again.
- Claude Desktop on Windows reports it's managed by an administrator: your organisation's policy takes precedence, and the script can't change it.
More guides
- Cut Your Claude Code BillRun Claude Code through GreenTokens, point each model slot at the right Claude model, cap spending with a dedicated key, and keep sessions lean.
- Switch to GreenTokens in 5 MinutesMove an app that uses the OpenAI or Anthropic SDK onto GreenTokens by changing the base URL and key, then test it and roll it out safely.