estimateCost
estimateCost(
inputTokens,outputTokens,rates):number
Defined in: backend/src/shared.ts:212
Estimate request cost based on token counts and provider rates.
Parameters
Section titled “Parameters”inputTokens
Section titled “inputTokens”number
Estimated input token count
outputTokens
Section titled “outputTokens”number
Estimated output token count (defaults to maxTokens or 1000)
Cost rates per million tokens
Returns
Section titled “Returns”number
Estimated cost in USD
Example
Section titled “Example”const cost = estimateCost(1000, 500, { inputPer1M: 3.00, // $3 per 1M input tokens outputPer1M: 15.00, // $15 per 1M output tokens});// cost ≈ $0.0105