Cheap AI API: How to Calculate Actual Costs
Price per million tokens is often confusing. Here you learn how to calculate AI API costs from input and output tokens, with example figures you can verify yourself.

Updated

Key points
Price: $0.15 per 1 million input tokens and $0.50 per 1 million output tokens.
An average conversation (2,000 input tokens, 500 output) costs $0.00055.
Resubmitted chat history is the largest cost driver and can be trimmed.
Failed or rejected requests are not charged, and credit never expires.
Short answers
If you are looking for a cheap AI API, the useful metric is not the price per request, but the cost per million tokens. At this service, the price is $0.15 per 1 million input tokens (prompt) and $0.50 per 1 million output tokens (model response). You pay from prepaid credit, with no monthly subscription.
The simplest example: one request with 2,000 input tokens and 500 output tokens costs $0.00055. A thousand such requests cost only $0.55. The section below shows how to arrive at that figure and where bills usually swell unnoticed.
Official pricing details are on the pricing and top-up page. This article focuses on how to calculate, not on a price list.
Basic formula: input tokens plus output tokens
A request bill consists of two parts with different rates. Output tokens are more expensive than input tokens, so long responses feel more expensive than long prompts of the same size.
biaya = (token_masuk x 0.15 / 1.000.000) + (token_keluar x 0.50 / 1.000.000)
Tokens are not words. For Indonesian text, one word usually takes more than one token, so do not guess from the word count. The most honest way is to read the usage field in the API response, which reports input and output tokens for each request.
Two things are not billed: failed requests and rejected requests are not charged. You also do not pay monthly fees or minimum fees, as the system is prepaid.
Calculation examples for four scenarios
The following table is calculated directly from the rates above. You can verify each row with a calculator.
| Scenario | Input tokens | Output tokens | Cost per request | Cost for 1,000 requests |
|---|---|---|---|---|
| Short chat reply | 500 | 200 | $0.000175 | $0.175 |
| Chat with context | 2,000 | 500 | $0.00055 | $0.55 |
| Document summary | 20,000 | 800 | $0.0034 | $3.40 |
| Very large context | 90,000 | 2,000 | $0.0145 | $14.50 |
How to calculate the second line: 2,000 x 0.15 / 1,000,000 = $0.0003 for input, then 500 x 0.50 / 1,000,000 = $0.00025 for output. Total $0.00055.
The last line approaches the 100,000 token context window limit, which includes both prompt and answer. Even at that limit, one request is still about one and a half cents.
A small project can be calculated the same way. A bot handling 300 requests per day using the second line pattern uses 300 x 30 = 9,000 requests per month, which is 9,000 x $0.00055 = $4.95.
Hidden cost source: resent chat history
The chat API has no memory. On each turn, your app sends the entire conversation history as input tokens. Therefore, the cost of one session does not increase linearly, but accelerates as the conversation lengthens.
Example of a 20-turn session
Suppose the system prompt is 500 tokens. Each turn adds 150 tokens from the user and 350 from the model, so the history grows by 500 tokens per turn.
- Tokens entering on turn k are 500 + 500 x (k - 1). The first turn has 500 tokens, the 20th turn has 10,000 tokens.
- Total input over 20 turns: 20 x 500 + 500 x (0 + 1 + ... + 19) = 10,000 + 500 x 190 = 105,000 tokens.
- Total output: 20 x 350 = 7,000 tokens.
- Cost: 105,000 x 0.15 / 1,000,000 = $0.01575, plus 7,000 x 0.50 / 1,000,000 = $0.0035. Total $0.01925.
One session costs about two cents. But note that input (105,000 tokens) is much larger than output (7,000 tokens). This is where savings are most impactful.
Building a monthly budget from your own data
Rough estimates should be replaced with figures from actual usage. The process is straightforward and can be done in three steps.
- Run your feature for a few days with a small credit and record
prompt_tokensandcompletion_tokensfor each request. - Calculate the average input and output per feature. Do not mix features with significantly different token patterns, such as chat and document summarization.
- Multiply by the estimated number of requests per month.
Example: an app has two features. The chat feature uses an average of 2,000 input tokens and 500 output, with 6,000 requests per month: 6,000 x $0.00055 = $3.30. The summary feature uses 20,000 input and 800 output, with 400 requests per month: 400 x $0.0034 = $1.36. Total $4.66 per month.
Add a buffer of about 30% for spikes and experiments, so a safe budget is around $6.06. Since credit never expires, the difference is not lost but becomes next month's balance. This is one advantage of the prepaid system over fixed-quota subscriptions.
How to reduce bills without sacrificing quality
- Limit history. Send only the most relevant last turn. In the 20-turn session above, if input is limited to 4,000 tokens per turn, total input becomes 18,000 + 12 x 4,000 = 66,000 tokens. Cost: $0.0099 + $0.0035 = $0.0134, a drop of about 30% from $0.01925.
- Summarize old history. Replace the beginning of the conversation with a short summary, then keep the latest turns as is.
- Trim the system prompt. A 3,000-token prompt sent with every request adds $0.00045 per request, or $0.45 per 1,000 requests. A small number, but it multiplies at high volume.
- Set
max_tokensif you need short answers. This parameter is optional. Without it, the answer may use the remaining context window. - Monitor balance from responses. The
X-Balance-USDheader shows the balance after each request.
The following code calculates the cost of one request from usage and reads the remaining balance:
from openai import OpenAI
client = OpenAI(
base_url="https://api.apitanpasensor.com/v1",
api_key="KEY_ANDA",
)
raw = client.chat.completions.with_raw_response.create(
model="uncensored",
messages=[{"role": "user", "content": "Jelaskan token dalam dua kalimat."}],
)
resp = raw.parse()
u = resp.usage
biaya = u.prompt_tokens * 0.15 / 1_000_000 + u.completion_tokens * 0.50 / 1_000_000
print(f"Biaya permintaan: ${biaya:.6f}")
print("Saldo tersisa:", raw.headers.get("X-Balance-USD"))
print(resp.choices[0].message.content)
Save these numbers to your logs. Within a week you will know the average cost per feature, which is more useful than an estimate.
Top-up, bonuses, and non-expiring credit
You top up your balance with any round amount from $20 to $500. There is a bonus for larger top-ups:
| Top-up | Bonus | Credit you receive |
|---|---|---|
| $20 | none | $20 |
| $50 | +5% | $52.50 |
| $100 | +10% | $110 |
| $200 | +15% | $230 |
Payment is made with crypto: USDT on the TRC20 network or USDC on the Base network. Credit never expires, so you are not forced to spend your balance in a specific month.
For reference, $20 on a chat pattern with context ($0.00055 per request) is enough for about 36,000 requests (20 / 0.00055 = 36,363). To compare other trade-offs beyond price, read uncensored AI cost and trade-off analysis.
When cheap isn't necessarily suitable
Low price does not mean this service is suitable for all tasks. Consider the following:
- This service is text-only. There is no image, audio, or video generation, no embedding, and no fine-tuning.
- There is only one model, with ID
uncensored. If you need multiple different models under one key, this is not a router. - Full keys are limited to 8 parallel requests and 300 requests per minute. Traffic significantly above that requires queuing on your side.
- To compare with other providers, check their current rates. Prices change, so do not rely on figures from old articles.
The safest way to decide is to try it with $0.50 in free trial credit and measure costs on your own workload. Installation guides are in documentation, and the API key page explains how to claim free trial credit.
Comparing offers fairly
Many offers look cheap only because you are comparing different numbers. Before choosing any provider, check the following and note the answers:
- Are input and output prices separated, or combined into one figure? Without separation, you cannot calculate the cost of long answers.
- Is there a monthly fee, minimum usage, or a package that must be purchased first?
- Does credit expire? Expired balance is equivalent to a higher price.
- Are failed or rejected requests still charged?
- What are the limits for concurrent requests and per minute, and what happens when limits are exceeded?
- What is the context window size, and are output tokens counted within it?
For this service, the answer is: prices are separated ($0.15 input, $0.50 output), no subscription, credit never expires, failed requests are not charged, and the context window is 100,000 tokens covering both prompt and output. For other providers, check their current prices and calculate using the same formula.
One important note about limits: if you exceed the limit, the API returns HTTP 429, not an extra charge. Retry with a delay, and if the response includes the Retry-After header, respect its value.
Other guides
Frequently asked questions
How much does a regular chat request cost?
With 2,000 input tokens and 500 output tokens, the cost is $0.00055. The actual amount depends on the length of the prompt and answer, which you can read from the usage column.
Is there a monthly fee or minimum usage?
No. The system is prepaid and you only pay for tokens used. Credit never expires.
Are failed requests still charged?
No. Failed or rejected requests are not charged.
How to check the remaining balance?
Read the X-Balance-USD header on each response, or call GET /v1/balance. The OpenAI-compatible endpoint at /v1/dashboard/billing/credit_grants is also available.
What is the minimum top-up?
$20, in round amounts up to $500. Payment via USDT (TRC20) or USDC (Base).
Your key requires only one step
Create an account, copy your key, change the base URL. That's it for the setup process.