← All articles

Gemini API: how to get a key, call the model, and what tokens cost

A glowing digital access key hovering over a dark keyboard surrounded by lines of code

The Gemini API is how you call Gemini models from your own code instead of a chat window: a support bot on your site, a script that triages tickets, code completion in an editor, a CRM integration. The classic route requires a Google account, cloud billing setup and a foreign card. On NeuralSpace the path is shorter: a key is created in your dashboard in about a minute, the model is called with an OpenAI-compatible request, and you pay from a token balance — no subscription. Below is a step-by-step guide: how to get a key, what your first call to Gemini 3.8 Flash looks like, and what tokens cost.

What the Gemini API is and who needs it

Gemini is Google's family of language models. Through the API it is open to developers: you send an array of messages, get a generated answer and use it in your product — show it to the user, store it, process it further. Typical use cases: support chatbots, summarising emails and documents, extracting structured data from text, drafting content, automating routine in scripts. Gemini 3.8 Flash in the NeuralSpace catalog is the fast branch of the family: a balance of speed and price that fits dialogues and bulk text processing.

Step 1. Get a key

  1. Sign up on NeuralSpace with your email — it takes under a minute. New users are credited starter tokens right away, enough for the first API calls without a top-up.
  2. Open the API keys page in your dashboard and create a key. The key looks like nsk-… and is shown once — save it immediately in a password manager or an environment variable, not in your repository.
  3. Check your balance: text models require a minimum of 50 tokens on the account. Top-ups happen in the dashboard — no foreign cards, no subscription fees.
The NeuralSpace API keys page: creating a key for the Gemini API

Step 2. Call the model

Gemini in the public API works through the OpenAI-compatible endpoint POST /v1/chat/completions: the body carries the model, a messages array with system / user / assistant roles, and the max_tokens limit. A minimal curl request:

curl https://neuralspace.pro/v1/chat/completions \
  -H "Authorization: Bearer nsk-your_key" \
  -H "content-type: application/json" \
  -d '{
    "model": "gemini-3-8-flash",
    "messages": [{"role": "user", "content": "Suggest three names for a neural network channel"}],
    "max_tokens": 500
  }'

The response comes back in the OpenAI format: the generated text is in choices[0].message.content, actual usage is in usage. If you already have OpenAI SDK code, exactly two values change — base_url and the key:

from openai import OpenAI

client = OpenAI(
    base_url="https://neuralspace.pro/v1",
    api_key="nsk-your_key",
)

resp = client.chat.completions.create(
    model="gemini-3-8-flash",
    messages=[
        {"role": "system", "content": "You answer technical questions briefly."},
        {"role": "user", "content": "How is streaming different from a regular response?"},
    ],
)
print(resp.choices[0].message.content)

Chat interfaces benefit from streaming: add "stream": true and the answer arrives in chunks via Server-Sent Events, so the user sees the first words before generation completes.

Step 3. Know what it costs

Billing is metered: input tokens (your prompt) and output tokens (the model's reply) are counted separately, each with its own per-million price. For Gemini 3.8 Flash, at the time of writing, it is 33.5 tokens per million input and 168 tokens per million output. A typical request of "2,000 context tokens + 500 output tokens" costs about 0.15 tokens. The price is exchange-rate-linked and floats, so check the live table before doing the math: it is published on the API documentation page and returned in machine-readable form by GET /v1/models. For comparison: DeepSeek V4 Flash in the same catalog is 21/42 tokens per million, Claude models are noticeably more expensive; Gemini 3.8 Flash sits in the middle on price while answering fast.

Two service limits: 60 requests per minute per key, and a 50-token minimum balance for text models. The current balance is available via GET /v1/balance, charges appear in your profile transaction history.

Gemini on the site — no code needed

If you do not need the API yet, the same models live in the interface: pick Gemini 3.8 Flash in the chat — web search is enabled there — and for images the image generation section offers Nano Banana, a model based on Gemini 2.5 Flash. The balance is shared: chat and API draw from the same account.

Common first-request errors

  • 401 Unauthorized — the key was passed incorrectly: an extra space, a truncated value, a wrong prefix. The full key goes after Bearer or in the x-api-key header.
  • 429 Too Many Requests — you hit the 60-requests-per-minute limit. Add a pause or a queue on your side.
  • Balance error — fewer than 50 tokens on the account: top up in the dashboard and retry.
  • Key leaked into git — keep it in environment variables (.env) and never commit it; if it leaks, reissue the key on the same API keys page.

FAQ

Do I need a Google account or a foreign card?

No. The key is issued in your NeuralSpace dashboard and you pay from a token balance: token-based billing, no subscription, no cloud billing.

How much does a Gemini API call cost?

Only the actual tokens: at the time of writing, 33.5 tokens per million input and 168 per million output for Gemini 3.8 Flash; a request of a couple thousand tokens is roughly 0.15 tokens. Current prices are in GET /v1/models and the documentation table.

Is there a free tier?

There are no free generations on the platform. New users get starter tokens — enough for first experiments — after that you pay per token with no subscription fee.

What else can the API do besides text?

With the same key you get image, video and music generation, speech synthesis and recognition, and an MCP server at https://neuralspace.pro/mcp for AI agents. The full endpoint list is in the documentation.