Gemini API key: how to get one and what to do if it does not work

Two ways to a Gemini API key: a Google AI Studio key and a Zukko gateway key. Steps, request examples, safe storage and common problems.

6 min · · API keys · errors

A Gemini API key is a string by which the service recognizes who sends a request and whose balance to charge tokens to. There are two ways to get one: create a key in Google AI Studio, or take a gateway key through which Gemini 3.8 Flash is called in the ordinary OpenAI format. Below are both paths step by step, why a Google key often does not work from Russia, how to store a key, and what to check if requests are rejected.

The Google data comes from the ai.google.dev documentation as of October 18, 2026, and Zukko prices are for the same date. Interfaces change, so button names in your window may differ slightly.

Two paths compared

Google AI Studio keyZukko gateway key
Where it is createdGoogle AI StudioZukko dashboard
Key shapea Google stringfetch_...
ModelsGemini modelsGemini, Claude, GPT, DeepSeek, Qwen, GLM
Request formatnative Google or OpenAI-compatible layerOpenAI and Anthropic
Access from Russiadepends on Google services being available in the regionvia the gateway
PaymentGoogle Cloud account, prepaymentdollar balance: SBP, MasterCard, crypto
Limitsper Google projectconfigurable on each key

Path 1. A key in Google AI Studio

The steps per Google's documentation:

  1. Open Google AI Studio and sign in with a Google account. You must be 18+ and have verified your age in the account.
  2. Accept the terms of use. If you are a new user, AI Studio creates a Google Cloud project and a default key for you.
  3. Go to the API keys page (aistudio.google.com/apikey). For a new key click Create API key and choose a project.
  4. Copy the key and save it to an environment variable.

If you already have a Google Cloud account, AI Studio does not create a project itself: first import an existing project under Dashboard, then Projects, then Import projects, and only then create a key on the API keys page. If the create button is inactive and mentions missing permissions, you need a project administrator role (for example Project Editor) or a new project not tied to an organization.

Google's client libraries read the GEMINI_API_KEY and GOOGLE_API_KEY variables on their own (if both are set, GOOGLE_API_KEY wins):

bash
export GEMINI_API_KEY="your_google_key"

What to know about the keys themselves:

  • since May 28, 2026, new keys created in AI Studio are authorization keys bound to a service account and restricted to the Gemini API by default;
  • the Gemini API rejects requests from unrestricted "standard" keys, while keys with explicit restrictions keep working;
  • if a key ends up in public, Google blocks it and you will see a message that the key is marked as leaked: you need a new one.

Why a Google key often does not work from Russia

The Gemini API and Google AI Studio are not available in every country. Google's Available regions page lists countries and territories, and Russia is not on that list (the page was updated in April 2026). So the typical scenario is that a key cannot be created, AI Studio says the service is unavailable in the region, or direct requests are rejected. This is not a bug in your code and client settings cannot fix it. We do not recommend workaround schemes.

Path 2. A gateway key: Gemini 3.8 Flash in the OpenAI format

For work from Russia the second path is more practical. Access to Gemini goes through the Zukko gateway: payment by SBP, MasterCard cards or crypto, a dollar balance, no subscription.

  1. Sign up in the dashboard and confirm your email (without confirmation the API does not spend balance and returns 403).
  2. Open the API keys page and create a key: set a name and, if you like, a daily and monthly dollar limit and a list of allowed models (allowed_models).
  3. Copy the fetch_... key: the full key is shown once, afterwards you cannot view it, only issue a new one.
  4. Top up the balance. The minimum is $1. SBP is paid in rubles at the market rate, and the payment page adds 8.5% on top: for $5 that is 5 × 1.085 = $5.425 in conversion. MasterCard cards carry a fee of about 13%, amounts $2 to $594. Cryptocurrency is also available.
  5. Send a first request.
bash
export OPENAI_BASE_URL="https://api.zukko.pro/v1"
export OPENAI_API_KEY="fetch_your_key"
bash
from openai import OpenAI

client = OpenAI()  # reads OPENAI_BASE_URL and OPENAI_API_KEY

r = client.chat.completions.create(
    model="gemini-3.8-flash",
    messages=[{"role": "user", "content": "Write one line: key check"}],
)
print(r.choices[0].message.content)

The same through curl:

bash
curl https://api.zukko.pro/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gemini-3.8-flash","messages":[{"role":"user","content":"Hello"}]}'

The base address ends with /v1: that is how OpenAI SDK clients work. More on headers is in the authentication section, and the general order of steps is in the quick start.

What a call costs

Zukko prices as of October 18, 2026 for gemini-3.8-flash: $0.125 per 1M input and $0.6 per 1M output tokens. Context is 1M tokens, and only text is accepted as input. For comparison, the official prices from our table are $0.75 and $3.75.

Example: a request of 3000 input and 600 output tokens costs 3000 × 0.125 / 1,000,000 + 600 × 0.6 / 1,000,000 = 0.000375 + 0.00036 = $0.000735. A dollar covers about 1360 such requests (1 / 0.000735). Actual spend on Gemini 3.x models may be higher because of reasoning tokens, which per Google's documentation are billed as output, so run a hundred requests and look at the total in "Usage".

Current prices and the model list: GET https://api.zukko.pro/v1/models or the Models page in the dashboard.

How to store a key safely

The rules are the same for any key:

  • do not put a key in code or commit it to a repository: Google blocks a leaked key, and anyone can spend a gateway key;
  • use environment variables or a secrets manager;
  • create a separate key for each project so you can revoke them independently;
  • in the Zukko dashboard limit a key with a daily and monthly dollar limit and a list of models: even if it leaks, losses are bounded;
  • if you suspect a leak, issue a new key and revoke the old one. The procedure is in An API key leaked: what to do, and storage practices are in Safe storage of API keys.

The key does not work: what to check

ResponseWhat it meansWhat to do
401wrong keycheck for typos and whitespace; the key must start with fetch_
402insufficient balancetop up
403 model_not_allowed_for_keythe model is not allowed for the keyadd the model to the key's list
404 model_not_foundunknown model namecheck against GET /v1/models
429key limit exhausted or a provider restrictioncheck the key's daily and monthly limit
503provider unavailable or model switched offretry later or pick another model

If you work with a Google key, also check: whether a second variable is set in the environment (GOOGLE_API_KEY takes priority over GEMINI_API_KEY), whether the key was blocked as leaked, and whether it is an unrestricted "standard" key.

FAQ

How do I get a Gemini API key for free?

Google AI Studio has a free tier with limited quotas, and on it request content may be used to improve Google's products. Google changes the free-tier limits, so check its documentation for the current ones; availability depends on region.

Can I get a Gemini API key in Russia?

A direct Google key usually cannot be obtained from Russia: Russia is not in the Gemini API region list. A practical option is a Zukko gateway key, with payment by SBP, MasterCard or crypto.

Do I need to change my code if I already use the OpenAI SDK?

No, it is enough to set base_url="https://api.zukko.pro/v1", a fetch_... key and the model gemini-3.8-flash.

How many keys can I create?

You can create several keys, each with its own name, limits and list of allowed models. Create a separate key for each project.

zukko

Pay 25×
less

for Claude Code & ChatGPT

One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.

Get API keyDocumentation

api.zukko.pro · fetch_*

Gemini API key: how to get it and fix problems · Zukko