Creating a Gemini API key takes a minute: open aistudio.google.com/apikey and press Create API key. The catch is the region. Russia is not among the countries where the Gemini API works, so an official Google key cannot be issued from here. The Gemini models are still reachable through the codexkey gateway, with an ordinary OpenAI-compatible client, an sk_cdx_... key and payment in rubles.
How to create a Gemini API key in Google AI Studio
If you are in a supported country, the path is short. According to Google's documentation:
- Open
aistudio.google.com/apikey. - Press Create API key. Keys from AI Studio now get the auth key type by default.
- Save the value in the
GEMINI_API_KEYvariable.GOOGLE_API_KEYworks too, but if both are set, the second one takes priority.
The first request from the quickstart:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3.8-flash",
"input": "Explain how AI works in a few words"
}'
Sometimes the key or the project does not show up in the list. In that case Google suggests pressing Import projects in the Projects section and creating the key on the API Keys page.
The client libraries are google-genai for Python (pip install -U google-genai) and @google/genai for JavaScript. Google is strict about the key itself. Treat it as a password, keep it out of Git and out of client-side code, and restrict it to the Gemini API alone, because the service now rejects unrestricted standard keys.
Free Gemini API: quotas and prices as of 29 October 2026
First, names, because a search for "gemini flash api" leads to several models at once. Google's models page calls Gemini 4 Argon (gemini-4-argon) the flagship, with a context of 1 million tokens. Gemini 3.8 Flash (gemini-3.8-flash) is presented as the strongest Flash model, offered for long coding tasks and autonomous agents. Gemini 3.6 Flash remains the stable model of the previous generation. We suggest starting with Flash. It is cheaper, and whether you need Pro is something a run on your own requests will show.
Not every model has a free tier. The data below comes from the Gemini API pricing page, with Google's prices in dollars per million tokens:
| Model | Free tier | Paid tier |
|---|---|---|
| Gemini 3.8 Flash | Yes | Input $0.75, output $3.75 until 31 December 2026, then $1.50 and $7.50 |
| Gemini 3.1 Pro | No | Input $2.00, output $12.00 for requests up to 200k tokens, $4.00 and $18.00 above that |
| Nano Banana Pro (images) | No | $0.134 per image at 1K and 2K, $0.24 at 4K, see the review |
What you need to know about the free tier. Google does not state requests-per-minute and requests-per-day limits on that page. AI Studio shows them, and the company adds that the stated limits are not guaranteed. Free-tier data is used to improve Google's products, while on the paid tier that column says "no". Do not send client data or internal code there.
To move to the paid tier, link a billing account and top up at least $5, the rules are on the billing page. After that the tiers grow with accumulated spend: the second opens after $100 and three days since the first payment, the third after $1000 and 30 days (see the limits section of the documentation).
Gemini API in Russia: why no key is issued and what to avoid
The list of regions for the Gemini API and AI Studio does not include Russia (checked on 29 October 2026). The official service works only in the countries listed. This is a region restriction, not a payment glitch.
What we advise against:
- Buying "ready-made Gemini keys" from resellers. A key is free to create, so there is nothing to sell, and someone else's key can be revoked at any moment together with your data.
- Faking your country and payment details. The account can be sent for review, and access may vanish in the middle of a project.
- Putting your own key in a repository or a chat. For a leaked key, Google recommends replacing it and disabling the old one.
In short, the vendor does not support your country, but a gateway that pays for the calls itself and accepts rubles leads to the same models. The same principle works for Claude, see Claude API in Russia.
Gemini through codexkey: models, prices and a call
The codexkey catalog as of 29 October 2026 holds three Google text models. Prices are in dollars per million tokens, taken from the codexkey price list of 29 October 2026, and current values are on the models page:
| ID | Context | Input | Output | Cache read |
|---|---|---|---|---|
gemini-3.1-pro | 1000K | $0.24 | $1.44 | $0.04 |
gemini-3.7-flash | 1000K | $0.2 | $0.96 | $0.02 |
gemini-3.8-flash | 1000K | $0.2 | $0.96 | $0.02 |
Two clarifications. First, Google's models page no longer mentions gemini-3.7-flash: it lists 3.8 Flash and 3.6 Flash, and names Gemini 4 Argon as the new flagship. The codexkey catalog has no Argon as of 29 October. Second, compare prices at your own volume, because Google's 3.8 Flash price stays as listed until 31 December 2026 and doubles from 1 January.
The call goes through the OpenAI-compatible endpoint https://api.codexkey.online/v1. You do not need a Google account for it:
from openai import OpenAI
client = OpenAI(
base_url="https://api.codexkey.online/v1",
api_key="sk_cdx_YOUR_KEY",
)
response = client.chat.completions.create(
model="gemini-3.8-flash",
messages=[{"role": "user", "content": "Explain the difference between Flash and Pro in three sentences"}],
max_tokens=300,
)
print(response.choices[0].message.content)
The same request through curl:
curl https://api.codexkey.online/v1/chat/completions \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gemini-3.8-flash", "messages": [{"role": "user", "content": "Hello"}]}'
The list of available IDs comes from GET https://api.codexkey.online/v1/models. The endpoint accepts model, messages, temperature, max_tokens and stream, with details in the OpenAI compatibility section. Do not use features that exist only in Google's native API through it without checking: make a test request first. How to issue a key and top up the balance is described in the quickstart.
How much the Gemini API costs: a worked example
The formula: (input tokens ÷ 1 000 000) × input price + (output tokens ÷ 1 000 000) × output price. The assumptions in the example are ours, so plug in your own: 100 000 requests a month, 2 000 input tokens and 500 output tokens each. That makes 200 million input tokens and 50 million output tokens. We take the codexkey prices from the table above and ignore the cache:
| Model | Input | Output | Total per month |
|---|---|---|---|
gemini-3.8-flash | 200 × $0.2 = $40 | 50 × $0.96 = $48 | $88 |
gemini-3.1-pro | 200 × $0.24 = $48 | 50 × $1.44 = $72 | $120 |
The math is in dollars, and the exchange rate floats, so convert to rubles on the day you top up. Flash and Pro land close together in this scenario, so choose by answer quality, not by price list. Take 30 real requests, run them through both models and count how many answers pass your check. Then divide the spend by the number of accepted answers. That shows the true price of a result.
Before going to production, look at the gateway rate limits to see how many parallel calls your key can sustain.
Which path to choose: a Google key or codexkey
| Situation | What to choose |
|---|---|
| Your country is on Google's list and you need a free prototype | An AI Studio key and Gemini 3.8 Flash, remembering that free-tier data goes into improving products |
| You need features of Google's native API | A direct Google key, if your country is supported |
| Russia, and you need Gemini in a script or service | A codexkey key and gemini-3.8-flash or gemini-3.1-pro |
| One codebase for Gemini, Claude and GPT | One codexkey key, only model changes, see the Claude and Gemini comparison |
| Google image generation | nano-banana-pro and other models in codexkey, covered in Nano Banana free: what Gemini includes |
If you are weighing gateways against direct APIs as a whole, the piece on AI model aggregators will help.
FAQ
How do I get a Gemini API key?
Go to Google AI Studio at aistudio.google.com/apikey, press Create API key and save the value in GEMINI_API_KEY. From Russia, Google does not give this access. The fallback is a codexkey key and an OpenAI-compatible call to Gemini models.
Is the Gemini API really free?
Partly. As of 29 October 2026 Gemini 3.8 Flash has a free tier, but Google uses its data to improve products. Gemini 3.1 Pro and the image models have no free tier. Google shows the exact request limits only in AI Studio.
Does the Gemini API work in Russia?
No, Russia is not on the list of regions for the Gemini API and AI Studio. A native Google key cannot be used from Russia, while Gemini models can be called through the codexkey gateway without a Google account.
Where can I get a Gemini API key, and can I buy one?
Officially a key is issued free in AI Studio, and you pay only for tokens once billing is on. Ready-made keys from resellers are not worth buying: it is someone else's key, and it can be revoked. Get your own key from a gateway.
Which Gemini models does codexkey have?
gemini-3.1-pro, gemini-3.7-flash and gemini-3.8-flash, all with a 1000K context. The current list comes from GET /v1/models. Google's new flagship, Gemini 4 Argon, is not in the catalog as of 29 October 2026.
How is Gemini Flash different from Pro in the API?
Flash is tuned for speed and volume. Google describes 3.8 Flash as the strongest Flash model for long coding tasks and autonomous agents. Pro costs more and is picked for hard reasoning. Test both on your own examples and work out the price of one usable answer.
Can I call Gemini through the OpenAI SDK?
Yes. Google has its own compatible endpoint: put https://generativelanguage.googleapis.com/v1beta/openai/ in base_url, put the Gemini key in api_key, and Google's examples use the model gemini-3.8-flash. From Russia it is closed for the same reason as the rest of the API. With codexkey you change only base_url to https://api.codexkey.online/v1 and the key to sk_cdx_....