Back to Tensorzero

Guide: Metrics & Feedback

examples/guides/metrics-feedback/README.md

2026.4.1960 B
Original Source

Guide: Metrics & Feedback

This directory contains the code for the Metrics & Feedback guide.

Running the Example

  1. Set the OPENAI_API_KEY environment variable:
bash
export OPENAI_API_KEY="sk-..." # Replace with your OpenAI API key
  1. Launch the TensorZero Gateway, the TensorZero UI, and a local Postgres database:
bash
docker compose up
  1. Run the example:
<details> <summary><b>Python</b></summary>

a. Install the Python dependencies. We recommend using uv:

bash
uv sync

b. Run the example:

bash
uv run main.py
</details> <details> <summary><b>HTTP</b></summary>
bash
curl -X POST http://localhost:3000/feedback \
  -H "Content-Type: application/json" \
  -d '{
    "metric_name": "haiku_rating",
    "inference_id": "00000000-0000-0000-0000-000000000000",
    "value": true
  }';
</details>