Report token counts to the metering beacon
POST /api/v1/meter
Accepts token counts and model metadata from a client. The beacon does not receive a receipt signature. A receipt hash supplied without signature proof is stored as unverified and is not counted in public transparency totals. The public receipt-inclusion endpoint reports pending unless a verified record exists for that hash.
Authenticate with an API key.
Request body
application/json object
beacon_noncestring or nullLength: at most 128 characters. Pattern:^[A-Za-z0-9_.:-]+$input_tokensinteger requiredRange: 0 to 20000000modelstring requiredLength: at most 80 characters. Pattern:^[A-Za-z0-9][A-Za-z0-9._:/+\-]{0,79}$noncestring requiredLength: 8 to 128 characters. Pattern:^[A-Za-z0-9_.:-]+$output_tokensinteger requiredRange: 0 to 20000000providerstring or nullLength: at most 40 charactersreceipt_hashstring or nullPattern:^[A-Fa-f0-9]{64}$surfacestring or nullOne of:"extension","desktop","proxy","proxy-direct",nulltsinteger requiredRange: at least 0
Generated sample
{
"beacon_nonce": "string",
"input_tokens": 0,
"model": "string",
"nonce": "string",
"output_tokens": 0,
"provider": "string",
"receipt_hash": "string",
"surface": "extension",
"ts": 0
}Responses
200 Meter result. If anchoring is present, verified is false because this beacon request carries no signature proof.
application/json object
anchoringobjectanchoredbooleanbeacon_noncestringinclusion_statestringOne of:"pending","anchored"receipt_hashstringPattern:^[a-f0-9]{64}$seed_hashstringPattern:^[a-f0-9]{64}$verifiedbooleanValue:false
balance_centsintegerbilledbooleanfee_centsintegermeteredbooleanbalance_microsintegerExact wallet balance in USD micro-dollars after the metered call.
Generated sample
{
"anchoring": {
"anchored": true,
"beacon_nonce": "string",
"inclusion_state": "pending",
"receipt_hash": "string",
"seed_hash": "string",
"verified": false
},
"balance_cents": 0,
"billed": true,
"fee_cents": 0,
"metered": true,
"balance_micros": 0
}401 The API key is missing or invalid.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
402 The prepaid balance does not cover the metering fee.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
403 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
413 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
415 The beacon body must use application/json.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
422 The counts-only beacon fields are invalid or the model has no price reference.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
429 Error response.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
text/html string
503 The metering beacon could not be recorded; retry with the same nonce.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.