# Run Claude Code through SecondGate

> Run Claude Code through SecondGate with the SecondStack CLI: secondstack login, claude and codex, the install commands, Devices, plus Cursor and similar tools.

Canonical: <https://docs.secondstack.ai/developers/coding-tools/>
Updated: 2026-11-06
Checked against: v3.7.2

---

Run Claude Code through SecondGate with the SecondStack CLI: `secondstack login`, `claude` and `codex`, the install commands, Devices, plus Cursor and similar tools. The CLI signs your computer in once. From then on Claude Code and Codex send every request through [SecondGate](/gateway/), on your company's subscription seats or on a virtual key.

**Labels in the app**

| Our word | Label in the app |
|---|---|
| the SecondStack CLI | secondstack |
| a connected computer | Devices |
| the desktop app's coding tools card | Coding agents |
| the Anthropic base URL | Anthropic base URL (Claude Code) |
| the OpenAI-compatible base URL | OpenAI-compatible base URL (SDKs and CLIs) |

## Install the SecondStack CLI

You install the CLI from your own platform's address with one command, and it signs you in as it finishes.

1. Ask your administrator whether the CLI is turned on. It stays off until the operator sets `SECONDSTACK_CLI_DEPLOY=true`. The default site offers Codex and Claude Code, and a site without the `secondstack_cli_coding_tools` setting offers Codex only.
2. On macOS or Linux, run `curl -fsSL https://ai.example.com/install.sh | sh`, with your platform's address in place of `ai.example.com`. On Windows, run `irm https://ai.example.com/install.ps1 | iex` in PowerShell. Add `-s -- --no-login` or `-NoLogin` to install without signing in.
3. The installer places `secondstack` under `~/.secondstack/bin/`, verifies the download's digest and opens your browser for sign-in. `secondstack login` repeats the sign-in, with `--portal URL`, `--no-browser` and `--team <id|name>` as options, and `secondstack status` shows where you are signed in.

The CLI installs neither Claude Code nor Codex. When a tool is missing or too old it says so and names the minimum: Codex 0.134.0 and Claude Code 2.1.303 at v3.7.2.

## Use SecondGate as a Claude Code proxy

`secondstack claude` starts the Claude Code you already have with SecondGate as its Anthropic endpoint, for this one launch, and your own Claude Code setup does not change.

- `secondstack claude` passes `ANTHROPIC_BASE_URL` and a session credential to Claude Code and keeps the key out of the command line. Any arguments after the command go to Claude Code.
- `secondstack claude --billing api` bills the API through a virtual key instead of a subscription seat. Codex and Claude Code use subscription seats by default.
- `secondstack install-claude` writes the same settings into Claude Code's `settings.json`, so plain `claude` goes through SecondGate from then on. `secondstack uninstall-claude` takes them out.
- `install-claude` refuses to overwrite a Claude Code that already holds its own API key or token. It also turns off the login prompt of the Claude Code extension in VS Code, VS Code Insiders, Cursor, Windsurf and VSCodium.
- `secondstack install-claude-desktop` and `secondstack uninstall-claude-desktop` do the same for the Claude desktop app.

Claude Code gets `https://ai.example.com/gateway/api` as its base URL, which the API Keys page shows as **Anthropic base URL (Claude Code)**. Claude Code adds `/v1/messages` itself. Every request shows in your record, and SecondGuard masks what your rules say before it leaves.

## Run Codex through SecondGate

`secondstack codex` starts Codex under a SecondStack profile, and `secondstack install-codex` makes that profile the default.

- `secondstack codex` launches Codex with a profile of its own and passes the key in `SECONDSTACK_API_KEY`. `--billing api` works here too.
- `secondstack install-codex` writes a `secondstack` provider into Codex's `config.toml`. The Codex app shares that file, so reopen the app and start a new thread after the change. `secondstack uninstall-codex` reverts it.

## Set up a tool by hand

`secondstack manual-setup` prints the settings the install commands would write, for a tool the CLI does not configure or for another computer.

1. Run `secondstack manual-setup claude` or `secondstack manual-setup codex`, with `--billing subscription` or `--billing api` to choose the route. The key is masked unless you add `--show-key`.
2. Add `--another-computer` for a copy with portable paths and the command that issues a key on that computer.
3. For Cursor and any other tool that takes an OpenAI-compatible base URL and an API key, use `https://ai.example.com/gateway/api/v1` as the base URL and a virtual key from **API Keys** in ControlTower. [Call SecondGate from your code](/developers/gateway-api/) shows the endpoints and the request shape. The CLI configures only the Claude Code extension inside those editors.

## Set up from the desktop app

The desktop app sets up Codex, Claude Code, the Codex app and the Claude desktop app from one card, sharing the CLI's setup core.

Open the **Coding agents** card in the desktop app. Each tool has **Reconfigure**, **Revert** and **Manual setup**. **Reconfigure** also takes over a setup the CLI made. The Claude desktop app row chooses between subscription and API billing. A Linux server without a display does the same through `desktop-runtime coding-agents status` and `desktop-runtime coding-agents connect-key`. [The desktop app](/chat-app/desktop-app/) covers installation and pairing.

## Devices

Every computer you sign in from appears under **Devices** in ControlTower, with its own key, and you can rename or revoke it there.

The page marks each device as **CLI** or **Desktop app** and offers **Rename** and **Revoke**. **Connect a computer** shows the install commands. A new device key starts with a budget of 0. That budget blocks API billing until an administrator raises it, and it does not block subscription use. Revoking a device signs the computer out, deletes its key and cuts off the coding agents running on it. To use the computer again, connect it again. `secondstack logout` signs out from the computer's side. `secondstack update` fetches the CLI version your platform publishes.

## What the CLI does not do

- The CLI does not install or update Claude Code or Codex. It starts the ones you have and names the minimum version when one is too old.
- A site without the `secondstack_cli_coding_tools` setting offers Codex only, so `secondstack claude` is not on offer there.
- The CLI does not configure an editor's own models. In Cursor, Windsurf and the VS Code family it touches only the Claude Code extension, and you set the editor's built-in models by hand.
- `install-claude` refuses to overwrite a Claude Code that already carries an API key or an OAuth token of its own. Remove that setting first.
- A device key with a budget of 0 cannot bill the API. Subscription seats still work.

## Related

- [Call SecondGate from your code](/developers/gateway-api/)
- [Agent Claude](/developers/agent-claude/)
- [Gateway](/gateway/)
- [Your dashboard](/controltower/user-dashboard/)
- [The desktop app](/chat-app/desktop-app/)
- [Model providers](/gateway/providers/)
