Set up Gemini CLI

Gemini CLI speaks Google's native protocol, which the platform serves directly.

This guide connects Gemini CLI to the platform so you can reach Claude, GPT, Gemini and others with a single token. Three values are all you need: endpoint, token, model name.

Create a token (starting with sk-) in the console first and make sure the account has credit. New here? Start with your first request in 5 minutes.

Configuration

Point Gemini CLI at the platform with environment variables and use your platform token as the key.

Field Value
Base URL https://api.router.ai
API Key your sk- token
Model gemini-3.1-pro-preview
export GOOGLE_GEMINI_BASE_URL=https://api.router.ai
export GEMINI_API_KEY=sk-your-token

gemini -m gemini-3.1-pro-preview

Verify

Before running anything complex, just say hello and check you get a reply. To test the token on its own, call the API directly:

curl https://api.router.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-token" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-3.1-pro-preview","messages":[{"role":"user","content":"hello"}]}'

A JSON response containing choices means you are connected. The call shows up in your billing records shortly after.

Troubleshooting

The platform serves both Google's native format (/v1beta/models/{model}:generateContent) and the OpenAI-compatible one. Gemini CLI uses the former, so do not add /v1 to the URL. Use catalog model names such as gemini-3.1-pro-preview or gemini-3.5-flash.

401

Wrong token, a stray space, or a copy that dropped the leading sk-. Copy it again in full.

404

Almost always the URL suffix. The OpenAI-compatible format needs a trailing /v1; the native Anthropic and Gemini formats must not have it. Check the table above.

402 / insufficient balance

The account is out of credit. See top-up methods.

Model not found

Model names must match the catalog exactly, including case and hyphens. Copy the exact name from the models page.

Related articles

Blog