Skip to main content
Estimate cost before a model call by combining the model directory price with the units that the endpoint bills: tokens, images, audio length, or video tasks. Treat the estimate as a budget guard, then use actual usage and billing records after the request completes.

Estimate token-based calls

The following Python example estimates token-based request cost from configured pricing values:
The result is a pre-call estimate:

Set a maximum output budget

The following request caps generated output so the estimate has an upper bound:
The response includes actual usage after the model call:

Estimate task-based calls

The following JavaScript example estimates a task-based workflow such as image or video generation:
The result is the task budget:

Common errors

Last modified on June 23, 2026