AI API Cost Calculator for Image Workloads
An AI API cost calculator for image workloads should separate request-priced image calls from token-priced text calls, label every rate with its route, and multiply each unit by measured volume. In the current Frugal Relay catalog, for example, gpt-image-2 calculates to $0.00225 per request on the Plus Account Route, while gpt-5.4 on that same route calculates at $0.1125 input and $0.675 output per 1M tokens. Those are different billing units, so putting both under a single “cost per call” field produces a weak estimate.
This guide shows how to construct a production estimate for a workflow that generates images and uses a chat model to prepare, classify, or review text. The prices below are calculations from the live catalog for this run, dated October 6, 2026. They are examples of named routes, not a promise that every account can use every route. Before deploying, verify the model and route available to your account on the live pricing page.
Build an AI API cost calculator from live routes
Section titled “Build an AI API cost calculator from live routes”Start by storing four fields with every rate: model name, route name, billing unit, and price. The distinction matters because a token-priced model has separate input and output rates, while a request-priced model has one rate per request. The public catalog also lists which routes each model enables. A calculator should show a price only when the model and route both appear in that catalog.
Here are useful current inputs for a mixed workload. Token prices are per 1M tokens; image prices are per request.
| Workload component | Model | Route | Calculated public price |
|---|---|---|---|
| Text prompt and response | gpt-5.4 | Plus Account Route | $0.1125 input / $0.675 output |
| Text prompt and response | gpt-5.4 | Pro Account Route | $0.225 input / $1.35 output |
| Image generation | gpt-image-2 | Plus Account Route | $0.00225 per request |
| Image generation | gpt-image-2 | Pro Account Route | $0.0045 per request |
| Image generation | gpt-image-2 | Image Route | $0.05 per request |
For the text rows, the live model data lists a model_ratio of 1.25 and a completion_ratio of 6. The catalog’s Plus Account Route ratio is 0.045, so the input calculation is 1.25 x 2 x 0.045 = 0.1125; the output price is 0.1125 x 6 = 0.675. The Pro Account Route ratio is 0.09, yielding $0.225 input and $1.35 output per 1M tokens.
For the image rows, gpt-image-2 is request-priced with a model_price field of $0.05, which yields the Image Route’s $0.05-per-request calculation. Its Plus Account Route calculation is $0.05 x 0.045 = $0.00225 per request; the Pro Account Route calculation is $0.05 x 0.09 = $0.0045 per request. The Image Route ratio is 1, so its calculation remains $0.05 per request. These values are route-specific facts from the catalog, not a comparison with another provider.
The pricing guide explains the catalog’s pricing types and route-specific presentation. Use the supported models guide to confirm endpoint compatibility before selecting a model. The live catalog takes precedence if either guide has not yet caught up with a model or route change.
Price image requests and text tokens separately
Section titled “Price image requests and text tokens separately”Use two formulas in the same calculator rather than forcing everything into a token formula.
For a token-priced model:
text cost = (input tokens / 1,000,000 x input rate) + (output tokens / 1,000,000 x output rate)For a request-priced model:
image cost = image requests x route-specific price per requestThe first formula handles the chat model’s usage. The second handles image requests. Do not multiply image requests by token rates, and do not apply a route price from one model to another. The rate is a property of the model-and-route pair.
It is also worth distinguishing an estimate from a billing record. An estimate starts with token counts and request counts you measured in staging, production logs, or a controlled sample. It becomes more reliable when it includes failed attempts, user retries, and internal jobs. The actual dashboard and usage records remain the source for billed usage.
Work through a mixed-workload estimate
Section titled “Work through a mixed-workload estimate”Assume an illustration feature makes 2,000 gpt-image-2 requests per month. It also runs gpt-5.4 once for each item to prepare a caption or structured instruction. A measured average chat call contains 2,500 input tokens and 300 output tokens. This is an example workload, not an expected usage profile.
At 10,000 chat calls, the text portion uses 25M input tokens and 3M output tokens. On the Plus Account Route, the calculation is:
text = (25 x $0.1125) + (3 x $0.675) = $2.8125 + $2.025 = $4.8375
images = 2,000 x $0.00225 = $4.50
Plus Account Route estimated monthly total = $9.3375The same request and token counts on the Pro Account Route calculate differently: text is (25 x $0.225) + (3 x $1.35) = $9.675, and images are 2,000 x $0.0045 = $9.00. The example total is therefore $18.675. On the Image Route, the image portion alone would calculate to $100 at $0.05 per request. That contrast is why a useful calculator must name the route beside every displayed rate instead of presenting a single image-generation price.
These arithmetic examples do not determine which model or route is right for a product. Choose based on the routes genuinely available to the account, then evaluate output quality, latency, error rate, and total cost per completed task. For a ready-made starting point, see Getting Started and run a small sample before projecting a full month.
Capture token usage with an OpenAI-compatible call
Section titled “Capture token usage with an OpenAI-compatible call”The live catalog marks gpt-5.4 as an OpenAI endpoint model. The documented OpenAI-compatible chat endpoint is POST /v1/chat/completions, available through https://frugalrelay.me/v1. This Python example makes one chat call and converts the returned usage into a Plus Account Route estimate. The constants are specific to gpt-5.4 on that named route; change them only after checking the current model and route price.
import osfrom openai import OpenAI
PLUS_GPT_5_4_INPUT_PER_MILLION = 0.1125PLUS_GPT_5_4_OUTPUT_PER_MILLION = 0.675
client = OpenAI( api_key=os.environ["FRUGAL_RELAY_API_KEY"], base_url="https://frugalrelay.me/v1",)
response = client.chat.completions.create( model="gpt-5.4", messages=[ {"role": "user", "content": "Create a short caption for a product image."} ],)
usage = response.usageestimated_usd = ( usage.prompt_tokens / 1_000_000 * PLUS_GPT_5_4_INPUT_PER_MILLION + usage.completion_tokens / 1_000_000 * PLUS_GPT_5_4_OUTPUT_PER_MILLION)
print({ "prompt_tokens": usage.prompt_tokens, "completion_tokens": usage.completion_tokens, "estimated_usd": round(estimated_usd, 8),})Keep the output from a small representative sample instead of guessing token counts from character length. Then record the number of image-generation requests separately. A spreadsheet, database table, or metrics event with model, route, input_tokens, output_tokens, and image_requests is enough to support a first forecast.
Make the calculator production-ready
Section titled “Make the calculator production-ready”The arithmetic is simple; keeping its inputs current is the engineering work. Apply these checks before relying on a forecast:
- Confirm the model appears in the live catalog and that the intended route is both enabled for that model and available to the account.
- Store the human-readable route name with each rate, such as Plus Account Route or Image Route.
- Track image request count independently from chat input and output tokens.
- Include failed requests, retries, background jobs, and non-user traffic in the expected volume.
- Calculate a typical case and a high-usage case rather than a single average only.
- Recheck the live rate whenever the route, model, or catalog changes.
FAQ: can one calculator cover image and chat APIs?
Section titled “FAQ: can one calculator cover image and chat APIs?”Yes, provided it keeps the units separate. A single application-level calculator can add a request-priced image subtotal to a token-priced chat subtotal. It should not convert one to the other or hide the route. That structure also makes it easy to test a change: update one model-and-route row, retain the observed usage counts, and compare the new total.
FAQ: should a low per-request price decide the route?
Section titled “FAQ: should a low per-request price decide the route?”No. A lower calculated price is only one input. Route availability can differ by account and change over time, while quality and successful-task rate determine whether a workflow actually delivers value. Verify the current rate, test the exact model on representative inputs, and keep the measurement data with the decision.
An AI API cost calculator earns its place in production when it reflects the units the catalog actually bills: requests for image generation and input/output tokens for chat. Start with one named route, collect real usage, and update the rates from the live catalog before making a spending decision.