OpenAI-Compatible API Cost Calculator
An OpenAI-compatible API cost calculator estimates a request by pairing the model with the route available to the account, then pricing input and output tokens separately. Start with the model-and-route pair, capture measured token counts, and apply the route-specific rate; do not apply one model price to every account. For Frugal Relay, send a representative request to https://frugalrelay.me/v1, record its usage, and check the current live rate before using an estimate in a production decision.
That order matters because the same model can have different eligible routes and rates. A calculator that stores only a model name cannot tell a finance review which price it used, and it cannot be reliably updated when route availability changes. The practical unit is a model, a named route, and the billed quantity: input tokens, output tokens, or requests.
OpenAI-compatible API cost calculator: start with the route
Section titled “OpenAI-compatible API cost calculator: start with the route”The live catalog identifies whether a model uses the OpenAI endpoint type and lists the routes enabled for that model. It also provides a human-readable route name and a route ratio. Calculate a public rate only when the route occurs in both places: the model’s enabled routes and the catalog’s route-ratio map. This prevents a calculator from inventing a price for an unavailable pairing.
For a token-priced model, the catalog inputs produce these rates:
input USD per 1M tokens = model_ratio x 2 x group_ratio[route]output USD per 1M tokens = input price x completion_ratioFor a request-priced model, use a different unit:
USD per request = model_price x group_ratio[route]The formulas are facts about the pricing inputs in this run. Choosing a model, setting a budget, or deciding that a lower token rate is worth a quality tradeoff is a recommendation that needs evidence from your own workload. Route eligibility can also differ by account, so confirm the route you can use rather than treating a catalog entry as a guarantee.
The pricing guide explains the input/output distinction and the supported models guide is the place to check model and endpoint compatibility. If either static guide differs from the live catalog, use the live catalog for a current rate or omit the disputed value.
Use live model and route inputs
Section titled “Use live model and route inputs”The following examples are calculated from the current catalog. The token rows show USD per 1M input / output tokens; the image row is USD per request. Each rate is attached to the route that produced it.
| Model | Named route | Billing unit and rate |
|---|---|---|
gpt-5.5 | Plus Account Route | $0.225 input / $1.35 output per 1M tokens |
gpt-5.5 | Pro Account Route | $0.45 input / $2.70 output per 1M tokens |
claude-sonnet-5 | Claude Sale Channel | $0.11 input / $0.55 output per 1M tokens |
claude-sonnet-5 | Claude Route | $0.22 input / $1.10 output per 1M tokens |
gpt-image-2 | Image Route | $0.05 per request |
These rows illustrate two calculator shapes. gpt-5.5 and claude-sonnet-5 are token-priced models, so a request needs separate input and output measurements. gpt-image-2 is request-priced, so a token formula would be the wrong unit. The live catalog marks all three as OpenAI-endpoint models; it also marks claude-sonnet-5 as usable through the Anthropic endpoint type. That does not make their prices interchangeable across routes.
Avoid labels such as “the GPT-5.5 price” in a dashboard or spreadsheet. Store gpt-5.5 plus Plus Account Route, or gpt-5.5 plus Pro Account Route, as separate price records. Apply the same rule to Claude Sale Channel and Claude Route. It makes an estimate auditable and avoids accidentally carrying a rate into a route for which it was never calculated.
Calculate a request from measured usage
Section titled “Calculate a request from measured usage”For token-priced calls, use the observed token counts rather than estimating from characters or prompt length. The request formula is:
request cost = (input tokens / 1,000,000 x input rate) + (output tokens / 1,000,000 x output rate)Assume a measured gpt-5.5 request has 80,000 input tokens and 20,000 output tokens. On the Plus Account Route, the route-specific calculation is:
input: 80,000 / 1,000,000 x $0.225 = $0.018output: 20,000 / 1,000,000 x $1.35 = $0.027total: $0.045 per requestAt 10,000 calls with that exact token profile and no extra calls, the estimate is $450. That is arithmetic, not a forecast: production traffic will vary in context length and completion size. If the flow retries 2% of calls, evaluates a second candidate, or runs background work, account for those additional calls explicitly instead of hiding them in a generic overhead percentage.
For comparison, the same 80,000-input and 20,000-output token profile calculates to $0.0198 for claude-sonnet-5 on the Claude Sale Channel: $0.0088 for input plus $0.011 for output. This is a route-specific price example, not a recommendation to substitute models. Test output quality, latency, errors, and the number of attempts needed for a successful task before changing a production workflow.
For request-priced work, multiply the measured request count by the matching named-route rate. For example, 500 gpt-image-2 requests on the Image Route calculate to 500 x $0.05 = $25. Keep that subtotal separate from chat token costs until the final addition.
Capture usage through the OpenAI-compatible API
Section titled “Capture usage through the OpenAI-compatible API”The documented OpenAI-compatible chat endpoint is POST /v1/chat/completions through the base URL https://frugalrelay.me/v1. This Python example sends one representative chat request with a current model slug. The two rate constants are valid only for gpt-5.5 on the Plus Account Route; replace them only after checking the selected model and route in the live catalog.
import osfrom openai import OpenAI
PLUS_GPT_5_5_INPUT_PER_MILLION = 0.225PLUS_GPT_5_5_OUTPUT_PER_MILLION = 1.35
client = OpenAI( api_key=os.environ["FRUGAL_RELAY_API_KEY"], base_url="https://frugalrelay.me/v1",)
response = client.chat.completions.create( model="gpt-5.5", messages=[ {"role": "user", "content": "Extract the order number and status."} ],)
usage = response.usageestimated_usd = ( usage.prompt_tokens / 1_000_000 * PLUS_GPT_5_5_INPUT_PER_MILLION + usage.completion_tokens / 1_000_000 * PLUS_GPT_5_5_OUTPUT_PER_MILLION)
print({ "input_tokens": usage.prompt_tokens, "output_tokens": usage.completion_tokens, "estimated_usd": round(estimated_usd, 8),})Run the example against inputs that resemble the traffic you plan to serve. Save the model slug, route name, input tokens, output tokens, response outcome, and retry count with each sample. That record is more useful than a single average because it lets you calculate a typical request and a high-usage request independently.
For a first connection, follow Getting Started before adding the call to an application. Then verify the model is listed for the intended endpoint in Supported Models and update the rate constants from the live pricing page when the catalog changes.
Turn the estimate into a production control
Section titled “Turn the estimate into a production control”The calculation is small; keeping its inputs honest is the production work. Start by grouping traffic by task rather than using one application-wide average. A short extraction, a long document review, and a retry after a validation failure can have very different input/output mixes. Calculate each group separately, then multiply by its observed volume.
Measure cost per successful task as well as cost per call. A lower nominal token rate can be a poor operational choice when a model causes additional retries, longer corrective prompts, or downstream review. Conversely, a model with a higher route-specific rate may reduce the total number of calls for a task. Those are hypotheses to evaluate with a representative test set, not properties implied by the price table.
Put a ceiling around the variables you control. Keep outputs bounded to what the product needs, make retries finite and selective, and run a small canary before expanding traffic. The pricing guide documents per-key daily or monthly limits; use those limits alongside application-level timeouts and error handling. A limit is a guardrail, while the calculator remains a planning estimate.
Production checklist for route-aware estimates
Section titled “Production checklist for route-aware estimates”- Confirm the model appears in the current catalog and supports the endpoint your client uses.
- Confirm the named route is both enabled for that model and present in the route-ratio map.
- Store model, route, billing unit, and rate together; never store an unlabeled price.
- Record input and output tokens separately for token-priced calls.
- Track request counts separately for request-priced calls such as image generation.
- Include retries, evaluation calls, scheduled jobs, and fallback calls in the projected volume.
- Compare a typical token profile with a high-usage profile before approving a monthly budget.
- Recheck the live pricing catalog before changing a model, route, or production budget.
FAQ: can one calculator cover chat and image calls?
Section titled “FAQ: can one calculator cover chat and image calls?”Yes, as long as it maintains separate subtotals. Add token-priced chat cost from input and output rates, then add request-priced image cost from the named route’s per-request rate. Do not turn an image request into a token estimate or reuse a chat rate for an image model.
FAQ: does an OpenAI-compatible endpoint select the cheapest route?
Section titled “FAQ: does an OpenAI-compatible endpoint select the cheapest route?”No route-selection rule is implied by endpoint compatibility. The endpoint tells the client which request shape to use; account configuration and model route eligibility determine the route you must verify. Keep the route named in the calculator and use the live rate as the final check.
An OpenAI-compatible API cost calculator becomes dependable when every number can be traced to a model, named route, and measured unit. Begin with a small sample, retain the evidence, and refresh the rate before a material production decision.