Referencia de la API

Consumo

Consumo por proveedor y componente, con costos.

GET /v1/pricing

The prices behind the cost estimates

Solo para usuarios con sesión iniciada (sin API key) · Rol: viewer o superior

A signed-in member with `costs:read`. The read-only price table that usage is priced with: per provider and model, USD per million tokens (text, audio and cached parts), per minute of audio or per million characters, with the public pricing page each rate was read from. `version` is the date the prices were read; every stored usage row keeps the version it was priced with. A model that is not listed has no price and its cost is null. Estimates ignore volume discounts and taxes. 401 when the token is missing, expired or invalid.

Respuestas

  • 200 Successful Response · PricingResponse
    NombreTipoRequeridoDescripción
    currencystringsí
    pricesPriceEntryResponse[]sí
    prices[].componentstringsí
    prices[].modelstringsí
    prices[].notestringsí
    prices[].providerstringsí
    prices[].ratesPriceRatessíUSD per unit; a rate that is null does not apply to the model.
    prices[].rates.audio_input_per_mtoknumber | nullsí
    prices[].rates.audio_minutenumber | nullsí
    prices[].rates.audio_output_per_mtoknumber | nullsí
    prices[].rates.cached_audio_input_per_mtoknumber | nullsí
    prices[].rates.cached_input_per_mtoknumber | nullsí
    prices[].rates.cached_text_input_per_mtoknumber | nullsí
    prices[].rates.input_per_mtoknumber | nullsí
    prices[].rates.output_per_mtoknumber | nullsí
    prices[].rates.per_mcharsnumber | nullsí
    prices[].rates.text_input_per_mtoknumber | nullsí
    prices[].rates.text_output_per_mtoknumber | nullsí
    prices[].sourcestringsíPublic pricing page the rates were read from.
    unpricedstringsíWhat happens to a model that is not listed: its cost is null, never a guess.
    versionstringsíDate the prices were read, `YYYY-MM-DD`.
  • 401 Missing, expired or invalid token. · ErrorResponse
  • 403 Cost permission required. · ErrorResponse
  • default Default Response · ErrorResponse

GET /v1/usage

What my organization consumed, with cost estimates

API key con usage:read · Rol: viewer o superior

Any signed-in member, or an API key with the scope `usage:read`. The consumption recorded between `since` (inclusive) and `until` (exclusive), by default from the start of the current month (UTC) until now, up to 366 days. `group_by` is `component` (llm, realtime, stt, tts, embeddings, telephony), `provider`, `model`, `assistant`, `campaign`, `day` (midnight of `timezone`, an IANA name, UTC by default) or `source` (call, talk, ingest, search, builder, decider); `then_by` splits each group once more by any of them. Filters: `assistant_id`, `campaign_id`, `component`, `provider`, `model` and `source`; usage that belongs to no call (knowledge ingestion and search) has no assistant or campaign. Each group has its quantities (tokens with the cached, reasoning, audio and text parts, audio seconds, characters, requests) and `cost_usd`, an estimate at the prices of `GET /v1/pricing`: the sum of the rows that have a price, with `unpriced_rows` counting the ones that do not. At most 500 groups (`truncated`). 401 when the token is missing, expired or invalid; 422 for an empty or too long range, an unknown time zone or another invalid parameter; 503 when usage is not available.

Parámetros

NombreEnTipoRequeridoDescripción
sincequerystring (date-time) | null
untilquerystring (date-time) | null
group_byquerystring
then_byquerystring | null
timezonequerystring
assistant_idquerystring (uuid) | null
campaign_idquerystring (uuid) | null
componentquerystring | null
providerquerystring | null
modelquerystring | null
sourcequerystring | null

Respuestas

  • 200 Successful Response · UsageResponse
    NombreTipoRequeridoDescripción
    group_bystringsí
    groupsUsageGroupResponse[]sí
    groups[].keystringsíThe value of `group_by`: a component, provider, model or source name, a day (`YYYY-MM-DD`), or an assistant or campaign id (empty for usage without one).
    groups[].labelstring | nullsíAssistant or campaign name, if known.
    groups[].subkeystring | nullsíThe value of `then_by`, when it is set.
    groups[].sublabelstring | nullsí
    groups[].totalsUsageTotalsResponsesí
    groups[].totals.cost_usdnumber | nullsíSum of the rows that have a price; null when none has.
    groups[].totals.quantitiesUsageQuantitiessí
    groups[].totals.unpriced_rowsintegersíRows whose model has no price: the cost is then incomplete.
    price_versionstringsíVersion of the price table that new usage is priced with.
    sincestring (date-time)sí
    then_bystring | nullsí
    totalsUsageTotalsResponsesí
    totals.cost_usdnumber | nullsíSum of the rows that have a price; null when none has.
    totals.quantitiesUsageQuantitiessí
    totals.quantities.audio_input_tokensintegersí
    totals.quantities.audio_output_tokensintegersí
    totals.quantities.audio_secondsnumbersí
    totals.quantities.cached_input_tokensintegersíPart of `input_tokens`.
    totals.quantities.charactersintegersí
    totals.quantities.input_tokensintegersí
    totals.quantities.output_tokensintegersí
    totals.quantities.reasoning_tokensintegersíPart of `output_tokens`.
    totals.quantities.requestsintegersí
    totals.quantities.text_input_tokensintegersí
    totals.quantities.text_output_tokensintegersí
    totals.unpriced_rowsintegersíRows whose model has no price: the cost is then incomplete.
    truncatedbooleansíTrue when more than 500 groups matched.
    untilstring (date-time)sí
  • 401 Missing, expired or invalid token. · ErrorResponse
  • 403 Role below the one in `x-min-role`, a suspended organization, or an API key without the operation's `x-api-key-scope` (any key, if the operation has none). · ErrorResponse
  • 422 The range or a parameter is invalid. · ErrorResponse
  • 429 The API key went over its requests per minute. · ErrorResponse
  • 503 Usage is not available yet. · ErrorResponse
  • default Default Response · ErrorResponse