Get request usage

Endpoint
GET/v1/billing/requests/{request_id}

Look up the token usage and final cost of a single model call by its request ID.

Request

Authenticate with Authorization: Bearer sk-moyiapi-xxxxxx.

Parameters

Parameter In Type Required Notes
request_id path UUID Yes The value of the x-request-id response header from the model call

Every model call returns an x-request-id response header (there is also x-trace-id for troubleshooting; it cannot be used for billing lookups).

Response

json
{
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "created_at": 1784081234,
  "model": "gpt-5.4",
  "usage": {
    "input_tokens": 1000,
    "output_tokens": 500,
    "cached_write_tokens": 800,
    "cached_read_tokens": 200,
    "total_tokens": 2500
  },
  "amount": {"value": "0.012680", "currency": "USD"}
}
Field Notes
request_id Request ID
created_at Request time (Unix seconds)
model The model that was called
usage.input_tokens Input tokens that missed the cache
usage.output_tokens Output tokens generated
usage.cached_write_tokens Tokens written to the prompt cache
usage.cached_read_tokens Tokens read from the prompt cache
usage.total_tokens Sum of the above
amount Final cost of the request; value is a string amount, currency the currency

Token types that do not apply or are not reported upstream are 0.

Examples

bash
curl "https://moyiapi.com/v1/billing/requests/550e8400-e29b-41d4-a716-446655440000" \
  -H "Authorization: Bearer sk-moyiapi-xxxxxx"

Errors

Billing endpoints return error.code + error.message:

HTTP status error.code When it happens
400 invalid_request request_id is not a valid UUID
404 not_found The request does not exist, or the current API key cannot access it
Ready? Three steps to startLog in to the console · top up · create an API key
DiscordGet community help instantly
Get request usage · Docs