Skip to main content

Other CLI agents

Many coding agents run in a terminal, and most of them can be pointed at a different server than their vendor's. This page connects four of them to Spanway: Gemini CLI, GitHub Copilot CLI, Aider and Goose. Once connected, each tool uses a virtual key your admin controls, so its spend counts against your team budget, the company guardrails and logging apply, and the admin can serve it any model the gateway knows. spanwayctl has launch commands only for Claude Code, Codex, OpenCode and pi, so these four tools are set up with their own settings, as shown below. Each tool speaks one of the API styles the gateway serves, and that decides which address you give it.

A real-world scenario​

A team has developers who each prefer a different terminal agent: one uses Gemini CLI, one uses GitHub Copilot CLI, one uses Aider and one uses Goose. The admin wants all four on the gateway with the same budget rules. They create one key per developer and tool, for example ravi-gemini-cli and mei-aider, each with a monthly budget. Each developer follows their tool's section on this page, sends one prompt, and finds the request on the Logs page under their own key alias. When one developer's agent loops overnight, only that key hits its budget and stops.

Prerequisites​

  • The tool installed, at a current version. The setting names below come from each tool's own documentation and can change between releases.
  • The gateway's address, for example https://gateway.example.com, reachable from your machine.
  • A virtual key for the tool, made as in the next section.
  • For Gemini CLI, at least one public model name on the gateway that the CLI can send. The name can point at any provider, see Gemini CLI.

Make a key for each tool​

  1. In the Admin UI open Virtual Keys (/ui/api-keys) and click + Create New Key.
  2. Set Key Name to who and which tool, for example ravi-gemini-cli, mei-aider, sam-goose or lee-copilot-cli. Leave Key Type on AI APIs.
  3. In Models, pick the models the developer will use in the tool, plus any helper model the tool sends side tasks to. Aider sends commit messages and chat summaries to its weak model, and Gemini CLI sends short helper calls to its own default models. A missing helper model makes those calls fail with 403 while the main chat works.
  4. Open Optional Settings. Set Max Budget (USD), for example 100, with Reset Budget on monthly, and a Requests per minute Limit (RPM) such as 60. Leave Tags empty unless the gateway has an Enterprise license, because key tags need one and without it the key is not created (Only premium users can add tags to keys). The key name already keeps this tool's spend apart in Usage.
  5. Click Create Key and copy the key. It is shown once.
curl -X POST https://gateway.example.com/key/generate \
-H "Authorization: Bearer $SPANWAY_MASTER_KEY" -H "Content-Type: application/json" \
-d '{"key_alias": "mei-aider", "key_type": "llm_api", "models": ["claude-sonnet-5-5", "claude-haiku-5-5"], "max_budget": 100, "budget_duration": "30d", "rpm_limit": 60}'

Make a key for a tool explains every field.

Which address each tool needs​

ToolAPI styleSetting for the addressValueRoute the gateway sees
Gemini CLIGoogle GeminiGOOGLE_GEMINI_BASE_URLhttps://gateway.example.com, without /v1 or /v1beta/v1beta/models/<model>:streamGenerateContent
GitHub Copilot CLI, type openaiOpenAIbaseUrl in providers.jsonhttps://gateway.example.com/v1, with /v1/v1/chat/completions, or /v1/responses with wireApi responses
GitHub Copilot CLI, type anthropicAnthropicbaseUrl in providers.jsonhttps://gateway.example.com, without /v1/v1/messages
AiderOpenAIOPENAI_API_BASEhttps://gateway.example.com/v1, with /v1/v1/chat/completions
Goose, built-in openai providerOpenAIOPENAI_HOST and OPENAI_BASE_PATHhttps://gateway.example.com and v1/chat/completions/v1/chat/completions
Goose, custom providerOpenAIbase_url in the provider filehttps://gateway.example.com/v1/chat/completions, the full path/v1/chat/completions

Connect any client explains why some tools want /v1 and others do not.

Steps​

Gemini CLI​

Gemini CLI speaks the Google Gemini API. The gateway serves that API for any provider, so a public name such as gemini-3.8-flash can point at a Gemini deployment or at any other model the admin chooses.

  1. Ask the admin which public model names your key may send. Gemini CLI cannot list models from the gateway, because the Gemini model listing route is not served, so you need the name in advance.

  2. Set the key, the address and the model, in your shell profile or in ~/.gemini/.env. The base URL is the bare gateway root, because Gemini CLI adds /v1beta/models/... itself.

    export GEMINI_API_KEY="sk-..."
    export GOOGLE_GEMINI_BASE_URL="https://gateway.example.com"
    export GEMINI_MODEL="gemini-3.8-flash"
  3. Make sure Gemini CLI signs in with the API key and not with a Google account. A Google account sign-in ignores GOOGLE_GEMINI_BASE_URL and goes straight to Google. Pick Use Gemini API Key in the CLI's /auth menu, or set it in ~/.gemini/settings.json:

    {
    "security": { "auth": { "selectedType": "gemini-api-key" } },
    "model": { "name": "gemini-3.8-flash" }
    }
  4. Start the CLI and send a prompt, or run one prompt without the interface:

    gemini -p "Say hello"

Gemini CLI sends the key in the x-goog-api-key header, which the gateway accepts. For a Vertex AI setup instead (GOOGLE_GENAI_USE_VERTEXAI=true and the vertex-ai sign-in), the address setting is GOOGLE_VERTEX_BASE_URL, which works the same way.

Gemini CLI also sends short helper calls of its own, for example to count tokens or to shorten a long session, and some of them name one of its default models rather than the one you set. If Logs shows 400 or 403 rows for a model name you never typed, the admin adds a deployment under that public name in Models + Endpoints (it may point at any provider) and adds it to your key.

GitHub Copilot CLI​

GitHub Copilot CLI can use your own model provider through a file called providers.json. The gateway works as an openai type provider, or as an anthropic type provider for Claude models.

  1. Open ~/.copilot/providers.json, or create it. To keep it somewhere else, set COPILOT_PROVIDERS_CONFIG to its path before starting the CLI.

  2. Add the gateway as a provider, and list each model you will use. Copilot CLI does not read the gateway's model list, so every model is listed by hand.

    {
    "providers": [
    {
    "name": "spanway",
    "type": "openai",
    "baseUrl": "https://gateway.example.com/v1",
    "apiKey": "sk-...",
    "wireApi": "completions"
    }
    ],
    "models": [
    { "id": "claude-sonnet-5-5", "provider": "spanway", "maxPromptTokens": 1000000, "maxOutputTokens": 128000 },
    { "id": "sol", "provider": "spanway", "wireModel": "gpt-6.1-sol", "maxPromptTokens": 922000, "maxOutputTokens": 128000 }
    ]
    }
  3. Protect the file, because the key is stored in it as plain text. Copilot CLI treats a value such as $SPANWAY_API_KEY in this file as literal text and does not read your environment.

    chmod 600 ~/.copilot/providers.json
  4. Start the CLI on a gateway model. Switch during a session with /model.

    copilot --model spanway/claude-sonnet-5-5
SettingWhat to putWhy
typeopenai, or anthropic for Claude modelsDecides the API style. With anthropic, set baseUrl to https://gateway.example.com without /v1.
baseUrlhttps://gateway.example.com/v1 for openaiThe CLI adds /chat/completions or /responses.
apiKey or bearerTokenThe virtual keyEither one works. The gateway reads the key from Authorization and from x-api-key.
wireApicompletions (the default) or responsesPicks /v1/chat/completions or /v1/responses. Both work on the gateway.
models[].idThe name you pick in the CLIAlso the name sent to the gateway, unless wireModel is set.
models[].wireModelA public name from GET /v1/modelsLets the CLI show a short id while sending the gateway's name.
models[].modelIdA model name the CLI knowsOptional. Gives the CLI that model's built-in settings for a gateway name it does not know.
maxPromptTokens, maxOutputTokensFrom GET /model_group/infoThe CLI uses them to fit the conversation into the model.

An explicitly selected file wins over an environment configured provider, and an environment configured provider wins over the default providers.json. Setting COPILOT_OFFLINE=true before starting the CLI stops it from contacting its vendor's servers, for example for telemetry, while the model calls still go to the gateway.

Aider​

Aider is a pair programming tool for the terminal that edits files in a git repository. It connects to the gateway as an OpenAI compatible endpoint.

  1. Set the address and the key. The address includes /v1.

    export OPENAI_API_BASE="https://gateway.example.com/v1"
    export OPENAI_API_KEY="sk-..."
  2. Start Aider with a gateway model name. Put openai/ in front of the name. Aider uses the prefix to pick the OpenAI style and removes it before sending, so the gateway receives claude-sonnet-5-5.

    aider --model openai/claude-sonnet-5-5 --weak-model openai/claude-haiku-5-5
  3. To keep the settings, put them in .aider.conf.yml in your home folder or the repository root instead:

    openai-api-base: https://gateway.example.com/v1
    openai-api-key: sk-...
    model: openai/claude-sonnet-5-5
    weak-model: openai/claude-haiku-5-5

The weak model writes commit messages and summarises long chats. If you do not set one, Aider picks its own default, which may not be a name on the gateway. Aider does not know the context window or price of gateway names, so it prints a warning about an unknown model at start. The warning is harmless, and --no-show-model-warnings hides it.

Goose​

Goose is an agent for the terminal and the desktop that uses extensions and MCP tools. It connects to the gateway with its built-in openai provider, its built-in anthropic provider, or a custom provider file.

  1. Built-in openai provider. Set the host without /v1, because Goose adds OPENAI_BASE_PATH, which defaults to v1/chat/completions.

    export GOOSE_PROVIDER="openai"
    export GOOSE_MODEL="claude-sonnet-5-5"
    export OPENAI_HOST="https://gateway.example.com"
    export OPENAI_BASE_PATH="v1/chat/completions"
    export OPENAI_API_KEY="sk-..."
    goose session

    goose configure asks for the same values interactively, under Configure Providers. It stores the key in the system keychain. A key typed into Goose's config.yaml is ignored, so the requests then arrive without one and fail with 401.

  2. Built-in anthropic provider, for Claude models. Set GOOSE_PROVIDER="anthropic", ANTHROPIC_HOST="https://gateway.example.com" without /v1, and ANTHROPIC_API_KEY to the virtual key.

  3. Custom provider, which shows up in Goose under its own name. Create ~/.config/goose/custom_providers/spanway.json (on Windows, %APPDATA%\Block\goose\config\custom_providers\spanway.json). Here base_url is the full path.

    {
    "name": "spanway",
    "engine": "openai",
    "display_name": "Spanway",
    "api_key_env": "SPANWAY_API_KEY",
    "base_url": "https://gateway.example.com/v1/chat/completions",
    "models": [
    { "name": "claude-sonnet-5-5", "context_limit": 1000000 },
    { "name": "gpt-6.1-sol", "context_limit": 922000 }
    ],
    "headers": { "x-spanway-tags": "tool:goose" },
    "supports_streaming": true,
    "requires_auth": true
    }

    Export SPANWAY_API_KEY with the virtual key, then start a session with goose session --provider spanway.

To tag requests from the built-in provider, set OPENAI_CUSTOM_HEADERS="x-spanway-tags=tool:goose". The gateway reads x-spanway-tags and records it on every request, so Usage can group Goose's spend.

Expected result​

Each tool answers your prompt as it normally does. On the gateway's Logs page (/ui/logs), open Filters, pick the tool's Key Alias and click Apply Filters. Each call is one row with the model, tokens and cost, on the route from the address table. Helper calls, such as Aider's commit messages on the weak model or Gemini CLI's token counts, appear as their own short rows.

None of these tools show response headers. To read them, send one request with the same key from a terminal, in the tool's API style. For the OpenAI style:

curl -i https://gateway.example.com/v1/chat/completions \
-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \
-d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Say hello"}]}'

For the Gemini style, which is what Gemini CLI sends:

curl -i "https://gateway.example.com/v1beta/models/gemini-3.8-flash:generateContent" \
-H "x-goog-api-key: $SPANWAY_API_KEY" -H "Content-Type: application/json" \
-d '{"contents": [{"role": "user", "parts": [{"text": "Say hello"}]}]}'

Look at x-spanway-call-id (the id to search for on Logs), x-spanway-model-group and x-spanway-routing-reason (which model group served the call and why, see routing decision headers), x-spanway-response-cost, and x-spanway-key-spend with x-spanway-key-max-budget for the budget left.

What works through the gateway​

FeatureGemini CLIGitHub Copilot CLIAiderGoose
StreamingYes, over :streamGenerateContentYesYes. --no-stream turns it offYes. Set supports_streaming in a custom provider
Tool callsYes. Gemini function declarations are translated for other providersYesAider edits files from the model's text answer and needs no tool callsYes. Goose depends on tool calls for its extensions, so pick models that support them
ImagesYes, when the model takes imagesYes, when the model takes imagesYes, add image files to the chat for a model that takes imagesYes, when the model takes images
ReasoningthinkingConfig reaches models that support thinkingModel dependent--reasoning-effort for models that support itModel dependent
Prompt cachingProvider dependentProvider dependent--cache-prompts marks the prompt for caching. It only helps on models whose provider cachesProvider dependent
Model list from the gatewayNo, the name is typedNo, models are listed in providers.jsonNo, the name is typedNo, models are typed or listed in the provider file

A parameter that a tool always sends but the provider behind the name does not take fails with 400 and the message does not support parameters. The admin can turn on drop params for that deployment to remove it instead.

Errors​

The third column is the text the gateway sends. Each tool wraps it in its own words: Gemini CLI shows it as an API Error with the message inside, Copilot CLI shows the status and message in the session, Aider prints the error type, such as AuthenticationError, followed by the message, and Goose shows the status and message in the session or in its log. The client error reference lists the same errors for every tool.

CaseStatusGateway textFix
No key reached the gateway401Authentication Error, No api key passed in.The variable is not set in that terminal, or for Goose the key is in config.yaml. Set the key the way the tool's section says.
Wrong or deleted key401Authentication Error, Invalid proxy server token passedCopy the key again from Virtual Keys, or ask the admin whether it was blocked.
Blocked key401Authentication Error, Key is blocked. Update via `/key/unblock` if you're an admin.Ask the admin to open the key in Virtual Keys and click Unblock Key.
The key may not use the model403The requested model '<model>' is not available for this API key, or the model name is invalid.Use a model the key allows, or ask the admin to add it, including helper models such as Aider's weak model.
The model name does not exist on the gateway400Invalid model name passed in model=<name>Use a name from GET /v1/models, typed exactly. For Aider, check that only one openai/ prefix is in front of it.
A parameter the provider does not take400does not support parameters: <names>, for model=<model>Ask the admin to turn on drop params for that deployment, or pick another model.
The budget is spent422Budget has been exceeded! Key=<key alias> Current cost: <spend>, Max budget: <max>Wait for the reset, or ask the admin to raise the budget.
The key's rate limit is reached429Rate limit exceeded for <scope>: <value>. Limit type: <type>.Wait for the reset time in the message, or ask for a higher RPM or TPM limit.
Wrong path, such as /v1/v1/chat/completions or /v1/v1beta/...404Not FoundUse the exact value from the address table. Goose's OPENAI_HOST and Gemini CLI's GOOGLE_GEMINI_BASE_URL must not end in /v1.
Gemini CLI answers but nothing shows on LogsnoneNoneThe CLI signed in with a Google account and bypassed the gateway. Switch /auth to Use Gemini API Key.
Connection refusednoneNone, the gateway never answered.Check the address and port, and run curl https://gateway.example.com/health/liveliness.
TLS or certificate errornoneNone, the connection failed before any answer.Give the tool the company root certificate. Gemini CLI and Copilot CLI are Node programs that read NODE_EXTRA_CA_CERTS. Aider is a Python program that reads SSL_CERT_FILE or REQUESTS_CA_BUNDLE. For Goose, add the certificate to the operating system's trust store. See connection problems.

Troubleshooting​

  1. Find the request on Logs by the tool's key alias and the time. If a row is there, the drawer shows the status, the message, the model group the router picked and the provider's answer.
  2. If there is no row, the request never reached the gateway. Check the address against the address table and run the matching curl above with the same values.
  3. Turn on the tool's own debug output from the table below and look for the URL it calls and the status it gets back.
  4. Read the routing headers from the curl above. x-spanway-attempts higher than 1 means the gateway retried or fell back, and x-spanway-routing-reason says why.
ToolDebug switchWhere the output goes
Gemini CLIgemini --debug (or -d)The terminal. Press F12 in the CLI to open its debug console.
GitHub Copilot CLIcopilot --log-level debugLog files in ~/.copilot/logs/, one per session, or the folder set with --log-dir.
Aideraider --verboseThe terminal, with the settings Aider loaded and each request.
GooseNo switch neededGoose writes logs under ~/.local/state/goose/logs/ on macOS and Linux, with the model requests in the llm_request files there.
Gatewayspanway --config config.yaml --detailed_debug on a test instanceThe gateway log, with every request, the key check and the routing decision.

Rotate or remove the key​

To rotate, open the key on Virtual Keys, click Regenerate Key and set a Grace Period such as 24h so the old key keeps working while you switch. Put the new key where the tool reads it: the environment variable for Gemini CLI, Aider and Goose (or the keychain through goose configure), and apiKey in providers.json for Copilot CLI. POST /key/{key}/regenerate does the same from the API and needs an Enterprise license. Without one, create a new key, switch to it and delete the old one.

To stop using the gateway, remove the address setting from the tool: unset GOOGLE_GEMINI_BASE_URL, remove the spanway provider from providers.json, unset OPENAI_API_BASE for Aider, or switch Goose back to another provider in goose configure. To cut the key off, use Block Key in the key's actions menu, which can be undone, or delete the key. From the API, POST /key/block with {"key": "sk-..."} blocks it and POST /key/delete with {"keys": ["sk-..."]} deletes it.