Meter an LLM completion
Changed onRecord the details of an LLM completion
Request
- Base URLhttps://api.revenium.io/meter
- AuthAPI key in header x-api-key
- TypeScriptA function with typed inputs. Its response is checked against the schema.
Request body
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
Example response
{
"object": "metering",
"label": "Metering Response",
"created": "2025-03-02T15:04:05Z",
"updated": "2025-03-02T15:04:06Z",
"id": "abc123",
"signature": "signature123"
}Changes
- breaking
the request property
became required - breaking
removed the enum value
CANCELLEDof the request property - breaking
removed the required property
from the response with the status - warning
removed the request property
- warning
removed the request property
- warning
removed the request property
- warning
removed the request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
removed the non-success response with the status
- info
added the required property
to the response with the status
- breaking
- breaking
removed the required property
from the response with the status - warning
removed the request property
- warning
removed the request property
- warning
removed the request property
- warning
removed the request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
added the new optional request property
- info
the request property
became optional - info
added the new
CANCELLEDenum value to the request property - info
added the non-success response with the status
- info
added the required property
to the response with the status
- breaking