Skip to main content
The Annotations API attaches structured human review values to a completed request’s Trace and span. Where the Annotations page covers the AI Studio review workflows (the Annotations panel in Traces and Logs, Annotation Queues, and experiments), this page is the API usage guide: how to capture the identifiers, shape the request body, and handle the response.

Use Cases

Record thumbs up/down or categorical ratings programmatically as users interact with responses, without opening AI Studio.
Log structured defect tags such as hallucination, off-topic, or incomplete at scale for systematic quality analysis.
Store a corrected response alongside the original to build gold-standard pairs for evaluation datasets.
Correct an LLM-as-a-judge result with a human review, attaching an explanation to the corrected output.

Attach Annotations to a Span

Each annotation must be defined before it can be applied. The definition sets the key, title, and value type; every annotation submitted through the API has to match one of these definitions, and a key that does not exist in the workspace is rejected with a 404. Create definitions under Optimization > Annotations in AI Studio, or under Settings > Annotations in AI Gateway, as described on the Annotations page.
Annotation definition form with Key set to star-rating, Title set to Star rating 1-5, Type set to Range, and Minimum 1 and Maximum 5.

Defining a range annotation with the key star-rating.

With the definition in place, two steps:
  1. Capture the trace_id and span_id from the completion response. The completion response returns telemetry that includes both identifiers for the request being annotated.
  2. Submit the annotations with the Annotate a Span API, using the key of an existing annotation definition.
Some API error messages still refer to annotations as human reviews. The two names describe the same object: annotations were previously called human reviews, and a message such as The human review with key "star-rating" ... was not found. refers to the annotation definition with that key.
Annotations are available on chat completion and Responses API spans. When annotating a deployment span, the associated log is automatically annotated with the same values.

Annotations Fields

Fields marked with * are always required. key and parent_annotation_id are conditionally required: each entry carries exactly one of them. An annotation entry is either a standard annotation with key and value, or a correction with parent_annotation_id, value, and optionally explanation. The two shapes are mutually exclusive.

Annotation Values

The value type must match the annotation’s definition:
  • Categorical, single-select: a string or a single-element array, for example "good" or ["good"]
  • Categorical, multi-select: an array of strings, for example ["grammatical", "hallucination"]
  • Range: a number within the annotation’s configured min/max, for example 4 on a 1-5 range
  • Boolean: true or false
  • Text or correction: a string, up to 3000 characters
String values outside the annotation’s configured options are rejected; see Error Handling.

Corrections

A correction replaces an existing evaluator output with a human-reviewed value:
The corrected value must match the evaluator annotation’s own output type. See Correct an Evaluator Result for the UI equivalent.

Batch Annotations

Send up to 10 annotation entries in a single request:

Remove Annotations

Submit keys to the Remove an Annotation from a Span API to delete standard annotations, or parent_annotation_ids to delete corrections by the eval ids of their parent annotations. Up to 10 of each per request. The examples below show keys; to delete a correction, replace the body with {"parent_annotation_ids": ["<evaluator_annotation_id>"]}.

Where Annotations Surface

Annotations applied through the API appear in the Annotations panel of the span and log detail views in Traces and Logs.

Error Handling

See a complete feedback loop implemented from scratch. Read our cookbook Capturing User Feedback.

Constraints

  • Batch limits: up to 10 annotations per create request, up to 10 keys and 10 parent_annotation_ids per delete request
  • Value length: string values are limited to 3000 characters; annotation definitions do not impose a tighter limit
  • Metadata fields: the optional metadata object supports identity_id (identityId in the Node SDK) for reviewer attribution

See Also