# Run your own coding agent in Ringleader

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Install a command-line coding agent on a workstation and give it its API key without storing the key there.


Install a command-line coding agent on a workstation and give it its API key without
storing the key there. You want this for an agent that Ringleader does not configure, such as
Aider, Gemini CLI or Goose, or one you wrote. It also fits Cursor CLI and Antigravity CLI, which
Ringleader installs without configuring. The steps work for an agent that sends its key in a
header over HTTPS to a fixed host. The examples use Gemini CLI, but it is only an example:
replace its package, command, host and header with your agent's.

## Prerequisites

- [Install Ringleader](https://docs-stg.ringleader.dev/install/), with the Ringleader application running.
- A running workstation in the namespace `local` that you own. The examples use a
  workstation named `my-agent-box`; replace it with yours. To create one, follow the
  [Quickstart](https://docs-stg.ringleader.dev/quickstart/) and use your own name. A cloud workstation needs
  an [Edge](https://docs-stg.ringleader.dev/reference/resources/edge/) in its namespace, and these examples do not cover
  it.
- Your agent's package name, the command it provides, and the host, header and variable it
  uses for its API key. The agent's own documentation lists them. The examples use the npm
  package `@google/gemini-cli`, the command `gemini` and the variable `GEMINI_API_KEY`. They
  use the host `generativelanguage.googleapis.com` and the header `x-goog-api-key`, as
  [Gemini CLI](https://github.com/google-gemini/gemini-cli) and the
  [Gemini API](https://aistudio.google.com/docs/api-key) document them.
- The agent's API key, which the examples call `<your-api-key>`.

## Install the agent

A WorkstationConfig installs the agent as a package on every workstation with a label. It
also sets the variable the agent reads for its key to a stand-in value, because the agent
expects one.

1. Add a label that selects the workstation. The examples use `role: agent`:

   ```bash
   rl workstation label my-agent-box role=agent -n local
   ```

2. Save this file as `my-agent.yaml`. Change `role: agent` to your label:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: WorkstationConfig
   metadata:
     name: my-agent
     namespace: local
   spec:
     selector:
       matchLabels:
         role: agent
     devtools:
       - name: nodejs                # installs Node.js 24, which an npm package needs
     packages:
       - type: npm                   # pypi or mise for an agent that is not on npm
         name: "@google/gemini-cli"  # the example agent: replace it with yours
         bin: gemini                 # the command the package must provide
     environment:
       GEMINI_API_KEY: not-the-real-key
   ```

3. Run `rl apply -f my-agent.yaml`. Ringleader then installs the agent on every workstation
   labeled `role: agent`.
4. Wait until the installation finishes:

   ```bash
   rl workstation wait my-agent-box --for condition=Configured --timeout 15m -n local
   ```

`bin` applies to npm only. For a PyPI package, remove it and name the package, as in
`type: pypi`, `name: aider-chat`, and the command `aider`. Ringleader skips any version
published in the last 24 hours, as [Package installation](https://docs-stg.ringleader.dev/workstations/packages-tools-settings/package-installation/)
describes. [Packages and repositories](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/#packages-and-repositories)
lists the package types and their fields.

An agent such as Goose is neither on npm nor on PyPI. Install it with a setup script, as
[Run a setup script](https://docs-stg.ringleader.dev/workstations/packages-tools-settings/scripts-files-services/#run-a-setup-script)
shows.

## Keep the agent's key off the workstation

Ringleader adds the real key to each request as it leaves the workstation, so the agent holds
only the stand-in value. Whenever Ringleader withholds the key, the stand-in reaches the API
instead. It does so, for example, when another person owns the workstation.

1. Store the key in a Secret:

   ```bash
   rl secret create gemini-api-key -n local --from-string token=<your-api-key>
   ```

2. Save this file as `my-agent-key.yaml`. Change `role: agent` to your label, and the host
   and header to your agent's:

   ```yaml
   apiVersion: workstations.ringleader.dev/v1
   kind: Integration
   metadata:
     name: my-agent-key
     namespace: local
   spec:
     type: httpProxy
     selector:
       ownerScope: true
       matchLabels:
         role: agent
     httpProxy:
       rules:
         - host: generativelanguage.googleapis.com
           inject:
             header: x-goog-api-key
             value: "${secret:gemini-api-key/token}"
   ```

3. Run `rl apply -f my-agent-key.yaml`.
4. Wait until your computer's network process holds the new rule:

   ```bash
   rl workstation wait my-agent-box --for=EgressApplied --timeout 5m -n local
   ```

5. Open a shell with `rl shell my-agent-box -n local`.
6. Start the agent with the command from the first task, such as `gemini`. Ringleader adds
   the key to its requests to the host, although the workstation holds only `not-the-real-key`.

Gemini CLI reads `GOOGLE_API_KEY` before `GEMINI_API_KEY`, so do not set both. If the agent asks
how to authenticate, choose its API key option.

Any header name works except `Host`. Text around the Secret reference is kept, so a scheme
prefix such as `Bearer ` goes in the value. Ringleader replaces a header of that name
that the agent sent. For an agent that takes Basic authentication, see
[Inject a key for a service that takes Basic authentication](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/#inject-a-key-for-a-service-that-takes-basic-authentication).

Ringleader decrypts the traffic to a host a rule names. It installs its certificate in the
system trust store. It also sets `SSL_CERT_FILE`, `CURL_CA_BUNDLE`, `REQUESTS_CA_BUNDLE`,
`GIT_SSL_CAINFO`, `CARGO_HTTP_CAINFO` and `NODE_EXTRA_CA_CERTS` on a Debian, Ubuntu or Alpine
workstation. A login shell, an SSH command and a Ringleader agent session get these variables.
A systemd service or cron job does not, so set `SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt`
in its unit. An agent built on Node.js, Python, Go, `curl` or `git` then needs no other setup.
[Effects of injection on a workstation](https://docs-stg.ringleader.dev/security/credentials/injection-effects/)
says what else changes.

## Optional: Use your team's LLM gateway

An LLM Integration delivers the gateway's address and key onto every workstation it reaches,
as environment variables for any agent to read. This section is for an agent that talks to your
team's LLM gateway instead of to its vendor. It replaces the previous task for that agent,
because the gateway key is then on the workstation.

1. Apply an `llm` Integration for the gateway, as
   [Connect a coding agent to an LLM gateway](https://docs-stg.ringleader.dev/guides/connect-llm-gateway/)
   shows.
2. Open a new shell with `rl shell my-agent-box -n local` and read
   `/etc/ringleader/integrations/<integration-name>.json`. Its `environment` list names the
   variables the agent reads.

[The endpoint files](https://docs-stg.ringleader.dev/reference/resources/integration/#the-endpoint-files) describes each
key. [The provider file](https://docs-stg.ringleader.dev/reference/resources/integration/#the-provider-file) describes the
OpenAI-style address that some vendors add.

The agent must read these values itself. Ringleader configures only the agents it supports,
which [Supported agents](https://docs-stg.ringleader.dev/workstations/coding-agents/supported-agents/) lists.

## Optional: Give the agent MCP servers

An Integration that registers an MCP server writes the server's name and address to
`/etc/ringleader/mcp/<integration-name>.json` on every workstation it reaches, whether or not a
supported agent is installed. An agent that can read the file connects to the server itself.

1. Register the server in `injected` mode, as
   [Register an MCP server with the key kept off the workstation](https://docs-stg.ringleader.dev/workstations/coding-agents/mcp-servers/#register-an-mcp-server-with-the-key-kept-off-the-workstation)
   shows.
2. Open a new shell with `rl shell my-agent-box -n local` and run
   `cat /etc/ringleader/mcp/<integration-name>.json`. The file holds `name` and `url`, and
   no header and no key.
3. Set the agent to call that `url` with no credential. Ringleader adds the key to each
   request as it leaves the workstation.

Do not use `local` mode for an agent Ringleader does not configure. In that mode the file's
`value` is a `${secret:…}` reference that nothing on the workstation resolves.
[Injected and local modes](https://docs-stg.ringleader.dev/workstations/coding-agents/mcp-servers/#injected-and-local-modes)
says where each mode adds a key.

## Optional: Sign in with a browser

An agent that signs in through a browser needs the setup in
[Sign in to a tool from a workstation](https://docs-stg.ringleader.dev/guides/tool-sign-in/). Follow that
guide to turn on URL forwarding for the workstation, then approve the sign-in link on your
computer.

## Check what the agent reaches

Confirm that Ringleader adds the key, and see which hosts the agent calls.

1. On your computer, run `rl integration describe my-agent-key -n local`. The **Credential
   injection** section reads `Injecting` for the host.
2. After the agent has made a request, run
   `rl workstation egress my-agent-box --credentials -n local`. The output lists the host
   and its request count. New records can take a few minutes to appear.

To find every host the agent calls, set `enforcement: audit` on the workstation first. Then
follow [Workstation reach audit](https://docs-stg.ringleader.dev/security/outbound/reach-audit/) to record
the hosts, and list the ones that need rules.

## Troubleshoot

- If the agent fails with a certificate error, it ignores the six certificate variables or
  checks for one fixed certificate. A Java keystore, `apt` and Rust's `webpki-roots` do this.
  Add the host to `exclude`, as
  [Exclude a host from decryption](https://docs-stg.ringleader.dev/security/credentials/host-inspection-exclusion/#exclude-a-host-from-decryption)
  shows. Ringleader then adds no key to that host, so the agent needs its real key another way.
- If the API answers `401`, Ringleader is not adding the key. Read the **Credential
  injection** section of `rl integration describe my-agent-key -n local`.
  [Reasons a host is not injected](https://docs-stg.ringleader.dev/reference/resources/integration/#reasons-a-host-is-not-injected)
  says what to do for each reason.
- If the agent ignores an environment variable, set the value in the agent's own settings
  file. Add a `files` entry to the WorkstationConfig, as [Files](https://docs-stg.ringleader.dev/reference/resources/workstationconfig/#files)
  describes:

  ```yaml
  files:
    - path: ~/.config/my-agent/settings.json
      content: '{"apiKey": "not-the-real-key"}'
  ```

- If the agent refuses the stand-in as malformed, use a value in the shape the agent expects,
  with the same prefix and length as a real key.
- If the API rejects the stand-in, the agent may send its key in a URL parameter or a body.
  Ringleader replaces a header only, so the stand-in reaches the API. Gemini's REST `?key=`
  form is one example.
- If the connection fails for another reason, check the limits. A rule names one exact host,
  with no wildcard or IP address, and an Integration takes 32 rules. Only HTTPS on port 443 is
  decrypted, so a client that speaks only HTTP/2 fails. Ringleader cannot inject a signed
  request such as AWS SigV4, an SSH key, a gRPC credential or a database key.
  [Injection fields](https://docs-stg.ringleader.dev/reference/resources/integration/#injection-fields) and
  [Effects of injection on a workstation](https://docs-stg.ringleader.dev/security/credentials/injection-effects/)
  say more.
- If a host reports `DaemonPlacementNotAllowed`, you do not own the workstation, or someone
  else applied the Integration. Apply it yourself on a workstation you own.
  [Reasons a host is not injected](https://docs-stg.ringleader.dev/reference/resources/integration/#reasons-a-host-is-not-injected)
  has the other reasons.
- If a shell does not show a new variable, it is older than the change. Open a new shell.

## Next steps

- [Supported agents](https://docs-stg.ringleader.dev/workstations/coding-agents/supported-agents/) says which
  agents Ringleader installs and configures, and what an agent loses without that support.
- [Injected credentials](https://docs-stg.ringleader.dev/security/credentials/injected-credentials/) says which
  hosts and headers Ringleader can add a key to.
- [LLM gateways for coding agents](https://docs-stg.ringleader.dev/workstations/coding-agents/llm-gateways/)
  explains the two ways to connect an agent to a gateway.
- [MCP servers for coding agents](https://docs-stg.ringleader.dev/workstations/coding-agents/mcp-servers/)
  explains the modes of an MCP server.
- [Lock down Claude Code for unattended runs](https://docs-stg.ringleader.dev/guides/lock-down-claude-code/)
  shows the same ideas for Claude Code: allowed hosts, keys held by Ringleader and a deadline.

