59API

← सभी गाइड पर लौटें

Gemini CLI API proxy setup with 59API: 2 settings

Claude Code · EN · 2026-11-05

Why Gemini CLI setup usually turns into a configuration puzzle

Gemini CLI is a good tool to have in your terminal. The friction often starts one step later: pointing it at an API proxy without rewriting your workflow. You edit environment variables, restart the shell, run a prompt, and wait. If the base URL is wrong, if the key lands in a variable the client ignores, or if you reach for an OpenAI-style endpoint, you get errors that look like network trouble even though your key is fine.

The fix is small. There are two settings to get right, and once they are in place you can use Gemini models through 59API with the client you already run. You do not need to change your editor, your prompts, or your habits. This is not a new SDK to learn; it is an existing client pointed at a different API host.

This guide covers the setup end to end: the exact environment variables, the protocol boundary that trips people up, the Gemini model ids and per-token rates available through 59API, and how prepaid billing works after the first request succeeds. It is written for a developer who wants a working connection quickly and a clear picture of the bill afterwards.

What 59API gives you before you write any code

59API is an independent third-party AI API relay. One account gives you one API key and one API host, https://api.59api.com, and through that single setup you can reach Claude, GPT, Gemini, DeepSeek and other models. It is not an official channel for any model provider and does not pretend to be one; it is a relay that routes requests to the models you ask for.

Billing is prepaid and metered by real token usage. You top up a balance, and each request draws down that balance according to the model's input, output and cache-read rates. There is no monthly fee, and your balance never expires, so an unused top-up is not a deadline. Monthly and weekly cards are optional extras for specific model families, but they are not required to get started.

For a Gemini CLI user, the practical appeal is simple: one key, one host, one balance, and a short list of Gemini model ids you can switch between without creating a second account anywhere else. The account, key and host are the whole configuration surface for Gemini CLI. That keeps the decision reversible: if one model does not suit a task, you pick another id from the same account.

The exact two settings for Gemini CLI

Open a terminal and set two variables for Gemini CLI:

Replace the placeholder with the key from your 59API account, export both for the current session, and make them permanent in the shell profile you actually use so a new terminal inherits them. Restart Gemini CLI after changing the variables so it picks up the new environment, then send a short prompt.

One boundary matters more than anything else here: Gemini models speak Google's native protocol. They are not OpenAI-compatible, and they do not work on /v1/chat/completions. That is why GOOGLE_GEMINI_BASE_URL points at the host root rather than an /v1 path. There is no SDK code to paste, no adapter to maintain, and no client-side rewrite.

The same distinction applies elsewhere in 59API. Codex, OpenAI SDKs, cURL and OpenAI-compatible clients such as Cursor, Cherry Studio, Cline and OpenCode work with GPT, DeepSeek and other non-Claude, non-Gemini models, using base_url https://api.59api.com/v1 and the chat endpoint https://api.59api.com/v1/chat/completions. Claude models work only through the genuine Claude Code or Claude Desktop client, version 2.1.285 or newer. Gemini belongs in Gemini CLI, on its own native path.

Gemini model rates you can pick from

Once the connection works, the next question is what it costs. 59API prices per 1 million tokens, with billing in CNY and USD figures shown at ¥7.2 = $1. Gemini 2.5 Flash, model id gemini-2.5-flash, is listed at input $0.2083 (¥1.5), output $1.67 (¥12) and cache read $0.0208 (¥0.15).

Gemini 3.1 Pro, model id gemini-3.1-pro, is input $1.39 (¥10), output $8.06 (¥58) and cache read $0.1389 (¥1). Gemini 3.8 Flash, model id gemini-3.8-flash, is input $1.11 (¥8), output $5 (¥36) and cache read $0.1111 (¥0.8). Gemini 4 Argon, model id gemini-4-argon, is input $1.39 (¥10), output $6.67 (¥48) and cache read $0.0694 (¥0.5).

Because the rate depends on the model id, moving between a flash model and a heavier pro model is a configuration change rather than a new purchase. Cache reads are metered separately, so repeated context can cost less than resending it as fresh input.

Several Gemini entries sit well below the Claude and GPT entries on the same rate card, which matters if your workflow leans on a lighter model for routine calls and a stronger one for hard tasks. Check the current rate for the exact id before you commit a long session to it, since pricing is per token and adds up with volume.

Prepaid balance, top-ups and optional cards

59API uses a prepaid balance, so the first practical step after configuration is topping up. Top-ups come in ¥10, ¥50, ¥100, ¥200, ¥500 and ¥1000, paid by WeChat Pay or bank card, and invoices are available. There is no monthly fee, and balance never expires, so a small top-up is a reasonable way to test the connection before you decide how much to keep on the account.

Charging happens per request against real token usage, so the number of prompts you can run depends on the model and the size of the payloads. Because there is no subscription hanging over you, you can top up in small increments and let the balance sit until your next session.

Monthly and weekly cards are optional and carry their own key, quota and weekly caps. A card pays only from its own quota and never falls back to your wallet balance, and a balance key never draws on a card. Unused quota does not roll over. Cards cover specific model families such as Claude and GPT, so for Gemini your prepaid balance is the straightforward route.

One more detail worth knowing: quota and caps on cards are metering units written in $, not official list-price dollars. Read them as card meters rather than as a comparison with any provider's published rate.

A one-minute verification pass and your next step

A clean verification takes a minute. Start a new terminal so the exported variables are loaded, run Gemini CLI, and send a short one-line question. If the answer comes back, the base URL and key are correct and the model id is being accepted.

If it fails, work through the likely causes in order. A rejected key usually means the placeholder was not replaced or the wrong string was pasted. A path error means the base URL points at an OpenAI-style route rather than the Gemini host root. A model-not-found message usually means the id is not one of the Gemini entries listed for the account, so check the spelling of gemini-3.1-pro, gemini-3.8-flash, gemini-2.5-flash or gemini-4-argon.

If you are moving between clients, remember that Gemini does not belong in an OpenAI-compatible tool. 59API keeps those paths separate on purpose, so the Gemini CLI configuration stays clean while GPT, DeepSeek and other non-Claude, non-Gemini models run through base_url https://api.59api.com/v1.

So is 59API worth trying for Gemini CLI? The case is short: two settings, one host, native Gemini protocol, and prepaid per-token pricing with no monthly fee. If you want to test the connection, top up a small amount, set GOOGLE_GEMINI_BASE_URL and GEMINI_API_KEY, and run your first prompt. If the numbers on the rate card look reasonable for your workload, you have a working setup and a clear bill.

दस्तावेज़

शुरू करने के लिए तैयार?

Claude, GPT और अन्य मॉडलों के लिए एक ही key, असली token उपयोग पर बिलिंग और कोई मासिक शुल्क नहीं। साइन अप करके अपनी API key बनाएं; हर मॉडल की दरें मूल्य पेज पर हैं।

मुफ़्त साइन अप मूल्य