docs/gateway/api-reference/feedback.mdx
POST /feedbackThe /feedback endpoint assigns feedback to a particular inference or episode.
Each feedback is associated with a metric that is defined in the configuration file.
dryrunIf true, the feedback request will be executed but won't be stored to the database (i.e. no-op).
This field is primarily for debugging and testing, and you should ignore it in production.
episode_idepisodeThe episode ID to provide feedback for.
You should use this field when the metric level is episode.
Only use episode IDs that were returned by the TensorZero gateway.
inference_idinferenceThe inference ID to provide feedback for.
You should use this field when the metric level is inference.
Only use inference IDs that were returned by the TensorZero gateway.
metric_nameThe name of the metric to provide feedback.
For example, if your metric is defined as [metrics.draft_accepted] in your configuration file, then you would set metric_name: "draft_accepted".
The metric names comment and demonstration are reserved for special types of feedback.
A comment is free-form text (string) that can be assigned to either an inference or an episode.
The demonstration metric accepts values that would be a valid output.
See Metrics & Feedback for more details.
tagsUser-provided tags to associate with the feedback.
For example, {"user_id": "123"} or {"author": "Alice"}.
valueThe value of the feedback.
The type of the value depends on the metric type (e.g. boolean for a metric with type = "boolean").
feedback_idThe ID assigned to the feedback.
# ...
[metrics.draft_accepted]
type = "boolean"
level = "inference"
# ...
from tensorzero import AsyncTensorZeroGateway
async with await AsyncTensorZeroGateway.build_http(gateway_url="http://localhost:3000") as client:
result = await client.feedback(
inference_id="00000000-0000-0000-0000-000000000000",
metric_name="draft_accepted",
value=True,
)
curl -X POST http://localhost:3000/feedback \
-H "Content-Type: application/json" \
-d '{
"inference_id": "00000000-0000-0000-0000-000000000000",
"metric_name": "draft_accepted",
"value": true,
}'
{ "feedback_id": "11111111-1111-1111-1111-111111111111" }
# ...
[metrics.user_rating]
type = "float"
level = "episode"
# ...
from tensorzero import AsyncTensorZeroGateway
async with await AsyncTensorZeroGateway.build_http(gateway_url="http://localhost:3000") as client:
result = await client.feedback(
episode_id="00000000-0000-0000-0000-000000000000",
metric_name="user_rating",
value=10,
)
curl -X POST http://localhost:3000/feedback \
-H "Content-Type: application/json" \
-d '{
"episode_id": "00000000-0000-0000-0000-000000000000",
"metric_name": "user_rating",
"value": 10
}'
{ "feedback_id": "11111111-1111-1111-1111-111111111111" }