Overview

The Estimates API lets you preview token counts and costs before sending a request to a model. This is useful for budgeting, comparing models, and validating prompt sizes.

Base URL

For local development:

Endpoints

Authentication

All requests require a virtual key in the Authorization header. See Authentication.

Estimate tokens

Request body

Example request

Example response

Estimate cost

Request body

Example request

Example response

Estimation methodology

  • Token counts use a heuristic of approximately 4 characters per token plus a per-message overhead.
  • Cost is computed from the gateway pricing cache. If a model is not in the cache, the gateway falls back to conservative default rates.
  • Pricing is expressed in cents and is normalized per 1 million tokens.

Error codes