---
title: "Meter an LLM completion"
method: POST
path: "/v2/ai/completions"
tags: ["AI Metering"]
---

# Meter an LLM completion

`POST /v2/ai/completions`

## Request

- Base URL: `https://api.revenium.io/meter`
- URL: `https://api.revenium.io/meter/v2/ai/completions`
- Auth: API key in header `x-api-key`
- TypeScript: <https://skmtc.dev/revenium/apis/revenium-metering-api/docs/v2/ai/completions/post.ts> (a function with typed inputs; its response is checked against the schema)

Record the details of an LLM completion

## Request body

- AICompletionMetadataResource: The AI completion metadata
  - `transactionId` string, required: The unique identifier of the LLM completion transaction
  - `traceId` string: Trace multiple LLM calls belonging to same overall request
  - `model` string, required: The model used for generating the LLM completion
  - `responseQualityScore` number, double: The quality score of the response
  - `modelSource` string: The source of the AI model used for the completion
  - `inputTokenCount` integer, required: The count of consumed input tokens
  - `outputTokenCount` integer, required: The count of consumed output tokens
  - `reasoningTokenCount` integer: The number of reasoning tokens in the completion
  - `cacheCreationTokenCount` integer: The number of cached creation tokens in the completion
  - `cacheReadTokenCount` integer: The number of cached read tokens in the completion
  - `totalTokenCount` integer, 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
  - `inputTokenCost` number, double: The input token cost associated with the LLM completion
  - `outputTokenCost` number, double: The output token cost associated with the LLM completion
  - `totalCost` number, double: The total cost associated with the LLM completion
  - `costType` 'AI', required: Cost type for the completion
  - `requestTime` string, required: The timestamp when the request was made
  - `completionStartTime` string, required: Time to first token for streaming requests
  - `timeToFirstToken` integer: The time to first token in milliseconds
  - `isStreamed` boolean, required: Indicates if the completion was streamed
  - `responseTime` string, required: The timestamp when the response was generated. If streaming, this is the time to first token
  - `requestDuration` integer, required: The duration of the request in milliseconds
  - `mediationLatency` integer: The latency, in milliseconds, of latency by an AI or API gateway
  - `provider` string, required: Vendor providing the LLM completion service
  - `taskType` string: 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.
  - `subscriberCredentialName` string: Populate the name of the subscriber credential from your system to allow Revenium to track usage & costs for individual users.
  - `subscriberCredential` string: Populate the ID of the subscriber from your system to allow Revenium to track usage & costs for individual users.
  - `subscriberEmail` string: The email address of the subscriber
  - `subscriberId` string: 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.
  - `organizationId` string: 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.
  - `subscriptionId` string: Unique identifier of the subscription from your own system that you wish to use to correlate usage between Revenium & your application.
  - `productId` string: Identifier of the product from your own system that you wish to use to correlate usage between Revenium & your application.
  - `agent` string: The AI agent that is making the request
  - `operationType` 'CHAT' | 'GENERATE' | 'EMBED' | 'CLASSIFY' | 'SUMMARIZE' | 'TRANSLATE' | 'OTHER': The type of operation performed
  - `systemFingerprint` string: 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
  - `temperature` number, double: The temperature setting used for the LLM completion
  - `errorReason` string: The details of the error that occurred during the LLM completion

## Response `201`

AI completion successfully metered

- MeteringResponseResource: Metering response resource details for the metering API, providing metadata about response creation and validation.
  - `object` string, required: Type of the object, typically 'metering'
  - `label` string, required: A descriptive label for the metering response
  - `created` string: ISO8601 formatted timestamp when the response was created
  - `updated` string: ISO8601 formatted timestamp when the response was last updated
  - `id` string, required: Unique identifier for the metering response
  - `signature` string, required: Signature used for validating the response data
  - `_links` Links

## Other responses

- `400`: Invalid input data
- `401`: Unauthorized - Authentication required
- `403`: Forbidden - Insufficient permissions
- `404`: Not Found
- `409`: Conflict

## Changes

- **2025-11-06** `8fb79ecfebda`: 3 breaking, 4 warning, 6 info
  - the request property `transactionId` became required
  - removed the enum value `CANCELLED` of the request property `stopReason`
  - removed the required property `resourceType` from the response with the `201` status
  - removed the request property `cacheCreationTokenCost`
  - …9 more
- **2025-11-06** `2042270cbdca`: 1 breaking, 4 warning, 8 info
  - removed the required property `object` from the response with the `201` status
  - removed the request property `subscriberCredential`
  - removed the request property `subscriberCredentialName`
  - removed the request property `subscriberEmail`
  - …9 more
- **2025-06-18** `8fb79ecfebda`: 2 breaking, 4 warning, 5 info
  - removed the enum value `CANCELLED` of the request property `stopReason`
  - removed the required property `resourceType` from the response with the `201` status
  - removed the request property `cacheCreationTokenCost`
  - removed the request property `cacheReadTokenCost`
  - …7 more
- **2025-06-18** `8a82b089285a`: 1 breaking, 4 warning, 6 info
  - removed the required property `object` from the response with the `201` status
  - removed the request property `subscriberCredential`
  - removed the request property `subscriberCredentialName`
  - removed the request property `subscriberEmail`
  - …7 more
- …earlier changes not shown

[Operation history](https://skmtc.dev/revenium/apis/revenium-metering-api/changes/v2/ai/completions/post.md)

---

[API](https://skmtc.dev/revenium/apis/revenium-metering-api.md) - [All operations](https://skmtc.dev/revenium/apis/revenium-metering-api/llms.txt) - [OpenAPI document](https://skmtc.dev/revenium/apis/revenium-metering-api/revisions/8fb79ecfebda?raw)
