Get Request Usage

GET/v1/billing/{request_id}

Returns a billing and metering summary for one inference call, keyed by the X-Trace-ID you receive in response headers on that call. If X-Trace-ID and X-Request-ID differ, this endpoint uses X-Trace-ID.

Authentication

Authorization Bearer

Use an API key in the Authorization header (sk-…).

Path Parameters

request_idstringrequired

Billing correlation id: X-Trace-ID from the HTTP response for that inference call. If X-Trace-ID and X-Request-ID differ, use X-Trace-ID.

Query Parameters

typeenum<string>

Optional. Omit entirely to search across all modalities (same as all). Use llm | image | audio | video only when resolving by request id alone could collide and you must narrow the row.

Response

The body uses the standard R<T> envelope (code, msg, data, trace_id; service_code when present). On success, code is 200 and data is a billing reconciliation summary object (shape below). On failure, data is null.

codeinteger

Response status code.

msgstring

Response message.

dataobject | null
data.idstring

Row ID.

data.request_idstring

Billing correlation id (typically matches the path when resolved).

data.typestring

e.g. llm, image, audio, video.

data.modelstring

Display model name.

data.model_namestring | null

Model name when available.

data.statusstring

Task or request status when present.

data.create_timeinteger | string | null

Created time, epoch seconds (UTC); JSON may be string or number depending on serializer.

data.update_timeinteger | string | null

Last update, epoch seconds (UTC); JSON may be string or number.

data.billedboolean | null

Whether usage has been charged (wallet / voucher / token path).

data.total_amountnumber | null

Total charged amount when settled.

data.wallet_amountnumber | null

Wallet-funded portion when applicable.

data.voucher_amountnumber | null

Voucher-funded portion when applicable.

data.bill_record_statusstring | null

Billing status when present.

data.status_codestring | null

Recorded HTTP / status code string on usage row when present.

data.pricenumber | null

List price snapshot on the usage row when present.

data.billing_atinteger | string | null

Billing timestamp as epoch seconds when present; JSON may be string or number.

data.amount_basenumber | null

Amount before discounts (rating pipeline), when present.

data.amount_finalnumber | null

Final rated amount before wallet split, when present.

data.currencystring | null

Currency for rated amounts, when present.

data.usageobject | null

Merged metering for reconciliation: token counts, nested usage, duration tiers, etc. (no heavy explain / trace blobs).

data.durationnumber | null

Generation duration in seconds when known.

trace_idstring | null

Server trace id when available.

service_codestring | null

Stable service error code when applicable.

Error handling

  • 401 / unauthenticated: missing or invalid Authorization.
  • 404: unknown request_id, or no access. Note a short-lived 404 may mean the ledger row is not written yet because charges can land slightly after the model response.

Request ID (billing correlation)

  • Use X-Trace-ID from the inference response as request_id for this endpoint.
  • If X-Trace-ID and X-Request-ID differ, use X-Trace-ID.
  • You may send X-Request-ID or X-Trace-ID on the request to pin your own correlation id; otherwise the platform generates one.
  • Do not use the chat JSON id (chatcmpl-…) or the video resource id (video_…) as this key. For video, persist headers from POST /v1/videos — each GET poll is a new HTTP trace.
  • For video tasks, GET /v1/videos/{video_id} (or equivalent polling) may include a usage object after the task reaches a terminal status, useful for meter-only checks beside this billing endpoint.

Request

Shell
1curl -sS "https://api.token360.ai/v1/billing/550e8400-e29b-41d4-a716-446655440000" \
2  -H "Authorization: Bearer sk-your-api-key"

Response

JSON
1{
2  "code": 200,
3  "msg": "success",
4  "data": {
5    "amount_base": "0.284******",
6    "amount_final": "0.284******",
7    "bill_record_status": "1",
8    "billed": true,
9    "billing_at": "177815****",
10    "create_time": "177815****",
11    "currency": "USD",
12    "duration": 4.0,
13    "id": "550e8400-****-****-****-************",
14    "model": "seedance-2.0",
15    "model_name": "seedance-2.0",
16    "price": "0.284******",
17    "request_id": "550e8400-****-****-****-************",
18    "status": "completed",
19    "status_code": "200",
20    "total_amount": "0.284******",
21    "type": "video",
22    "update_time": "177815****",
23    "usage": {
24      "total_tokens": "40***",
25      "completion_tokens": "40***",
26      "output_tokens": "40***",
27      "seconds": 4,
28      "requested_seconds": 4,
29      "video_count": 1,
30      "sample_count": 1
31    },
32    "voucher_amount": "0.284******",
33    "wallet_amount": null
34  },
35  "service_code": null,
36  "trace_id": null
37}
Was this page helpful?