Back to Tensorzero

Code Example: How to track usage and cost

examples/docs/guides/operations/track-usage-and-cost/README.md

2026.4.1415 B
Original Source

Code Example: How to track usage and cost

This folder contains the code for the Guides » Operations » Track usage and cost page in the documentation.

Run the example

  1. Set the OPENAI_API_KEY environment variable.
  2. Launch TensorZero: docker compose up
  3. Install the dependencies: uv sync
  4. Run the script: uv run openai_sdk.py