WiozenAPI

How do you calculate the cost of an AI API?

In short: API cost is token count times token price: input tokens are multiplied by the input price, output tokens by the output price, cached input by its own price, and the results are added up. Prices are quoted per 1 million tokens. For example, on the Wiozen API a request to wiozen-anthropic with 2,000 input tokens and 1,000 output tokens costs 2,000 × $0.05 / 1,000,000 + 1,000 × $0.20 / 1,000,000 = $0.0003.

What is a token, and why are input and output priced separately?

A model reads and writes text in small pieces called tokens. As a rough guide, 1 million tokens of English text is about 750,000 words. Other languages often take more tokens for the same length; Turkish, with its long suffixed words, is one of them. Rather than guessing, look at the token counts the API returns with every response.

Input is everything you send: the system message, earlier messages in the conversation, any file or code you attach. Output is what the model writes back. Providers charge more for output. For the chat models on the Wiozen API's Models page, output costs 4 to 5 times the input price: wiozen-anthropic is $0.05 in and $0.20 out, claude-sonnet-5-5 is $1.40 in and $7.00 out.

In a chat, every new message is sent together with the messages before it. That's why the later messages in a long conversation cost more than the first ones: the part that grows is the input.

The formula

formula
cost = ( input tokens × input price
       + cached tokens × cache read price
       + output tokens × output price ) / 1,000,000

The Wiozen API has four separate prices: input, cached input read, cache write and output. A short chat question doesn't touch the cache, so the cost is just input plus output. You can see the cache prices on the Models page by hovering over the input price.

An example with real prices

The table below uses the prices listed on the Models page on October 27, 2026. The sample message is 2,000 input tokens and 1,000 output tokens: a short question and answer with no cache.

ModelInput / 1MOutput / 1MSample messageAbout this many with $5
wiozen-anthropic$0.05$0.20$0.000316,666 messages
claude-haiku-5-5$0.07$0.35$0.0004910,204 messages
deepseek-v4.1-flash (peak hours)$0.15$0.60$0.00095,555 messages
gemini-3.8-flash-high$0.30$1.50$0.00212,380 messages
claude-sonnet-5-5$1.40$7.00$0.0098510 messages
claude-opus-5-5$2.80$14.00$0.0196255 messages

For the claude-sonnet-5-5 row the arithmetic is: 2,000 × 1.40 / 1,000,000 = $0.0028 for input, 1,000 × 7.00 / 1,000,000 = $0.007 for output, $0.0098 in total. $5 / $0.0098 ≈ 510.

For deepseek-v4.1-flash the table shows the peak-hours price, which applies on weekdays from 04:00 to 07:00 and from 09:00 to 13:00 Turkey time. At all other hours and on weekends half of that price applies, so the same message costs $0.00045.

How does caching lower the cost of long contexts?

Coding agents send the same files, the same instructions and the conversation history again at every step. When that repeated part is read from the cache, it is charged at a much lower rate. Going by the prices on the Models page, cached input costs a tenth of normal input or less.

Take a typical agent step: 15,000 new input tokens, 83,000 tokens read from the cache and 2,000 output tokens.

Caching is used by the tool that sends the request; agents like Claude Code do it on their own. How many tokens came from the cache is shown for each request on the Usage page of the dashboard.

How does the balance go down per request?

Measuring your own cost in code

Every response reports the tokens it used in the usage field. In the OpenAI format the fields are prompt_tokens and completion_tokens; in the Anthropic format they are input_tokens and output_tokens. Multiply them by the prices and you can log the cost of each request yourself:

Python
from openai import OpenAI

client = OpenAI(base_url="https://api.wiozen.com/v1", api_key="sk-gw-...")
# dollars per 1M tokens: (input, output)
PRICES = {"wiozen-anthropic": (0.05, 0.20), "claude-sonnet-5-5": (1.40, 7.00)}

model = "wiozen-anthropic"
r = client.chat.completions.create(
    model=model,
    messages=[{"role": "user", "content": "Hello"}],
    max_tokens=16000,
)
p_in, p_out = PRICES[model]
cost = (r.usage.prompt_tokens * p_in + r.usage.completion_tokens * p_out) / 1_000_000
print(f"{r.usage.prompt_tokens} in, {r.usage.completion_tokens} out: ${cost:.6f}")

This example doesn't count cached tokens separately, so treat it as an estimate that works well for short requests. The exact figure is the breakdown on the Usage page of your dashboard.

Frequently asked questions

Why do output tokens cost more than input tokens?

Providers price output higher. On the Wiozen API's chat models output costs 4 to 5 times the input price, so for tasks with long answers most of the cost comes from output.

How much text is 1 million tokens?

Roughly 750,000 words of English. In Turkish the same number of tokens covers fewer words. For exact numbers, check the usage field in the response.

Do I pay for a failed request?

No. Requests that return an error are not charged, including 502 and 504.

What happens when my balance runs out?

New requests return 429. Once you top up and it's approved, you carry on with the same key. Topped-up balance doesn't expire.

How can I limit my spending?

Give each key a spending cap on the Keys page. When the cap is reached that key returns 429 and the others keep working.

To see the numbers with your own requests, create an account. With the $0.15 trial balance you can send a few requests and see what each one cost, line by line, on the Usage page.

Create your account

More guides: How can you use an AI API from Turkey without a credit card? · How do you connect an OpenAI-compatible API to a tool you already use? · How do you get AI to write and publish articles in WordPress automatically? · How do you find blog topics from RSS feeds and Google Trends? · Does AI-written content show up on Google and in AI answers?