Gateways
A gateway is a named LLM endpoint an agent can use instead of its own login: a company proxy, a hosted service such as OpenRouter, a local model server, or a cloud switch (Bedrock, Vertex). You add it once to a profile. aide keeps the key encrypted, writes the endpoint into each agent’s config, and uses it only for the agents you choose.
Gateways work with claude, pi, omp, opencode and codex.
This page covers the usual flow. Every flag and field is in the Gateways section of the configuration reference and under aide gateway in the CLI reference.
Add a gateway once
aide gateway add corp --url https://gateway.example.com --profile work
aide asks for the key with hidden input. Then it:
- Encrypts the key into the profile’s secret store.
- Saves the gateway under
gateways:in the profile. - Fetches the model list from the gateway and writes an
aide-corpprovider entry into the config of each agent the gateway serves.
No flag takes the key itself, so the key never lands in shell history. To skip the prompt, read the key from a password manager or from an environment variable:
op read op://Eng/Gateway/credential | aide gateway add corp --url https://gateway.example.com --key-stdin
aide gateway add corp --url https://gateway.example.com --from-env=CORP_GATEWAY_TOKEN
A built-in preset supplies the URL and wire protocol, so it needs only a key:
aide gateway add openrouter-anthropic --from-env --profile work
By default a custom gateway serves all five agents. Pass --agents to limit
it, for example --agents claude,pi. Presets, keyless local servers and the
Bedrock and Vertex switches are described under
Kinds and presets.
Choose which agent uses it
Adding a gateway does not change how your launches authenticate. aide never selects a gateway by itself, even when only one exists. You choose, per agent:
aide gateway use corp --agent claude --profile work
This saves the choice in the profile’s gateway_choice:. To make the choice
for one repository only, add --repo:
aide gateway use corp --agent claude --repo
You can also choose while adding: --default-for claude makes the new
gateway the choice for that agent, and --default does so for every agent
it serves.
claude and codex take exactly one endpoint, so they need a choice. If
gateways are marked for one of them and no choice is saved, a launch on a
terminal shows a picker with nothing preselected. In a script the launch
stops with exit code 78 and prints the commands that resolve it, so a
launch never moves to another billing account without you. pi, omp and
opencode list every gateway in their own model menu; the choice only
decides which one they start on.
The full order aide follows is under Choosing a gateway. See also The picker and Exit code 78.
Opt out or switch for one launch
aide --gateway none # this launch uses the agent's own login
aide --gateway corp # this launch uses corp
--gateway applies to that run only and never changes the saved choice. To
save the agent’s own login as the choice, use none as the name:
aide gateway use none --agent claude
aide gateway use --agent claude --unset removes the saved choice.
Where the key is stored
The key lives in an age-encrypted secret store under
~/.config/aide/secrets/, by default the profile’s own store, under the key
name corp_token. The profile file holds only the store and key names:
gateways:
corp:
url: https://gateway.example.com
api: anthropic-messages
store: work
key: corp_token
gateway_choice:
claude: corp
Agent config files name a variable, never the key. At launch aide decrypts
the key in memory and passes it to the agent as AIDE_GW_CORP_KEY (for
claude, as the variables Claude Code reads). A gateway key that you
exported in your shell does not reach an agent; only a gateway you chose
does. See What each agent gets,
Safety rules and Secrets.
Rotate the key
aide gateway edit corp --rotate-token
This asks for the new key, replaces the stored one and syncs the models
again. --token-stdin and --token-env read the new key without a prompt.
Running aide gateway add again with the same name and URL also replaces
the key.
To change who can decrypt the store, rotate its age recipients with aide secrets rotate.
Inspect, refresh and remove
aide gateway list # URL, store, key name, cache age, chosen agents
aide gateway sync corp # fetch the model list now
aide gateway remove corp # delete the gateway, its cache and agent entries
list never prints a key. A launch refreshes the model list by itself when
the cache is older than the gateway’s refresh interval; see
Refresh at launch. remove also
deletes the key unless you pass --keep-secret, and clears any choice that
named the gateway.
Repository preferences
aide project set --gateway corp --agent claude saves the same
per-repository choice as aide gateway use --repo. Preferences are local to
your machine and are not written to .aide.yaml. See
aide project.