EN ▾
Get API key
gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc gemmaapi.cc

Gemma 4 API Cost: Token Math and Budget Examples

The gemma 4 api cost here is $0.15 per 1M input tokens and $0.50 per 1M output tokens, paid from prepaid credit. This page gives you the formula, worked examples and a way to estimate a monthly budget.

Updated

Balance scale weighing glowing token cubes against coins, illustrating per-token API cost

Key points

  • Input costs $0.15 per 1M tokens, output costs $0.50 per 1M tokens.
  • A 2,000-in, 500-out chat turn costs $0.00055, so 1,000 turns cost $0.55.
  • Failed or refused requests are not charged, and credit never expires.
  • Top-ups of $50, $100 and $200 add a 5%, 10% and 15% bonus.

The formula

You pay for tokens in and tokens out, each at its own rate. For one request:

cost = (input tokens / 1,000,000 x $0.15) + (output tokens / 1,000,000 x $0.50)

Per 1,000 tokens, that is $0.00015 for input and $0.0005 for output. Output is a little over three times as expensive as input, so a chatty answer costs more than a long prompt of the same size. There is no subscription, no minimum per month and no charge for failed or refused requests.

A note on scope. This is an independent OpenAI-compatible API serving one open-weight model under the ID uncensored. It is not Google's official Gemma service, so numbers from Google's pricing do not apply here. If you compare, check their current pricing yourself.

Because the rates are fixed and billing is per token, the cost of a request is known the moment you know its size. There are no tiers that change the rate as you grow, no seat fees and no charge for idle time. A key that sits unused for a month costs nothing, and credit stays in your balance until you spend it.

Worked examples

All figures below are computed from the two rates above. Check any of them by running the formula.

RequestInputOutputCost
Short question300 tokens200 tokens$0.000045 + $0.0001 = $0.000145
Chat turn with history2,000 tokens500 tokens$0.0003 + $0.00025 = $0.00055
Long document summary50,000 tokens2,000 tokens$0.0075 + $0.001 = $0.0085
Full window, long answer90,000 tokens10,000 tokens$0.0135 + $0.005 = $0.0185

The last row fills the whole 100,000-token context window, prompt and completion together, and it still costs under two cents. Prompt-heavy work such as summarising a long file is cheap. Output-heavy work, such as generating long stories, is where the bill grows.

A batch job

Say you classify 10,000 support tickets, each about 1,000 tokens in and 300 tokens out.

  • Input: 10,000 x 1,000 = 10M tokens, which is 10 x $0.15 = $1.50
  • Output: 10,000 x 300 = 3M tokens, which is 3 x $0.50 = $1.50
  • Total: $3.00

Estimate a monthly budget

Take your daily request count, multiply by the average tokens per request, then apply the rates. A worked case: a small app that makes 5,000 requests a day, each averaging 1,500 input tokens and 400 output tokens.

  1. Cost per request: (1,500 x $0.15 / 1M) + (400 x $0.50 / 1M) = $0.000225 + $0.0002 = $0.000425
  2. Per day: 5,000 x $0.000425 = $2.125
  3. Per 30 days: 30 x $2.125 = $63.75

The same arithmetic in code makes it easy to try other numbers:

IN_PRICE = 0.15   # dollars per 1M input tokens
OUT_PRICE = 0.50  # dollars per 1M output tokens

def cost(tokens_in, tokens_out):
    return tokens_in / 1e6 * IN_PRICE + tokens_out / 1e6 * OUT_PRICE

per_request = cost(1500, 400)
print(round(per_request, 6))            # 0.000425
print(round(per_request * 5000 * 30, 2))  # 63.75

Two caveats. Chat apps resend the whole history each turn, so input tokens grow as a conversation gets longer; budget for the average, not the first message. And the figures assume you stay inside the rate limits (8 concurrent requests and 300 per minute on a full key), which is a throughput matter rather than a price one.

Context length and cost

The context window is 100,000 tokens, shared by prompt and completion. That is large enough that cost, not capacity, is the real limit for most projects. Filling the window with a 100,000-token prompt costs 100,000 / 1,000,000 x $0.15 = $0.015 before any output. Do that 1,000 times and the input side comes to $15.00.

Long-running conversations are where the window matters most. A roleplay or companion session that starts at 500 tokens may reach 40,000 tokens after a long evening. If every turn re-sends the full history, the last turn alone costs 40,000 / 1,000,000 x $0.15 = $0.006 in input. Averaged over the session, the cost per turn is far lower, but it is still worth summarising early parts of the story once they are no longer needed for continuity.

The completion can use whatever room is left in the window, so a very long reply is possible. Set max_tokens when you want a firm bound on output spend.

Measure real usage instead of guessing

The API returns token counts in the response, so you do not need to estimate. For streamed requests, usage arrives at the end of the stream. Log it and you can reconcile your own totals against your balance.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.gemmaapi.cc/v1",
    api_key=os.environ["API_KEY"],
)

r = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Summarise the plot of Hamlet in 3 sentences."}],
    max_tokens=200,
)
u = r.usage
usd = u.prompt_tokens / 1e6 * 0.15 + u.completion_tokens / 1e6 * 0.50
print(u.prompt_tokens, u.completion_tokens, round(usd, 6))

The response headers also carry X-Balance-USD, your remaining credit. Compare it before and after a batch and it should match your computed total. The docs show how to read usage on streams.

Ways to keep the bill down

  • Trim history. Input is cheaper than output, but a 30-turn history sent every time adds up. Summarise old turns into one short message.
  • Cap the answer. Setting max_tokens is optional, but a ceiling prevents a runaway reply from costing more than you planned.
  • Use stop sequences. The stop parameter is passed through, so you can end a completion at a delimiter.
  • Ask for structure. JSON mode (response_format with json_object) tends to give short, parseable answers instead of prose around them.
  • Batch what you can. Several small questions in one prompt share a single system message.

Top-ups, bonuses and the trial

You pay in advance. Any whole amount from $20 to $500 is accepted, and the bonus rises with the size:

Top-upBonusCreditChat turns at $0.00055
$20none$20.00about 36,400
$50+5%$52.50about 95,500
$100+10%$110.00about 200,000
$200+15%$230.00about 418,200

Pay by crypto (USDT on TRC20, USDC on Base). Credit never expires, so a large top-up cannot go to waste.

Before paying anything, you can claim the $0.50 trial on the API key page. It is valid for 7 days, needs no card and covers roughly 900 turns of the size in the table above. For a summary of rates and bonuses, see the pricing page.

Input and output in a typical workload

Whether input or output dominates your bill depends on the job, and the two rates make the split easy to predict.

  • Summarising, classifying, extracting. Long input and short output. A 20,000-token document with a 400-token summary costs $0.003 + $0.0002 = $0.0032. Input is about 94% of that.
  • Story writing and roleplay. Moderate input and long output. With 3,000 tokens in and 1,500 out, the cost is $0.00045 + $0.00075 = $0.0012, and output is 62.5% of the total.
  • Tool use and agents. Many short calls with growing context. Each round re-sends earlier tool results as input, so the input side climbs with every step. Keep tool results short.
  • Code and structured data. Balanced. Output is usually bounded by the schema you ask for.

If your bill looks higher than expected, the first thing to check is average input size per request, because history and pasted context creep up quietly. The second is runaway output, which a sensible max_tokens prevents. Neither needs a pricing change, only a prompt change.

Questions and answers

How much does 1 million tokens cost?

One million input tokens cost $0.15 and one million output tokens cost $0.50.

Am I charged for failed requests?

No. Failed or refused requests are not charged.

Does the cost change with long prompts?

Only through the token count. Prompts up to the 100,000-token window are billed at the same $0.15 per 1M input rate.

Is there a monthly fee?

No. It is pay as you go from prepaid credit with no subscription, and the credit never expires.

Are these Google's Gemma prices?

No. This is an independent API serving one open-weight model, so Google's pricing does not apply. Check Google's current pricing separately if you compare.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.