Skip to content
Sign in Create account

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_nonce string or null
    Length: at most 128 characters. Pattern: ^[A-Za-z0-9_.:-]+$
  • input_tokens integer required
    Range: 0 to 20000000
  • model string required
    Length: at most 80 characters. Pattern: ^[A-Za-z0-9][A-Za-z0-9._:/+\-]{0,79}$
  • nonce string required
    Length: 8 to 128 characters. Pattern: ^[A-Za-z0-9_.:-]+$
  • output_tokens integer required
    Range: 0 to 20000000
  • provider string or null
    Length: at most 40 characters
  • receipt_hash string or null
    Pattern: ^[A-Fa-f0-9]{64}$
  • surface string or null
    One of: "extension", "desktop", "proxy", "proxy-direct", null
  • ts integer required
    Range: 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

  • anchoring object
    • anchored boolean
    • beacon_nonce string
    • inclusion_state string
      One of: "pending", "anchored"
    • receipt_hash string
      Pattern: ^[a-f0-9]{64}$
    • seed_hash string
      Pattern: ^[a-f0-9]{64}$
    • verified boolean
      Value: false
  • balance_cents integer
  • billed boolean
  • fee_cents integer
  • metered boolean
  • balance_micros integer

    Exact 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

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

402 The prepaid balance does not cover the metering fee.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

403 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

413 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

415 The beacon body must use application/json.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

422 The counts-only beacon fields are invalid or the model has no price reference.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

429 Error response.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.

text/html string

503 The metering beacon could not be recorded; retry with the same nonce.

application/json GenericError

  • error any

    One of

    • string
    • object

      Any keys are accepted.

  • error_code string
  • code string
  • message string
  • detail string
  • status any

    One of

    • string
    • integer
  • errors object

    Any keys are accepted.