Cost traces
Prerequisites
- A Paid API key.
- The Paid SDK installed in the service that makes AI provider calls.
- Optional: customers and products with stable external IDs when you want costs attributed to a specific account or product. You can also create them through the Products API and Customers API.
Capture your AI call
To capture the AI call, there are 2 steps:
- Let Paid autoinstrument your AI libraries at the initialization of your application (preferably in the main thread).
- Wrap your AI call in the Paid tracing context. Whether they’re wrapped directly or somewhere down the stack does not matter.
- If the AI call is not wrapped, the cost trace is still recorded, though unattributed to a customer or product.