Relay365Multi-model API relay desk
← All desk bulletins
Agent shift notesEN641 desk reads

Connect Gemini CLI to a Native Gemini Relay

Pointing Gemini CLI at a relay requires two settings to agree: the destination receiving requests and the credential authorizing them. Changing only the API key can leave requests going to Google. Changing only the destination can send the wrong credential to the relay. This walkthrough keeps those choices together.

#1 · Confirm you need a native Gemini endpoint

Gemini CLI uses the Gemini API, not the OpenAI chat completions interface. Your relay must accept native Gemini requests, including the request paths and authentication headers used by the CLI. An OpenAI-compatible endpoint alone is not enough.

Relay365 is a pay-as-you-go relay desk covering Gemini and other model families. Its API base is https://api.api365relay.com. OpenAI clients add /v1, but do not copy that OpenAI-specific suffix into your Gemini CLI configuration. Confirm the relay's current native Gemini instructions before proceeding, including any required path prefix.

#2 · Prepare a relay key and check your CLI

Create an API key in your relay dashboard and confirm that the account has access to the Gemini model you want. A relay-issued key is a separate credential from a Google-issued Gemini API key.

Run gemini --version to identify your installed release. Use a current Gemini CLI release whose documentation supports GOOGLE_GEMINI_BASE_URL. If your release does not recognize that setting, update through your installation method rather than assuming the endpoint override worked.

Keep keys out of source files, screenshots, shared terminal transcripts, and committed settings. Avoid placing a literal key in a shell command that your terminal might save in history.

#3 · Set the endpoint and key together

In a Bash terminal, run export GOOGLE_GEMINI_BASE_URL='https://api.api365relay.com', provided that this matches the relay's documented native Gemini base.

Then enter the key without displaying it: read -r -s -p 'Relay API key: ' GEMINI_API_KEY; export GEMINI_API_KEY; printf '\n'. This is Bash syntax; use the equivalent secure input mechanism if you use another shell.

These settings apply to that shell and processes launched from it. Start Gemini CLI from the same terminal. A CLI already running elsewhere will not automatically inherit the changes.

#4 · Select API-key authentication, not Google login

Launch gemini. If prompted for authentication, select the Gemini API-key option. If the CLI previously used Google sign-in or Vertex AI, open /auth and switch to API-key authentication.

A successful browser login does not authorize a relay-issued key. Likewise, a relay key does not configure a Google Cloud project. Keep this setup on the Gemini API-key path.

Check for conflicting environment settings, particularly GOOGLE_API_KEY and GOOGLE_GENAI_USE_VERTEXAI. If they are unrelated to this test, remove them from the test shell with unset GOOGLE_API_KEY GOOGLE_GENAI_USE_VERTEXAI. Also inspect project or user environment files that might reintroduce conflicting values.

#5 · Test one explicit model

Choose a model available to your relay account, such as Gemini 2.5 Flash. Copy its exact API identifier from the relay's current model listing; a display name is not necessarily the identifier accepted by the API.

Run gemini --model YOUR_RELAY_MODEL_ID --prompt 'Reply with a short greeting.', replacing the placeholder. Start with a simple text request before trying repository analysis, tools, or large inputs.

Check the relay dashboard's usage or request records, where available, to confirm that the request reached the intended account. A response alone does not prove which endpoint handled it.

#6 · Troubleshoot before making settings permanent

  • Authentication failure: Check the relay key, selected authentication mode, and inherited environment variables.
  • Not found: Check native Gemini support, the documented base path, and the model identifier. Do not blindly append /v1.
  • Model unavailable: Check account access and the relay's current model listing.
  • Unexpected behavior: Confirm your CLI version and test in a fresh terminal without conflicting configuration.

Relay365 fits when you want pay-as-you-go access across multiple model families while retaining Gemini CLI's native workflow. Create a Relay365 account if that matches your needs, then validate this small test before persisting the endpoint and storing the key securely.

Further desk bulletins

Curious how it runs on your own code? Sign up →