Commet
  • Pricing
Log InTry out
Check usage availability POSTTrack usage event POST
DocumentationKnowledge BaseBuild with AIAPI ReferenceWebhooks

Track usage event

Track a usage event for a metered feature. Deducts from balance/credits if applicable.

Check usage availability POST

Check if a customer can consume a feature before actual consumption. Returns availability and cost estimates based on the plan's consumption model.

Authorization

ApiKeyAuth
x-api-key<token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

POST
/usage/events

application/json

feature*string
Match^[a-z0-9_]+$
Length1 <= length <= 100
customerId*string
Length1 <= length <= 200
idempotencyKey?string
timestamp?string
Formatdate-time
properties?array<>
Default[]
model*string
Length1 <= length <= 200
inputTokens*integer
Range0 <= value
outputTokens*integer
Range0 <= value
cacheReadTokens?integer
Range0 <= value
cacheWriteTokens?integer
Range0 <= value
curl -X POST "https://commet.co/api/usage/events" \  -H "Content-Type: application/json" \  -d '{    "feature": "api_calls",    "externalId": "user_123",    "value": 1  }'

application/json

application/json

application/json

Track a usage event for a metered feature. Deducts from balance/credits if applicable.

{
  "success": true,
  "data": {
    "id": "string",
    "feature": "string",
    "value": 0,
    "customerId": "string",
    "idempotencyKey": "string",
    "ts": "2019-08-24T14:15:22Z",
    "createdAt": "2019-08-24T14:15:22Z",













{
  "success": false,
  "code": "string",
  "message": "string",
  "details": null
}
{
  "success": false,
  "code": "string",
  "message": "string",
  "details": null
}
{
  "success": false,
  "code": "string",
  "message": "string",
  "details": null
}
{
  "success": false,
  "code": "string",
  "message": "string",
  "details": null
}
"properties"
: [
{
"property": "string",
"value": "string"
}
],
"consumption": {
"model": "string",
"deducted": 0,
"remaining": 0,
"blocked": true
}
}
}