Pricing & Cost Calculation — ML Junction docs
Route prices are returned in USD per one million tokens. pricing=null means no verified active price is available; it does not mean the route is free.
Field · Unit · Meaning input_per_mtok · USD / 1,000,000 tokens · Uncached input tokens cached_input_per_mtok · USD / 1,000,000 tokens · Input tokens served from provider cache output_per_mtok · USD / 1,000,000 tokens · Generated output tokens effective_from · UTC timestamp · Beginning of the active price period effective_to · UTC timestamp or null · End of the price period source · URL · Pricing evidence/source
uncached_input_tokens = input_tokens - cached_input_tokens
input_cost = uncached_input_tokens / 1,000,000 * input_per_mtok
cached_input_cost = cached_input_tokens / 1,000,000 * cached_input_per_mtok
output_cost = output_tokens / 1,000,000 * output_per_mtok
estimated_total = input_cost + cached_input_cost + output_cost
function estimateCost({ inputTokens, cachedInputTokens, outputTokens, pricing }) {
if (!pricing) return null;
const million = 1_000_000; const cached = Math.min(cachedInputTokens ?? 0, inputTokens); const uncached = Math.max(0, inputTokens - cached);
return (
(uncached / million) * Number(pricing.input_per_mtok ?? 0) +
(cached / million) * Number(pricing.cached_input_per_mtok ?? pricing.input_per_mtok ?? 0) +
(outputTokens / million) * Number(pricing.output_per_mtok ?? 0)
);
}
The receipt actual_charge_usd is authoritative for the completed request. Client-side estimates cannot predict provider-specific reasoning, cache, retry, or fallback usage exactly.
Canonical URL: https://mljunction.com/docs/pricing-costs