Rolling out terminal coding agents across an engineering team looks trivial until five developers hit five different authentication and path bugs on day one.
One engineer sets ANTHROPIC_BASE_URL with a trailing /v1 and gets 404 on /v1/v1/messages. Another sets OPENAI_BASE_URL in .zshrc expecting OpenAI's Codex CLI to pick it up—only to discover Codex CLI ignores OPENAI_BASE_URL unless a [model_providers.*] block is declared in ~/.codex/config.toml with wire_api = "responses". A third installs Google's Antigravity CLI (agy), exports GEMINI_API_KEY, and still gets prompted for browser OAuth because ~/.gemini/antigravity-cli/settings.json is missing "modelProvider": "gemini".
Meanwhile, whoever holds the company card has a bigger problem: sharing a single raw vendor API key in Slack means zero per-developer spend caps, no attribution when an autonomous loop burns $300 overnight, and a painful laptop-by-laptop migration the day an engineer leaves.
This guide gives you exact, production-tested configuration files for running Claude Code, OpenAI Codex CLI, and Google Antigravity CLI (agy) against a unified enterprise gateway (https://api.hop-base.com), along with the base-URL path rules, config-precedence traps, per-developer quota controls, and key-rotation patterns that keep a team setup maintainable.
1. Base URL Suffix Matrix: Why Half of Custom Gateway Setups Return HTTP 404
Before touching any config file, lock down the exact path contract for each CLI. Different agent runtimes append different path prefixes internally:
| Coding Agent / SDK | Base URL Variable or Config Key | Exact Value | Path Appended by Client | Auth Header Sent |
|---|---|---|---|---|
| Claude Code CLI | ANTHROPIC_BASE_URL |
https://api.hop-base.com (no /v1)
|
/v1/messages, /v1/messages/count_tokens
|
x-api-key / Authorization: Bearer
|
| OpenAI Codex CLI |
base_url in ~/.codex/config.toml
|
https://api.hop-base.com/v1 (with /v1)
|
/responses (wire_api = "responses") |
Authorization: Bearer |
| OpenAI Python / Node SDKs | OPENAI_BASE_URL |
https://api.hop-base.com/v1 (with /v1)
|
/chat/completions, /responses
|
Authorization: Bearer |
Antigravity CLI (agy) |
GOOGLE_GEMINI_BASE_URL |
https://api.hop-base.com (no /v1beta)
|
/v1beta/models/{model}:streamGenerateContent?alt=sse |
x-goog-api-key |
The golden rule: only OpenAI-compatible clients (OPENAI_BASE_URL and Codex CLI base_url) include /v1 in the Base URL. Both Claude Code (ANTHROPIC_BASE_URL) and Antigravity CLI (GOOGLE_GEMINI_BASE_URL) expect the bare origin and attach /v1/... or /v1beta/... themselves.
Always verify which model IDs a given developer key is authorized to call before launching any CLI:
curl -fsS https://api.hop-base.com/v1/models \
-H "Authorization: Bearer $HOPBASE_API_KEY" | jq -r '.data[].id'
2. Claude Code: ANTHROPIC_BASE_URL & the settings.json Precedence Trap
Claude Code speaks the native Anthropic Messages API (POST /v1/messages). You can configure it either via ~/.claude/settings.json or via shell environment variables—but you should never mix both on the same machine.
Option A: Declarative ~/.claude/settings.json (Recommended for Team Onboarding)
Writing the configuration into ~/.claude/settings.json works identically across macOS, Linux, Windows, and IDE-integrated terminals (VS Code, Cursor, JetBrains) that do not always source interactive .zshrc files:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.hop-base.com",
"ANTHROPIC_AUTH_TOKEN": "sk-dev-alice-key",
"ANTHROPIC_MODEL": "claude-sonnet-5-5",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-5-5"
}
}
Precedence Pitfall: Any variable present inside the
"env"block of~/.claude/settings.jsonoverrides shell environment variables of the same name (export ANTHROPIC_AUTH_TOKEN=...). If a developer updates.zshrclater and wonders why Claude Code is still sending an old token, check~/.claude/settings.jsonfirst.
Option B: Shell Environment + Secret Manager Injection (Recommended for Zero-Plaintext Laptops)
If your team injects secrets dynamically from 1Password CLI (op run), Doppler, AWS Vault, or direnv so keys never sit on disk in plaintext, keep ANTHROPIC_AUTH_TOKEN out of ~/.claude/settings.json and export it in your shell wrapper:
# ~/.zshrc or ~/.bashrc (macOS / Linux)
export ANTHROPIC_BASE_URL="https://api.hop-base.com"
export ANTHROPIC_AUTH_TOKEN="sk-dev-alice-key"
# Launch with an explicit flagship or daily-driver model
claude --model claude-opus-5-5
# Or switch mid-session inside Claude Code:
# /model claude-fable-5-2
On Windows PowerShell:
setx ANTHROPIC_BASE_URL "https://api.hop-base.com"
setx ANTHROPIC_AUTH_TOKEN "sk-dev-alice-key"
# Reopen PowerShell, then run:
claude --model claude-sonnet-5-5
Bonus: Running 1M-Context Non-Claude Models Natively in Claude Code
When your gateway exposes native Anthropic Messages (POST /v1/messages) for 1M-context models such as qwen4-max, kimi-k3.1-pro, or deepseek-v4.1-flash-1017, Claude Code connects directly without any local translation proxy. Just add CLAUDE_CODE_MAX_CONTEXT_TOKENS so Claude Code does not prematurely compact the session at its default 200K threshold:
export ANTHROPIC_BASE_URL="https://api.hop-base.com"
export ANTHROPIC_AUTH_TOKEN="sk-dev-alice-key"
export ANTHROPIC_MODEL="qwen4-max"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3.8-flash"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=1000000
claude
Full walkthrough and one-click installer details: Claude Code Custom Base URL Guide.
3. OpenAI Codex CLI: Custom base_url & wire_api = "responses" in config.toml
Standard OpenAI SDK scripts honor OPENAI_BASE_URL=https://api.hop-base.com/v1 and OPENAI_API_KEY. OpenAI Codex CLI is stricter: it uses OpenAI's Responses API (POST /v1/responses) rather than legacy Chat Completions, and it requires an explicit custom provider table in ~/.codex/config.toml (or C:\Users\<your-name>\.codex\config.toml on Windows).
Copy-Paste ~/.codex/config.toml
model_provider = "hopbase"
model = "gpt-6.2-sol"
model_reasoning_effort = "high"
[model_providers.hopbase]
name = "HopBase"
base_url = "https://api.hop-base.com/v1"
wire_api = "responses"
env_key = "OPENAI_API_KEY"
Then export the developer's scoped key (and optionally OPENAI_BASE_URL so other OpenAI-compatible CLI tools and Python/Node scripts in the same shell share the exact same gateway endpoint):
export OPENAI_BASE_URL="https://api.hop-base.com/v1"
export OPENAI_API_KEY="sk-dev-alice-codex-key"
codex
Three Codex CLI Pitfalls to Avoid in Team Rollouts
-
Never combine
requires_openai_auth = truewithenv_keyin the same provider block. Codex CLI has two mutually exclusive credential paths:env_key = "OPENAI_API_KEY"(environment variable) andrequires_openai_auth = true(which reads~/.codex/auth.json). Mixing both in Codex 0.153+ causes the client to omit theAuthorizationheader completely, resulting in401 missing_api_key. -
Right-size
model_reasoning_effort. Accepted values arelow,medium,high, andxhigh. Leaving every developer defaulted toxhighon flagship models burns maximum reasoning tokens on trivial file renames; standardize your team template onmediumorhighand reservexhighfor deep architectural debugging. -
Disable Codex web search if you want clean logs. Codex CLI's built-in web search calls
/v1/alpha/searchand remote compaction calls/v1/responses/compact. On standard OpenAI-compatible gateways those proprietary endpoints return404without harming normal coding turns, so turning web search off in Codex keeps logs noise-free.
Full setup reference: Codex CLI OpenAI-Compatible Base URL Guide.
4. Google Antigravity CLI (agy): Native Gemini Protocol via GOOGLE_GEMINI_BASE_URL
Google's terminal coding agent, Antigravity CLI (agy, version 1.1.13+, verified through 1.5.12), speaks the native Gemini streaming protocol (POST /v1beta/models/{model}:streamGenerateContent?alt=sse)—meaning tool calls, multi-file edits, --continue session resumption, and multimodal image inputs run without lossy OpenAI-to-Gemini schema translation.
Step 1: Switch agy from Google OAuth to API Key Mode
Create or edit ~/.gemini/antigravity-cli/settings.json:
{
"modelProvider": "gemini"
}
The value must be lowercase "gemini". If a developer skips this file and only exports environment variables, agy ignores the custom URL and opens a Google account sign-in flow.
Step 2: Export GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY
export GEMINI_API_KEY="sk-dev-alice-gemini-key"
export GOOGLE_GEMINI_BASE_URL="https://api.hop-base.com"
# Model names in agy append -low, -medium, or -high to set thinkingLevel:
agy --model gemini-4-argon-medium
# Single-shot non-interactive prompt:
agy -p "Audit database migration 0042 for lock contention" --model gemini-4-hydrogen-low
Operational Notes for agy Administrators
-
Root URL only: Set
GOOGLE_GEMINI_BASE_URL=https://api.hop-base.comwith no/v1betasuffix. Also note thatagyreads environment variables from the launching shell—it does not load project.envfiles orGOOGLE_API_KEY. -
Background safety-review helper calls: After each agent step,
agyautomatically invokesgemini-3.1-flash-lite-previeworgemini-3.8-flashin the background. Make sure the developer's API key belongs to a group (such as HopBase'sGemini Official Direct (Enterprise)group) that serves both the primary Gemini 4 model (gemini-4-argon,gemini-4-carbon,gemini-4-neon,gemini-4-hydrogen) and those Flash helper models, otherwise background steps will return404. -
Use
-highinstead of-xhigh:agybuilds requestthinkingLevelfrom the model suffix (-low,-medium,-high);-xhighis not supported on the API path yet.
Full setup reference: Antigravity CLI Custom Base URL Guide.
5. Team Governance: Per-Developer Spend Caps & Zero-Touch Key Rotation
Pointing all three CLIs at a single gateway endpoint solves more than protocol routing—it lets engineering managers enforce security and cost boundaries centrally instead of policing laptops.
1. One Key per Developer + Three-Tier Quotas
Never paste a shared org-wide API key into a team wiki. Issue one scoped API key per engineer (and separate keys for CI runners):
-
Group scoping: Attach Claude, OpenAI Codex, and Gemini Enterprise groups onto one developer key (or split per tool if you prefer), so
GET /v1/modelsexposes exactly the approved model catalog. -
Three-level spend caps (Key → Member → Department): Set a monthly or daily USD spend cap on each developer key alongside department budgets. If an unattended agent loop gets stuck retrying a failing test suite at 2 AM, the gateway trips
HTTP 402 insufficient_quotaon that single key while every teammate and production service keeps running unaffected. -
Line-item chargeback: Export CSV usage logs filtered by member, department, or key creator—recording timestamp, model ID, input/cached/output token counts, latency, and exact USD charge—while failed requests rejected before generating output are billed at
$0.
2. Key Rotation & Offboarding Without Touching Developer Laptops
When an engineer changes teams, loses a laptop, or leaves the organization:
- Instant server-side revocation: Revoke or disable only that engineer's key in the gateway console. Because no other laptop or CI pipeline shares that credential, zero teammates are disrupted.
-
Centralized secret delivery for active rotations: Store each developer's
HOPBASE_API_KEYin your team vault (1Password, Doppler, or macOS Keychain via MDM) and reference a single source variable across all three tools in~/.zshrc:
# Single secret lookup feeds Claude Code, Codex CLI, OpenAI SDKs, and Antigravity CLI
export HOPBASE_API_KEY="$(op read 'op://Engineering/HopBase-Dev-Key/credential')"
export ANTHROPIC_BASE_URL="https://api.hop-base.com"
export ANTHROPIC_AUTH_TOKEN="$HOPBASE_API_KEY"
export OPENAI_BASE_URL="https://api.hop-base.com/v1"
export OPENAI_API_KEY="$HOPBASE_API_KEY"
export GOOGLE_GEMINI_BASE_URL="https://api.hop-base.com"
export GEMINI_API_KEY="$HOPBASE_API_KEY"
When a scheduled 90-day key rotation runs in your secret manager, every developer's next terminal session picks up the rotated token across Claude Code, Codex CLI, and agy simultaneously.
3. Optional: Let Agents Check Their Own Quota via MCP
To eliminate "is my key out of quota or did I misspell the model ID?" support tickets, developers can register HopBase's read-only MCP management server right inside Claude Code:
claude mcp add --transport http hopbase https://api.hop-base.com/mcp \
--header "Authorization: Bearer $HOPBASE_API_KEY"
That exposes read-only tools (get_balance, get_key_info, list_models, get_usage, get_model_limits, search_docs) scoped strictly to the calling key—so an engineer can ask their terminal agent directly how much of their monthly spend cap remains or which exact model IDs their key can call.
Quick Verification Script for Team Onboarding
Drop this 15-line smoke test into your engineering onboarding repo so new hires can validate all three protocol surfaces in five seconds:
#!/usr/bin/env bash
set -euo pipefail
: "${HOPBASE_API_KEY:?Export HOPBASE_API_KEY first}"
echo "1/3 Checking authorized models..."
curl -fsS https://api.hop-base.com/v1/models \
-H "Authorization: Bearer $HOPBASE_API_KEY" | jq -r '.data | "OK: \(length) models available"'
echo "2/3 Checking Anthropic Messages surface (Claude Code path)..."
curl -fsS https://api.hop-base.com/v1/messages \
-H "x-api-key: $HOPBASE_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{"model":"claude-haiku-5-5","max_tokens":16,"messages":[{"role":"user","content":"Reply: ok"}]}' \
| jq -r '.content[0].text'
echo "3/3 Checking OpenAI Responses surface (Codex CLI path)..."
curl -fsS https://api.hop-base.com/v1/responses \
-H "Authorization: Bearer $HOPBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-6-luna","input":"Reply: ok"}' \
| jq -r '.output_text // .output[0].content[0].text'
For full tool-by-tool parameter references and troubleshooting error codes, bookmark the official integration guides:
Top comments (0)