rax keys
Save a provider API key once, then run rax from any folder without exporting it. Part of the CLI reference.
rax keys set <provider>rax keys listrax keys remove <provider>rax run, rax serve and rax playground use a saved key when the provider’s environment variable is not set. The environment variable always wins. Cortex Settings · Providers saves keys to the same store, so a key saved in either place works in both.
Commands
Section titled “Commands”| Command | What it does |
|---|---|
rax keys set <provider> |
Saves a key for <provider>. The key is read from stdin when stdin is piped, otherwise from a hidden prompt (the input is not echoed). Saving again replaces the old key. If the provider’s environment variable is set in the current shell, set warns that the variable wins over the saved key. |
rax keys list |
Prints one row per provider: PROVIDER, SAVED KEY (a mask such as ••••a1b2, - when none, or unreadable), IN USE and UPDATED. Ends with the store directory. Other ids in the store (for example a web-search key saved in Cortex) are listed too. |
rax keys remove <provider> |
Deletes the saved key. Removing a key that is not saved is not an error. |
rax keys set never accepts the key as an argument: a key on the command line stays in your shell history and is visible to other users in ps. Pass it on stdin or type it at the prompt:
rax keys set anthropic # hidden promptpbpaste | rax keys set openai # from the clipboard (macOS)rax keys set groq < ~/groq-key.txt # from a fileOutput shows masks only, never a key. A key shorter than 12 characters is shown as ••••.
The IN USE column
Section titled “The IN USE column”IN USE says where the key comes from for that provider in the current shell:
| Value | Meaning |
|---|---|
env ANTHROPIC_API_KEY |
The environment variable is set; it is used, and a saved key is ignored. |
saved key |
No environment variable; the saved key is used. |
none |
Neither: commands that need a key for this provider fail with a missing-key error. |
Providers
Section titled “Providers”| Provider | Environment variable |
|---|---|
anthropic |
ANTHROPIC_API_KEY |
openai |
OPENAI_API_KEY |
gemini |
GOOGLE_API_KEY |
groq |
GROQ_API_KEY |
xai |
XAI_API_KEY |
litellm |
LITELLM_API_KEY (optional for LiteLLM) |
ollama |
OLLAMA_API_KEY (only for a remote Ollama endpoint) |
A saved Ollama key is sent only to an https endpoint that is not loopback. A local Ollama needs no key.
How rax picks a key
Section titled “How rax picks a key”For rax run, rax serve and rax playground, in order:
- The provider’s environment variable, for example
ANTHROPIC_API_KEY. - The key saved with
rax keys set <provider>. The command prints a notice such asUsing stored anthropic key ••••a1b2when it uses one (on stderr forrax runandrax serve).
When a provider that needs a key (anthropic, openai, gemini, groq, xai) has neither, rax run and rax serve exit with code 2 before the agent starts and name both fixes:
Missing API key: ANTHROPIC_API_KEY is not set and no anthropic key is stored.Set it with: export ANTHROPIC_API_KEY=<your-key> or save it once: rax keys set anthropicIf a saved key cannot be decrypted, the message says so; save the key again. rax playground prints the same message as a warning and starts anyway.
Builder code does not read the store unless you ask it to. Pass .withProvider(provider, { useStoredKey: true }): an explicit apiKey wins, then the environment variable, then the stored key, read once when .withProvider() runs. See Provider keys. To read the key yourself, resolveProviderKey(provider) from @reactive-agents/llm-provider applies the same environment-then-store order.
Where keys are stored
Section titled “Where keys are stored”| Item | Value |
|---|---|
| Directory | ~/.reactive-agents/keys. Set REACTIVE_AGENTS_KEYS_DIR to use another directory. |
| Files | secret.key (32 random bytes) and provider-keys.json (one AES-256-GCM sealed entry per provider), both mode 0600 |
Do not replace or delete secret.key while keys are saved: every saved key would become unreadable. To start over, delete both files and save your keys again.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 |
Done. Also rax keys --help. |
1 |
The store could not be read or written. |
2 |
Usage error: no subcommand, an unknown subcommand or provider, a key passed as an argument, or an empty key. |
Install
Bun (recommended)bun add reactive-agentsNode 22.5+npm install reactive-agentsGet notified on new releases
Release notes, about once a month.