Skip to content

Sign-in, API keys, and named connections

Available on the next release channel.

By default every agent uses its own login, for example a Claude.ai or ChatGPT subscription. Nori can also keep API keys for you and pass them to the agents you choose, or send an agent to a gateway through a named API connection.

Terminal window
nori auth # table: agent, status, credential, source
nori auth --json # the full report, for scripts

Each built-in agent shows signed in, signed out, or unknown, with the credential it will use and where it comes from (an environment variable, the agent’s own login files, or a saved key). unknown means Nori cannot check that agent’s own login, for example Hermes Agent.

Terminal window
nori auth set-key openai # anthropic, openai, google, xai, or cursor
nori auth remove-key openai

At a terminal the key is read hidden: only its public prefix shows, such as sk-proj-****. Piped input is read silently. The key is never taken as an argument. A key that looks like another provider’s prints a warning but is saved.

Keys are saved per provider, so one OpenAI key serves Codex, OpenCode, and Pi. Hermes Agent takes no saved key.

NORI_CREDENTIALS_STORE Where keys live
unset or file $NORI_HOME/credentials.json, readable only by you
keyring one OS keyring item, Nori Credentials; no file. macOS may prompt at each launch

A saved key does nothing until you opt an agent in:

Terminal window
nori auth prefer-api-key codex # use the saved key from its next launch
nori auth prefer-login codex # back to the agent's own login (default)

In the TUI, /api-key opens the same choice for the current agent. Changes apply the next time the agent starts, for example after /new.

When Claude Code or Codex is signed in with a subscription, opting in changes who you are billed: usage goes to the API account instead. Nori warns and asks once, then remembers your answer. Without a terminal, or with --json, the command fails with confirmation_required until you pass --yes.

The choice is saved in config.toml:

[auth.codex]
prefer_api_key = true
api_billing_confirmed = true

Even for an opted-in agent, Nori skips a saved key when the agent already has a key variable for that provider set, when a base URL variable such as OPENAI_BASE_URL points elsewhere, or when the agent is bound to a named connection.

A named connection sends an agent to one endpoint, protocol, and model, with the key read from an environment variable. Codex and Pi support it.

[agent_token_providers]
codex = "lab"
[[token_providers]]
name = "lab"
preset = "custom"
protocol = "openai-responses"
base_url = "https://gateway.example.com/v1"
env_key = "LAB_MODEL_KEY"
model = "lab/model-a"
Key Values
preset custom, openrouter, fireworks, subconscious, or cloudflare
protocol openai-responses, openai-completions, or anthropic-messages
base_url HTTP(S) URL with no credentials, query, or fragment
env_key name of the variable that holds the key; never the key itself
model exact model ID; wins over [default_models] for that agent

Steps:

  1. Add the connection and the binding to ~/.nori/cli/config.toml. Use the canonical agent slug (codex, pi) as the binding key.
  2. Set the key variable in the environment that starts Nori. For nori host, that is the host’s environment.
  3. Run nori --agent codex, nori exec --agent codex "...", or nori host new --agent codex.
  • Codex needs openai-responses.
  • A custom preset uses exactly its declared protocol. The other presets try the declared protocol first, then other protocols the gateway supports. cloudflare accepts only openai-completions.
  • For Pi, Nori writes a private Pi profile per launch. The model ID in /model is <name>/<model>, for example lab/model-a.
  • A missing or empty key variable stops the launch, even when the agent’s own login would work. Remove the binding to go back to the agent’s usual login and model.
  • Binding any other agent fails before it starts.

Does nori exec see a key I set on its command line? Only when exec runs its own host. When it uses your running nori host, the agent gets the host’s environment. See nori host.

Does this change Nori Cloud sessions? No. Cloud sessions use your organization’s credentials; saved keys are never used there.

this page as markdown: /cli/guides/auth-and-connections.md· index for agents: /llms.txt