Gemini CLI · about 2 minutes

Gemini CLI with 9Coding

Gemini CLI supports a gateway address. Set two environment variables and Gemini calls in your terminal route through 9Coding with the same workflow, while one key still lets you choose the right model for the task.

Step 1 · Get a key

Create an API key in the 9Coding console; keys start with sk-9c-.

Step 2 · Change the endpoint

Gemini CLI detects a gateway address and then uses the matching key. On macOS or Linux, run:

terminal
export GOOGLE_GEMINI_BASE_URL="https://api.9coding.com"
export GEMINI_API_KEY="sk-9c-your-key"

Windows (PowerShell):

PowerShell
[Environment]::SetEnvironmentVariable("GOOGLE_GEMINI_BASE_URL", "https://api.9coding.com", "User")
[Environment]::SetEnvironmentVariable("GEMINI_API_KEY", "sk-9c-your-key", "User")
When Gemini is the right pick: choose Gemini Flash for very long documents or codebases, or when response speed matters most. Claude Opus is a better fit for hard reasoning; Claude Fable or GPT fit everyday coding. One key covers them all, so the model name is the choice you change.

Step 3 · Verify the connection

Open a new terminal, run the command below, and send a test message. Gemini CLI must reply and the matching call must appear on the 9Coding console's Logs page. Both checks must succeed.

terminal
gemini
# Enter: Reply only: Gemini connected

Troubleshooting

  • Model not found — the Gemini 3.5 series is available; the full list lives in the console.
  • 400 in a multi-turn chat — trim the message history, then check every turn's role and content shape.
  • Multimodal input — pass image_url content blocks exactly as the OpenAI specification describes.
  • Billing — Gemini bills like every other model: from your balance, at the official price list, for exactly what you call.
  • The variables do not take effect — open a new terminal before running gemini; make sure the address has no /v1 suffix and the key has no stray whitespace.