v47

latestOpenAPI 3.1.0raw.githubusercontent.com2025-11-064829.2 KB
AI Metering

Meter an LLM completion

Record the details of an LLM completion

post/v2/ai/completions

Request body

transactionIdstring required

The unique identifier of the LLM completion transaction

traceIdstring

Trace multiple LLM calls belonging to same overall request

modelstring required

The model used for generating the LLM completion

responseQualityScorenumber double

The quality score of the response

modelSourcestring

The source of the AI model used for the completion

inputTokenCountinteger required

The count of consumed input tokens

outputTokenCountinteger required

The count of consumed output tokens

reasoningTokenCountinteger

The number of reasoning tokens in the completion

cacheCreationTokenCountinteger

The number of cached creation tokens in the completion

cacheReadTokenCountinteger

The number of cached read tokens in the completion

totalTokenCountinteger required

The total number of tokens

stopReason'END' | 'END_SEQUENCE' | 'TIMEOUT' | 'TOKEN_LIMIT' | 'COST_LIMIT' | 'COMPLETION_LIMIT' | 'ERROR' required

The reason for stopping the completion

inputTokenCostnumber double

The input token cost associated with the LLM completion

outputTokenCostnumber double

The output token cost associated with the LLM completion

totalCostnumber double

The total cost associated with the LLM completion

costType'AI' required

Cost type for the completion

requestTimestring required

The timestamp when the request was made

completionStartTimestring required

Time to first token for streaming requests

timeToFirstTokeninteger

The time to first token in milliseconds

isStreamedboolean required

Indicates if the completion was streamed

responseTimestring required

The timestamp when the response was generated. If streaming, this is the time to first token

requestDurationinteger required

The duration of the request in milliseconds

mediationLatencyinteger

The latency, in milliseconds, of latency by an AI or API gateway

providerstring required

Vendor providing the LLM completion service

taskTypestring

If you wish to track the costs or performance of a specific task and compare the values over time or compare the performance across AI models or vendors, use a consistent taskType for all related tasks.

subscriberCredentialNamestring

Populate the name of the subscriber credential from your system to allow Revenium to track usage & costs for individual users.

subscriberCredentialstring

Populate the ID of the subscriber from your system to allow Revenium to track usage & costs for individual users.

subscriberEmailstring

The email address of the subscriber

subscriberIdstring

Populate the ID of the subscriber from your system to allow Revenium to track usage & costs for individual users. i.e. user-123. If several subscriberCredentials have the same subscriberId, Revenium’s reporting will show usage for the entire organization broken down by user.

organizationIdstring

Populate the ID of the subscriber’s organization from your system to allow Revenium to track usage & costs by company. i.e. AcmeCorp. If several subscriberIds have the same organizationId, Revenium’s reporting will show usage for the entire organization broken down by user.

subscriptionIdstring

Unique identifier of the subscription from your own system that you wish to use to correlate usage between Revenium & your application.

productIdstring

Identifier of the product from your own system that you wish to use to correlate usage between Revenium & your application.

agentstring

The AI agent that is making the request

operationType'CHAT' | 'GENERATE' | 'EMBED' | 'CLASSIFY' | 'SUMMARIZE' | 'TRANSLATE' | 'OTHER'

The type of operation performed

systemFingerprintstring

A unique identifier that represents the statistical signature of the language model that generated a specific chat completion. This fingerprint can be used for model attribution, debugging, and monitoring model behavior across request

temperaturenumber double

The temperature setting used for the LLM completion

errorReasonstring

The details of the error that occurred during the LLM completion

Example request

{
  "transactionId": "123e4567-e89b-12d3-a456-426614174000",
  "traceId": "123e4567-e89b-12d3-a456-426614174000",
  "model": "gpt4",
  "responseQualityScore": 45,
  "modelSource": "ANTHROPIC",
  "inputTokenCount": 50,
  "outputTokenCount": 150,
  "reasoningTokenCount": 1300,
  "cacheCreationTokenCount": 1300,
  "cacheReadTokenCount": 1300,
  "totalTokenCount": 200,
  "stopReason": "END",
  "inputTokenCost": 12.34,
  "outputTokenCost": 12.34,
  "totalCost": 12.34,
  "costType": "AI",
  "requestTime": "2025-03-02T15:04:05Z",
  "completionStartTime": "2025-03-02T15:04:05Z",
  "timeToFirstToken": 10200,
  "responseTime": "2025-03-02T15:04:06Z",
  "requestDuration": 1000,
  "mediationLatency": 1000,
  "provider": "OpenAI",
  "taskType": "completion",
  "subscriberCredentialName": "OpenAI Key (Production)",
  "subscriberCredential": "asd-123",
  "subscriberEmail": "user@example.com",
  "subscriberId": "user-123",
  "organizationId": "org-123",
  "subscriptionId": "subscr-456",
  "productId": "Free Trial",
  "agent": "Bishop",
  "operationType": "CHAT",
  "systemFingerprint": "fp_44z789a1c23def456gh7890ijkl1234mnopq567rstuv8910wxyz",
  "temperature": 0.78,
  "errorReason": "key not allowed to access model"
}

Response

AI completion successfully metered

objectstring required

Type of the object, typically 'metering'

labelstring required

A descriptive label for the metering response

createdstring

ISO8601 formatted timestamp when the response was created

updatedstring

ISO8601 formatted timestamp when the response was last updated

idstring required

Unique identifier for the metering response

signaturestring required

Signature used for validating the response data

_linksLinks

Example response

{
  "object": "metering",
  "label": "Metering Response",
  "created": "2025-03-02T15:04:05Z",
  "updated": "2025-03-02T15:04:06Z",
  "id": "abc123",
  "signature": "signature123"
}