Skip to main content

LLM token cost estimator

OpenAI, Gemini & Claude API Cost Calculator

Paste a representative prompt, choose a model, and estimate cost per request plus daily, monthly, and yearly spend. No login or data upload is required.

Instant browser-side estimatesVersioned provider pricing snapshotsCopyable TypeScript formula

Estimate your API workload

Verified pricing snapshot

Change any input to update the estimate instantly.

Example workloads

Start with a representative prompt and output estimate, then adjust it for your application.

110 characters · 15 words

Estimated at four Unicode characters per token. Exact counts vary by provider, language, formatting, and model tokenizer.

Estimated input: 28 tokens

Paste a count from provider tooling or request logs to replace the approximate browser estimate.

%

Daily request volume

Total daily requests = requests per active user per day × active users per day.

The safety buffer is applied to input and output tokens before cost and context usage are calculated.

Private by design

Prompt text is estimated in this browser and is not stored, shared, or sent to a model provider. Token counts are approximate where provider tokenization differs. Privacy policy

API cost estimate

Estimate

OpenAI · GPT-4.1 mini

Shared links include model and numeric workload settings, never prompt text.

Total daily requests

1,000

100 requests × 10 active users

Estimated cost per request

$0.000565

Estimated daily cost

$0.5652

Estimated monthly cost

$16.96

30-day projection

Estimated yearly cost

$206.30

365-day projection

Context window usage

0.04%

378 buffered input + output tokens of a 1,047,576 token context window.

OpenAI GPT-4.1 mini model documentation · Verified Jul 31, 2026

Calculation basis

Input tokens after buffer
33
Output tokens after buffer
345
Total requests per day
1,000
Safety buffer
15%
Monthly projection
30 days
Yearly projection
365 days

Selected model pricing

Verified pricing snapshot
Pricing details for GPT-4.1 mini
ProviderOpenAI
ModelGPT-4.1 mini
Input / 1M tokens$0.40Applied
Output / 1M tokens$1.60Applied
Cached input / 1M$0.10
Last verifiedJul 31, 2026
SourceOpenAI model pricing

Standard text-token pricing. Batch API input and output rates are listed separately and are not applied by this calculator.

View provider pricing source (opens in a new tab)

Saved scenarios

Store numeric workload settings in this browser. Prompt text is never included. Export a backup to move scenarios between devices.

Up to 12 scenarios are stored locally on this device.

No saved scenarios yet.

Formula

How the API cost estimate is calculated

The safety buffer is applied before input and output token costs are calculated. The combined request cost is then multiplied by requests per active user and active users per day.

Total daily requests = requests per active user per day × active users per day

Request estimate = buffered input cost + buffered output cost

Monthly estimate = request estimate × total daily requests × 30

llm-cost.ts
type Workload = {
  inputTokens: number;
  outputTokens: number;
  requestsPerActiveUserPerDay: number;
  activeUsersPerDay: number;
  safetyBufferPercent: number;
};

type TokenPricing = {
  inputPricePerMillion: number;
  outputPricePerMillion: number;
};

export function estimateApiCost(
  workload: Workload,
  pricing: TokenPricing,
) {
  const bufferMultiplier =
    1 + workload.safetyBufferPercent / 100;

  const bufferedInputTokens = Math.ceil(
    workload.inputTokens * bufferMultiplier,
  );
  const bufferedOutputTokens = Math.ceil(
    workload.outputTokens * bufferMultiplier,
  );

  const inputCost =
    (bufferedInputTokens / 1_000_000) *
    pricing.inputPricePerMillion;
  const outputCost =
    (bufferedOutputTokens / 1_000_000) *
    pricing.outputPricePerMillion;
  const costPerRequest = inputCost + outputCost;

  const totalDailyRequests =
    Math.floor(workload.requestsPerActiveUserPerDay) *
    Math.floor(workload.activeUsersPerDay);
  const dailyCost = costPerRequest * totalDailyRequests;

  return {
    bufferedInputTokens,
    bufferedOutputTokens,
    totalDailyRequests,
    costPerRequest,
    dailyCost,
    monthlyCost: dailyCost * 30,
    yearlyCost: dailyCost * 365,
  };
}

Example API cost estimate

Suppose a support assistant sends about 1,000 input tokens and generates 300 output tokens. At 500 requests per day, even a small difference in output pricing compounds across a month.

Use a representative production prompt, include system instructions in the pasted text, and set output tokens near your observed average. Add a safety buffer when traffic or response length is uncertain.

What this estimate includes

  • Approximate prompt tokens from pasted text
  • Manually specified response tokens
  • Separate model input and output rates
  • Requests per active user multiplied by active users per day
  • Configurable input and output safety buffer
  • Daily, 30-day monthly, and 365-day yearly estimates

Frequently asked questions

How does this OpenAI API cost calculator work?

This OpenAI API cost calculator estimates prompt tokens from your text, adds expected output tokens and a safety buffer, then applies the selected model's input and output rates. Request volume converts the per-request estimate into daily, monthly, and yearly projections.

How do I calculate LLM tokens from text?

If you are learning how to calculate LLM tokens, a practical planning estimate is about four Unicode characters per token. Exact counts depend on the provider tokenizer, language, formatting, and code content, so this LLM token cost estimator should be treated as a budget estimate rather than a billing record.

Can I use this as a Claude API cost calculator?

Yes. Select Anthropic and a Claude model to use the corresponding versioned pricing snapshot. The Claude API cost calculator view uses the same buffered token and request-volume math as every other provider.

Can I compare Gemini API costs with other models?

Yes. Select a Gemini model to calculate its estimate, then review the comparison preview below the calculator. The Gemini API cost calculator applies the same workload to available OpenAI, Gemini, and Anthropic models so the monthly differences are comparable.

What does the safety buffer change?

The safety buffer increases both estimated input tokens and expected output tokens before pricing is applied. It helps account for system instructions, prompt wrappers, tokenizer differences, and responses that run longer than the expected average.

Are these provider prices live?

No. TokenMath uses versioned pricing snapshots with source labels and last-verified dates. Providers can change rates, tiers, regional premiums, and discounts without notice, so verify the linked provider pricing before making a production commitment.