_cost property to any event you ingest through OurPay’s Event Ingestion API. These costs are then aggregated and made available through the Metrics API alongside revenue metrics.
The _cost Property
Basic Structure
To track costs, add a_cost property to your event’s metadata when ingesting events.
TypeScript (SDK)
cURL
Cost Metadata Schema
The_cost property has the following structure:
-
amount(required): The cost amount in cents as a decimal number- Example:
0.025for $0.00025 (a fraction of a cent) - Example:
150for $1.50 - Supports up to 17 digits with 12 decimal places for precision
- Example:
-
currency(required): The currency code- Currently only
"usd"is supported
- Currently only
Amount must be in cents: The
amount field represents the cost in cents,
not dollars. For example, 100 = \$1.00, 0.5 = \$0.005 (half a cent), and
0.001 = \$0.00001 (one hundredth of a cent).Use Cases
AI/LLM Applications
Track the cost of LLM API calls per customer:TypeScript
This is a text-token cost estimate using OpenAI’s GPT-6 Astra rates, checked September 13, 2026. The standard rates are 1 per million cached input tokens and $50 per million output tokens. The example applies the documented long-context multipliers above 272,000 input tokens. Cache-write charges, tools, other service tiers and account-specific charges need separate entries. Keep rates configurable and reconcile estimates against provider billing.
Infrastructure Costs
Track compute, storage, or API costs:Third-Party Service Costs
Track costs from external services:Best Practices
Track Costs in Real-Time
Ingest cost events as they occur to maintain accurate, up-to-date metrics: Record the event after the provider returns usage, as in the example above. Use a stable event name such asllm.inference and keep the model identifier in metadata. Queue ingestion retries with a stable event identifier so a transient network failure does not count the same request twice.
Use Precise Amounts
Theamount field supports up to 12 decimal places, perfect for tracking micro-costs:
Add Context with Additional Metadata
Combine_cost with other metadata to understand cost drivers: