Skip to content
DocsStar33Playground

rax keys

ReferenceLast updated 2026-12-02 · 8c7937357Quickstart

Save a provider API key once, then run rax from any folder without exporting it. Part of the CLI reference.

Terminal window
rax keys set <provider>
rax keys list
rax 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.

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:

Terminal window
rax keys set anthropic # hidden prompt
pbpaste | rax keys set openai # from the clipboard (macOS)
rax keys set groq < ~/groq-key.txt # from a file

Output shows masks only, never a key. A key shorter than 12 characters is shown as ••••.

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.
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.

For rax run, rax serve and rax playground, in order:

  1. The provider’s environment variable, for example ANTHROPIC_API_KEY.
  2. The key saved with rax keys set <provider>. The command prints a notice such as Using stored anthropic key ••••a1b2 when it uses one (on stderr for rax run and rax 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 anthropic

If 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.

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.

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-agents
Node 22.5+npm install reactive-agents

Get notified on new releases

Release notes, about once a month.