LLM gateways for coding agents
An LLM gateway is a service that forwards model requests to providers, and an Integration points your coding agents at it.
An LLM gateway is a service that forwards model requests to providers, and an Integration
points your coding agents at it. You declare the gateway’s address and key once. Ringleader then
configures the agents that support it, the same way on every workstation the Integration
reaches. For any other agent, an httpProxy Integration keeps the key off the workstation.
To connect a gateway, follow Connect a coding agent to an LLM gateway. Supported agents says which agents an Integration configures.
Integration defaults on every workstation
An llm Integration writes up to three things to every workstation it reaches, whichever
agents the workstation has:
- Environment variables for Anthropic’s protocol.
ANTHROPIC_BASE_URLholds the gateway’s address.ANTHROPIC_API_KEYholds the key. For LiteLLM, Bifrost andcustom, so doesANTHROPIC_AUTH_TOKEN. OpenRouter sets it to an empty string on purpose. Withsource: ringleader, neither variable holds a key. Any program that speaks that protocol reads them, not only a coding agent. - An endpoint file.
/etc/ringleader/integrations/<name>.jsonnames the vendor, the address and the variables the Integration set. A program finds the gateway there. - A provider file.
/etc/ringleader/pi/<name>.jsonholds the gateway’s OpenAI-compatible address, the one place that address is published. It exists for a named vendor, and not forvendor: customorsource: ringleader. pi and OpenCode read it, and so can any agent that takes a base URL.
The endpoint files lists the fields of both files. An agent that has its own configuration file gets more, as the next sections describe.
Gateway vendors and models
Ringleader knows each supported vendor’s address, the protocols it speaks, and the
environment variables and configuration files each agent needs. So you name the vendor and
never write ANTHROPIC_BASE_URL. For OpenRouter, you also never have to know which of
Claude Code’s two authentication variables must be set to an empty string. The
Integration reference lists the four
vendors, what each configures, and the checks on a self-hosted endpoint’s url. If your
gateway is LiteLLM or Bifrost, name it instead of using custom. Ringleader then works out
the OpenAI-compatible address as well as the Anthropic one.
model is the gateway’s own name for the model. Ringleader writes it unchanged into the
settings of Codex, pi and OpenCode. The
Integration fields says which vendors
accept it. Without it, OpenRouter uses ~openai/gpt-latest. Your organization’s
policy (Policy and OrgPolicy) can limit which models you can name, and a model
outside that list is refused when you apply. The policy judges only the model you write in
model, not OpenRouter’s default.
Agent support by vendor
The table says what each supported agent gets from an llm Integration, by vendor. A cell that
says “provider” means the agent’s own configuration file lists the gateway as a model provider.
| Agent | openrouter | litellm and bifrost | custom | source: ringleader |
|---|---|---|---|---|
| Claude Code | Environment variables. | Environment variables. | Environment variables. | Environment variables and apiKeyHelper, and no key. |
| Codex | A provider, with model or ~openai/gpt-latest. | A provider, with a model only when you set model. | Nothing. | Nothing. |
| OpenCode | A provider, with model or ~openai/gpt-latest. | A provider that lists no models unless you set model. | Nothing. | Nothing. |
| pi | A provider, with model or ~openai/gpt-latest. | A provider, only when you set model. | Nothing. | Nothing. |
| Cursor CLI | Nothing. | Nothing. | Nothing. | Nothing. |
| Antigravity CLI | Nothing. | Nothing. | Nothing. | Nothing. |
Where Codex is configured, both the Codex CLI in a terminal and the Codex extension in the
browser IDE use it. They read the same ~/.codex/config.toml, so there is no second setting
to write for the editor.
Codex gets its provider even on a workstation where Codex is not installed. OpenCode and pi
get theirs only on a workstation that has the opencode or pi devtool. To configure an agent
the table lists as “Nothing”, see
Run your own coding agent in Ringleader.
A toolconfig you write for an agent can displace the Integration’s. Toolconfigs merge by tool, and
a toolconfig from a WorkstationConfig you write replaces the Integration’s for the same tool,
rather than adding to it. A codex toolconfig of your own drops the Integration’s provider
block, and a claude-code toolconfig of your own drops its apiKeyHelper. For pi and OpenCode,
the Integration’s provider is merged into your toolconfig, and yours wins only when it names a
provider of the same name. To keep the Integration’s block, copy it into your toolconfig.
Provider configuration by agent
Codex, pi and OpenCode each read the gateway from their own configuration file. Ringleader writes that entry in the agent’s own form, as the next two sections describe.
The Codex provider
On every workstation the Integration reaches, the Integration adds a codex toolconfig. It sets
model_provider to the vendor’s name (openrouter, litellm or bifrost) and writes a
[model_providers.<vendor>] table in ~/.codex/config.toml. The table holds the gateway’s
OpenAI-compatible address as base_url, wire_api = "responses", and env_key, the name of the
vendor’s key variable, so the file holds no key. model is set to the Integration’s model,
or to OpenRouter’s default, and is left out for LiteLLM and Bifrost when you set none.
A codex toolconfig of your own replaces this one whole, as the previous section describes. To
declare the provider yourself, with no Integration, write the same keys in the toolconfig’s
configToml.
The pi and OpenCode providers
On a workstation with the pi devtool, the
Integration adds a provider to pi’s ~/.pi/agent/models.json. On a workstation with the
opencode devtool, it adds the same provider
under provider in ~/.config/opencode/opencode.json. The provider is named after the vendor:
openrouter, litellm or bifrost.
The provider points at the gateway’s OpenAI-compatible address. It offers one model, the one in
model, or OpenRouter’s default when model is not set. Both tools read the key from the
vendor’s environment variable (OPENROUTER_API_KEY, LITELLM_API_KEY or BIFROST_API_KEY),
so neither file holds the key.
A LiteLLM or Bifrost Integration without model gives pi no provider, because pi drops a provider
that lists no models. OpenCode gets the provider with no models listed. Set model for both. An Integration with vendor: custom or
source: ringleader gives neither tool a provider.
Neither tool switches to the new provider by itself. In pi, pick it with /model, or set
defaultProvider and defaultModel in a
pi toolconfig. In OpenCode, set model to
<vendor>/<model> in an
opencode toolconfig.
Two rules decide what happens when a provider of the same name already exists:
- A provider of that name in your
pioropencodetoolconfig wins over the Integration’s. - An entry of that name that you added by hand to
models.jsonoropencode.jsonis replaced. From then on Ringleader owns it, so it is removed when the Integration stops applying.
To declare a gateway for pi yourself, with no Integration, see Model providers.
Gateway key handling
With source: external, Ringleader delivers the gateway’s key to every workstation the
Integration reaches. Secrets on the workstation
says what that exposes. To keep the key off the workstation, see
Keep the gateway key off the workstation.
Every workstation owner must be able to read the Secret
With source: external and an endpoint.credentialRef, the owner of each workstation the
Integration reaches must be able to read the Secret, as
Places that name a Secret
lists. An owner who cannot sees two things, and neither says why. Their workstation is set up
with no endpoint, and their own stop, start or edit of it can be refused.
Give each owner access with rl secret share <secret> -n <namespace> --with <subject>, as
rl secret share <name> describes. When
you apply an Integration that reaches workstations you do not own, rl apply -f prints a note
with this command.
Keep the gateway key off the workstation
Two routes keep a key off the workstation. Route one holds the gateway’s key with Ringleader and
works for Claude Code only. Route two adds the key as requests leave the workstation. It works for
any agent that calls a fixed host, including the agents the table above lists as “Nothing”.
Use route two for Codex, pi and OpenCode when the key must stay off the workstation, because
source: ringleader does not configure them.
Gateway keys held by Ringleader for Claude Code
With source: ringleader, the key stays with Ringleader. Claude Code on each workstation calls an
endpoint that your Ringleader deployment runs. The endpoint adds the key to each request and
sends it on to the provider. It also counts the tokens of each request, which
rl usage reports.
Each workstation the Integration reaches then gets three settings and no key:
ANTHROPIC_BASE_URL, set to this Integration’s address on your deployment’s endpoint.ANTHROPIC_AUTH_TOKEN, set to an empty string, so that Claude Code uses the endpoint.- Claude Code’s
apiKeyHelpersetting, set toringleader-agent auth token. Claude Code runs it to get the workstation’s own short-lived token, which the endpoint accepts in place of a key.
Codex, pi and OpenCode are not configured with this source. Codex reads its key once, when it starts. The workstation’s token can expire while Codex is still running. Neither pi nor OpenCode gets a provider, because this source names no model.
Name the provider under llm.providers, beside endpoint, with the Secret that holds its key:
apiVersion: workstations.ringleader.dev/v1
kind: Integration
metadata:
name: claude
namespace: acme
spec:
type: llm
selector:
matchLabels:
team: platform
llm:
endpoint:
source: ringleader
providers:
anthropic:
credentialRef:
name: anthropic # a Secret in this namespace
key: tokenThe Integration reference lists the three providers, says to name exactly one, and lists the fields this source refuses.
You must be able to read the Secret to apply the Integration. The owners of the workstations it reaches need no access to it, as Places that name a Secret lists. On each request, the endpoint checks four things:
- The workstation’s token still belongs to a live workstation.
- The workstation is allowed to use Integrations at all.
- The Integration still reaches the workstation.
- The Integration’s author, the person who first applied it, can still read the Secret.
If a check fails, the endpoint refuses the request. When the author loses access, or the Secret is deleted, requests fail.
Because the key never reaches a workstation, llm.providers.<provider>.credentialRef can name
a Ringleader-only Secret, created with rl secret create --ringleader-only. Nobody can read that
Secret’s value back, its owner included.
Ringleader-only Secrets
lists what else sets it apart.
Your operator may limit which providers you can name, and your organization’s
policy can too. If your deployment
does not run the endpoint, the Integration configures no workstation, and its status message
says so.
Keys added to requests for any agent
An httpProxy Integration adds a key to requests for the hosts you name, as they leave the
workstation. Most agents refuse to start without a key. So give the agent a placeholder key, and
the Integration replaces it on the way out. The real key stays in a Secret.
Injected credentials says where
the key is added, and which workstations it works on.
This example is for an agent that reads LLM_API_KEY and calls llm.acme.example. Replace both
with the variable and the host your agent uses:
apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
name: agent-environment
namespace: acme
spec:
selector:
matchLabels:
role: agent
environment:
LLM_API_KEY: not-the-real-key
---
apiVersion: workstations.ringleader.dev/v1
kind: Integration
metadata:
name: agent-gateway
namespace: acme
spec:
type: httpProxy
selector:
matchLabels:
role: agent
httpProxy:
rules:
- host: llm.acme.example
inject:
header: Authorization
value: "Bearer ${secret:llm-gateway/token}"Codex, pi and OpenCode send the placeholder to their default provider’s fixed host. For any other
host, first write a provider in the agent’s toolconfig. Codex also needs the placeholder passed to
codex login --with-api-key.
The agent has to trust the certificate Ringleader uses to add the key. Ringleader sets the usual certificate variables, as Effects of injection on a workstation describes. Run your own coding agent in Ringleader shows the whole setup for an agent Ringleader does not configure.
Override an Integration for Claude Code
If a vendor’s settings do not suit you, set the variables yourself. The configuration Ringleader
generates from an Integration has priority -100. A WorkstationConfig wins over it at any priority
above -100. The generated configuration still applies over your own workstation’s
spec.environment, which is the base every layer applies over, as
Layer merge order
explains. So setting ANTHROPIC_BASE_URL in your workstation’s spec.environment does
not override an administrator’s Integration:
# does NOT work: the Integration's configuration is applied over spec.environment
apiVersion: workstations.ringleader.dev/v1
kind: Workstation
metadata:
name: my-agent-box
namespace: acme
spec:
environment:
ANTHROPIC_BASE_URL: https://my-own-gateway.example.comTwo ways do work. To override for every workstation a layer reaches, write a WorkstationConfig of your own. Any priority of 0 or more puts it above the generated configuration:
# works: your own configuration outranks the generated one
apiVersion: workstations.ringleader.dev/v1
kind: WorkstationConfig
metadata:
name: my-llm-override
namespace: acme
spec:
selector:
ownerScope: true
environment:
ANTHROPIC_BASE_URL: https://my-own-gateway.example.com
ANTHROPIC_API_KEY: ${secret:my-gateway/token}
ANTHROPIC_AUTH_TOKEN: ${secret:my-gateway/token}A litellm, bifrost or custom Integration also sets ANTHROPIC_AUTH_TOKEN to its key.
Set it in the override too, to the new key or to an empty string. An OpenRouter Integration
already sets it to an empty string, so leave it out.
To override on one workstation, write the variables in that workstation’s
spec.environmentOverrides instead. They win over every configuration, at any priority:
apiVersion: workstations.ringleader.dev/v1
kind: Workstation
metadata:
name: my-agent-box
namespace: acme
spec:
environmentOverrides:
ANTHROPIC_BASE_URL: https://my-own-gateway.example.com
ANTHROPIC_API_KEY: ${secret:my-gateway/token}A configuration can block an override. If a configuration lists a variable in its own
spec.lockedEnvironment, the workstation keeps that configuration’s value. Ringleader reports
the blocked override and does not refuse it. rl workstation get-resolved-configuration names
it.
These overrides cover Claude Code, and any other program that reads the Anthropic variables. Codex, pi and OpenCode keep pointing at the old gateway. To change where they point, write a toolconfig of your own, as Agent support by vendor describes. Check what the workstation actually gets:
rl workstation get-resolved-configuration my-agent-box -n acmeNext steps
- Supported agents says what each agent gets from an Integration.
- Integration behavior says which workstations an Integration reaches, what it generates, and what happens when it stops applying.
- Integration lists the fields, the vendors and the endpoint files.
- MCP servers for coding agents registers an MCP server beside the gateway.
- Injected credentials adds a key to
requests for hosts you name, with
type: httpProxy. - Anthropic federation gets an Anthropic token without a key in a Secret.