Shift Note: Gemini CLI Relay Auth Stays on API Keys
The relay change has two moving parts
Pointing Gemini CLI at a relay means changing where its requests go and making sure it sends credentials that destination accepts. Changing only the address can leave the CLI using a saved Google sign-in session. Changing only the key can leave it calling Google's default endpoint.
The working arrangement is straightforward: Gemini CLI uses its Gemini API key authentication mode, the key belongs to your relay account, and the base URL points to a relay endpoint that understands the native Gemini API. Keep those three choices aligned before investigating model names or network settings.
Native Gemini requests need a Gemini-compatible endpoint
A relay can offer several API formats through the same hostname. Native Gemini requests have their own paths, request bodies, and authentication conventions. An OpenAI-compatible endpoint uses a different interface, even when it ultimately reaches a Gemini model.
Relay365 lists https://api.api365relay.com as its API base; OpenAI clients add /v1. For a native Gemini setup, use the base specified by its Gemini integration instructions. Do not append /v1 simply because an OpenAI SDK example does so. The Gemini client normally constructs its own versioned resource paths, so copying a complete request URL into the base setting can also produce an incorrect path.
Relay365 fits this use case when its native Gemini interface supports the Gemini CLI features you need. Its support for other clients does not, by itself, establish compatibility with every Gemini CLI operation.
Set the relay key and base in the launching shell
Gemini CLI versions that support a custom Gemini base URL use GOOGLE_GEMINI_BASE_URL. The API key variable is GEMINI_API_KEY. Check the documentation for your installed CLI version before relying on the base URL override.
In a Bash or Zsh session, the endpoint assignment is export GOOGLE_GEMINI_BASE_URL="https://api.api365relay.com". Set GEMINI_API_KEY to the key issued by Relay365, then launch gemini from that same shell. Environment variables set in one terminal do not automatically appear in another terminal or an already running process.
Treat these assignments as local configuration containing a secret. Avoid putting the actual key into shared setup notes, screenshots, source control, or command history. A secret manager or a private environment file loaded by your launch process is a better home for repeated use.
Select API key authentication before the first request
If Gemini CLI has previously used Google sign-in, inspect its authentication selection. Use the CLI's authentication menu, available through /auth in interactive sessions, and choose the Gemini API key option. A relay-issued key belongs in that flow; a Google account session represents a different authentication mechanism.
Also inspect inherited configuration for competing Google API keys or Vertex AI settings. Remove stale values from this launch environment where they could select another backend. Restart the CLI after changing the environment so the next process reads the intended values.
Run one small request and read failures narrowly
Choose a model your relay account actually exposes, such as Gemini 2.5 Flash if available, and send a short prompt. Check both the response and any available relay usage record. A successful Google sign-in alone does not establish that the request reached the relay.
- An authentication error calls for checking the selected auth mode, the relay key, and whether the account can make requests.
- A missing endpoint error calls for checking the base URL and looking for duplicated version segments or an OpenAI-specific path.
- A model error calls for checking the relay's exact model identifier and your account's access to it.
- A successful text response establishes a useful first check, while streaming, tool use, and other features still need testing if your workflow depends on them.
Keep the working relay configuration easy to repeat
Relay365 offers pay-as-you-go access across multiple model families, which can suit engineers using Gemini CLI alongside Claude Code, Codex, or OpenAI SDK applications. Create a Relay365 account if that shared billing and access arrangement fits your workflow, then confirm its current native Gemini setup instructions before saving your configuration.
Record the CLI version, base URL, authentication choice, and tested model without recording the secret. That gives the next shift enough information to reproduce the connection and investigate changes.
Further desk bulletins
| Date | Bulletin title | Filed under | Language |
|---|---|---|---|
| 2026-10-26 | Shift Note: Keep the Agent Context Lean | Agent shift notes | EN |
| 2026-10-26 | Shift note: PR review with an agent and a checklist | Agent shift notes | EN |
| 2026-10-26 | Shift Note: Tests Before the AI Writes the Function | Agent shift notes | EN |
| 2026-10-26 | Duty Log: Pairing With an AI Agent During an Alert | Agent shift notes | EN |
| 2026-10-26 | Desk note: Claude Desktop is not a relay client | Agent shift notes | EN |
| 2026-10-26 | Shift Note: Cline and Roo on a Fixed Monthly Budget | Agent shift notes | EN |
Curious how it runs on your own code? Sign up →