_cost property to any event you ingest through Polar’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
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:TypeScript
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:

