Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Estimate an LLM API request by multiplying its input and output token counts by the current rates for the specific provider, model, endpoint, and billing categories. The Colab calculator below does that arithmetic and can project a user-entered workload. It is an estimate—not a guaranteed invoice—because the exact request, model usage, and rate card can change the result.

What are you billed for?

For a basic request priced per million tokens, estimate cost as:

((input tokens × input rate) + (output tokens × output rate)) ÷ 1,000,000

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Input and output are separate billing dimensions, and their rates often differ. Some rate cards also price cached input or other categories separately. Add those terms only when the chosen provider and model support them; this tutorial’s calculator intentionally omits cached tokens, cache storage, tools, and other separately billed categories.

For a dated arithmetic example, Google lists Gemini 3.8 Flash standard paid rates through December 31, 2026, of $0.75 per million input tokens and $3.75 per million output tokens. At those rates, a hypothetical request with 1,000 input tokens and 500 output tokens estimates to (1,000 × $0.75 + 500 × $3.75) ÷ 1,000,000 = $0.002625. Google’s pricing page lists $1.50 input and $7.50 output per million tokens beginning January 1, 2027. These are provider-published Gemini rates for the stated pricing mode and dates, not a cross-provider benchmark or a measured request. Check the Google Gemini Developer API pricing page immediately before using rates; prices and categories can change.

How do I count tokens?

A token is not the same as a word. Tokenizers can split words, punctuation, and other text differently, so a character or word-count conversion is not a dependable universal rule. Google says, “For Gemini models, a token is equivalent to about 4 characters.” Treat that as a rough Gemini text heuristic, not an exact formula and not a rule for other providers.

A local text counter can also miss parts of the actual API input: message roles and boundaries, tools, schemas, files, images, or provider-specific formatting may contribute to the request. For better estimates, use the provider’s count-before-send method on the complete input where available. Google documents Gemini’s count_tokens method; OpenAI documents an input-token counting endpoint for complete Responses API input. After sending a request, compare the estimate with the usage metadata returned by the API.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Provider documentation: Google: Understand and count tokens and OpenAI: Counting tokens.

Build the calculator in Colab

Open a new Colab notebook, add a code cell, and paste this Python. It accepts token counts and rates in dollars per million tokens, calculates a single-request estimate, then optionally multiplies it by a user-entered monthly scenario. The example’s model and rates are explicitly labeled; replace them with the applicable current rate card before relying on the result.

# Estimate only: standard paid Gemini 3.8 Flash rates through 2026-12-31.
# Replace these values after checking the provider's current pricing page.
provider = "Google"
model = "Gemini 3.8 Flash"
pricing_mode = "standard paid"
rate_checked = "2026-10-11"
currency = "USD"

input_price_per_million = 0.75
output_price_per_million = 3.75
input_tokens = 1000
output_tokens = 500

estimated_cost = (
    input_tokens * input_price_per_million
    + output_tokens * output_price_per_million
) / 1_000_000

print(f"{provider} {model} ({pricing_mode}; {currency}; rates checked {rate_checked})")
print(f"Estimated cost per request: ${estimated_cost:.8f}")

# Optional usage scenario. Enter your own expected workload.
requests_per_day = 100
days_in_period = 30
estimated_period_cost = estimated_cost * requests_per_day * days_in_period
print(f"Estimated cost for {requests_per_day} requests/day × "
      f"{days_in_period} days: ${estimated_period_cost:.4f}")

The code uses assumed counts and rates; it does not send a request, identify a tokenizer, or retrieve live prices. Change the counts to the provider/model-specific count for your complete request and the output you expect. Edit the daily request count and period length to model another workload. The projected total is a scenario based on those inputs, not a forecast or invoice prediction.

Why can the estimate differ from the bill?

  • Tokenizer and request structure: Plain text counts may omit roles, formatting, tools, schemas, images, files, or other parts of the API request. A provider count-before-send or actual response usage is more relevant than a generic text estimate.
  • Output and reasoning: Generated output is billed separately from input where the rate card distinguishes them. Some models also report reasoning or thinking usage; do not assume it is absent or billed like ordinary input. Check the model’s pricing and usage definitions.
  • Cached input and storage: Providers can price cached tokens differently, and storage duration may be a separate billing factor. Google’s Gemini billing guidance identifies input, output, cached-token count, and cached storage duration as billing factors. The simple code above does not include them.
  • Rate-card changes: Rates can be model-, endpoint-, pricing-mode-, and date-specific. Keep the provider, model, currency, pricing mode, and date checked with your assumptions; do not reuse an old rate as though it were current.

For a reconciliation, compare the estimate against the API response’s usage details. OpenAI responses can report input, output, and total usage, with cached-input and reasoning details in some cases. Google’s interaction usage can report input, output, thinking, cached, tool-use, and total counts. The available fields depend on the provider and response. See OpenAI’s API usage and costs guidance and Google’s token guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How should you compare models?

Do not choose by input price alone. Compare rates and token usage for the same representative task, including expected output and any separately billed categories. A lower rate per million tokens may still cost more for a particular job if the model uses more tokens or generates more output.

What to compare What to record
Provider and model Exact model and API endpoint
Pricing basis Pricing mode, currency, and date checked
Input Provider-appropriate input token count and input rate per million
Output Expected or observed output token count and output rate per million
Other categories Cached-input, cache-storage, reasoning, or other rates when applicable
Result Estimated cost for the same representative request or workload

Use actual API usage from representative requests when possible, then apply the corresponding dated rate card. OpenAI’s pricing page separates input, cached-input, cache-write, and output rates by model; Google’s Gemini pricing and billing pages likewise define model and billing categories. Recheck both before comparing: OpenAI API pricing, Google Gemini Developer API pricing, and Google Gemini API billing.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.