Run Claude Code through SecondGate
On this page
Labels on this page
- 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)
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, on your company’s subscription seats or on a virtual key.
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.
- 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 thesecondstack_cli_coding_toolssetting offers Codex only. - On macOS or Linux, run
curl -fsSL https://ai.example.com/install.sh | sh, with your platform’s address in place ofai.example.com. On Windows, runirm https://ai.example.com/install.ps1 | iexin PowerShell. Add-s -- --no-loginor-NoLoginto install without signing in. - The installer places
secondstackunder~/.secondstack/bin/, verifies the download’s digest and opens your browser for sign‑in.secondstack loginrepeats the sign‑in, with--portal URL,--no-browserand--team <id|name>as options, andsecondstack statusshows 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 claudepassesANTHROPIC_BASE_URLand 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 apibills the API through a virtual key instead of a subscription seat. Codex and Claude Code use subscription seats by default.secondstack install-claudewrites the same settings into Claude Code’ssettings.json, so plainclaudegoes through SecondGate from then on.secondstack uninstall-claudetakes them out.install-clauderefuses 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-desktopandsecondstack uninstall-claude-desktopdo 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 codexlaunches Codex with a profile of its own and passes the key inSECONDSTACK_API_KEY.--billing apiworks here too.secondstack install-codexwrites asecondstackprovider into Codex’sconfig.toml. The Codex app shares that file, so reopen the app and start a new thread after the change.secondstack uninstall-codexreverts 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.
- Run
secondstack manual-setup claudeorsecondstack manual-setup codex, with--billing subscriptionor--billing apito choose the route. The key is masked unless you add--show-key. - Add
--another-computerfor a copy with portable paths and the command that issues a key on that computer. - For Cursor and any other tool that takes an OpenAI-compatible base URL and an API key, use
https://ai.example.com/gateway/api/v1as the base URL and a virtual key from API Keys in ControlTower. Call SecondGate from your code 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 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_toolssetting offers Codex only, sosecondstack claudeis 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-clauderefuses 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.