Skip to main content
Estimate cost before a model call by combining the model directory price with the units that the endpoint bills: tokens or generated images. 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

For an image model priced per task, the following JavaScript example estimates the cost from the task count:
The result is the task budget:

Common errors

Last modified on October 9, 2026