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