> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orq.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Add Human Reviews | Add Human feedback to generations

> Add structured human feedback to LLM traces and spans. Capture quality assessments, corrections, and review AI responses via the AI Studio or API.

Annotations are structured key-value pairs that capture human feedback on traces and spans in your observability data. They enable quality assessment, human review workflows, and training dataset curation from human-reviewed traces.

**Use Cases**

<AccordionGroup>
  <Accordion title="Collecting quality feedback" icon="thumbs-up">
    Capture thumbs up/down ratings, custom scores, or categorical labels on AI responses. Build a feedback loop that surfaces low-quality generations for review.
  </Accordion>

  <Accordion title="Compliance and QA review" icon="shield-check">
    Flag responses with specific defects (hallucination, off-topic, inappropriate content) using structured annotation keys shared across your team.
  </Accordion>

  <Accordion title="Dataset curation" icon="database">
    Annotate traces with corrections and quality labels, then export curated subsets as training datasets for future experiments.
  </Accordion>

  <Accordion title="Human-in-the-loop workflows" icon="user-check">
    Route traces to annotation queues for systematic expert review. Combine with Trace Automations to automatically surface traces that meet specific criteria.
  </Accordion>
</AccordionGroup>

**Concepts**

Three concepts work together to form the annotations system:

* **Human Review**: defines the schema (key, value type, options) that annotations must conform to
* **Annotations**: the actual feedback values applied to a trace or span
* **Annotation Queues**: organized workflows for reviewing traces in bulk via the AI Studio

<CardGroup cols={3}>
  <Card title="Human Review" icon="clipboard-list" href="#create-human-review">
    Define annotation schemas: keys, value types, and validation rules. Available on all traces and spans in the project once created.
  </Card>

  <Card title="Annotations" icon="pen" href="#use-annotations">
    Apply structured human feedback to traces and spans via the AI Studio or programmatically via the API.
  </Card>

  <Card title="Annotation Queues" icon="list-check" href="#create-annotation-queues">
    Organize human review workflows. Filter and present relevant traces for review in bulk.
  </Card>
</CardGroup>

## Create Human Review

Human Reviews define the structure and validation rules for annotations. Each annotation key must match an existing Human Review definition in the project.

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    To create a Human Review, head to **Project Settings > Human Review** and press the `+` button.

    <Frame caption="Customizing a Human Review.">
      <img src="https://mintcdn.com/orqai/6HurnhGELvozB4iC/images/docs/human-review-settings.png?fit=max&auto=format&n=6HurnhGELvozB4iC&q=85&s=0de8b6fbf5c6356d4d6c63891cbbf980" alt="Create human review form with Key, Title, Description fields and a Type selector showing Categorical, Range, and Text options." width="1018" height="994" data-path="images/docs/human-review-settings.png" />
    </Frame>

    Three Human Review types are available:

    * **Categorical**: button options with custom labels, such as good/bad or saved/deleted
    * **Range**: a custom scoring slider, for example a scale from 0 to 100
    * **Open field**: free-form text input for detailed comments

    <Info>
      Once created, a Human Review is available on all traces and spans in the project. No additional configuration or filtering required.
    </Info>
  </Tab>
</Tabs>

### Common Annotation Types   <Badge color="yellow">Legacy</Badge>

<AccordionGroup>
  <Accordion title="Rating" icon="star">
    Rate the overall quality of AI responses:

    | Rating   | Description                               |
    | -------- | ----------------------------------------- |
    | **good** | The response was helpful and accurate.    |
    | **bad**  | The response was unhelpful or inaccurate. |
  </Accordion>

  <Accordion title="Defects" icon="triangle-exclamation">
    Identify specific issues with AI responses:

    | Defect             | Description                                                   |
    | ------------------ | ------------------------------------------------------------- |
    | **grammatical**    | Responses that contain grammatical errors                     |
    | **spelling**       | Responses that contain spelling errors                        |
    | **hallucination**  | Responses that contain hallucinations or factual inaccuracies |
    | **repetition**     | Responses that contain unnecessary repetition                 |
    | **inappropriate**  | Responses that are deemed inappropriate or offensive          |
    | **off\_topic**     | Responses that do not address the user's query                |
    | **incompleteness** | Responses that are incomplete or partially address the query  |
    | **ambiguity**      | Responses that are vague or unclear                           |

    <Info>
      You can select multiple defects for one response by using an array-type Human Review.
    </Info>
  </Accordion>
</AccordionGroup>

## Use Annotations

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    The annotation capabilities differ between [Logs](/docs/observability/logs) and [Traces](/docs/observability/traces). Logs support both human feedback and corrections, while Traces only support human feedback annotations.

    <Tabs>
      <Tab title="Traces">
        Navigate to the [Traces](/docs/observability/traces) view and select a single trace. The **Annotations** panel will be displayed, allowing you to apply human feedback to the AI response.

        <Frame caption="The Annotations panel in Traces lets you apply human feedback.">
          <img src="https://mintcdn.com/orqai/cbhNm3-6xhlam62F/images/trace-annotation.png?fit=max&auto=format&n=cbhNm3-6xhlam62F&q=85&s=64bb4202d2f67874dafdcb4f397e1d28" alt="Trace detail panel for a claude-sonnet chat-completion showing Evaluations section with Defects, Interactions, and Rating feedback options including good/bad thumbs." width="1732" height="873" data-path="images/trace-annotation.png" />
        </Frame>
      </Tab>

      <Tab title="Logs">
        Navigate to the [Logs](/docs/observability/logs) view and select a single log. The **Annotations** panel will be displayed, allowing you to apply human feedback and provide corrections to the AI response.

        <Frame caption="The Annotations panel in Logs lets you apply human feedback and corrections.">
          <img src="https://mintcdn.com/orqai/mDs6v2JrTlXp9Ikl/images/docs/e43e24e-Screenshot_2024-07-03_at_22.14.37.png?fit=max&auto=format&n=mDs6v2JrTlXp9Ikl&q=85&s=c31df329ce6cbe2dbfb6ebf6c80b9e38" alt="Log panel showing a botanist assistant conversation with Rating (good/bad), Defects, and Interactions annotation options on the right, and an Add correction button below the assistant response." width="1762" height="1162" data-path="images/docs/e43e24e-Screenshot_2024-07-03_at_22.14.37.png" />
        </Frame>

        To make a correction, use the **Add correction** button below the AI-generated response:

        <Frame caption="The Add correction button is below the Assistant response.">
          <img src="https://mintcdn.com/orqai/x_6IXnot9ETOc_0g/images/docs/12dc1bf-8bdb4f9-iScreen_Shoter_-_Google_Chrome_-_240712114908.jpg?fit=max&auto=format&n=x_6IXnot9ETOc_0g&q=85&s=74509ec20d6f11fbb921cd8eb054ee0a" alt="Assistant response box with an Add correction button highlighted in red below it." width="1824" height="606" data-path="images/docs/12dc1bf-8bdb4f9-iScreen_Shoter_-_Google_Chrome_-_240712114908.jpg" />
        </Frame>

        Click to add a correction, which opens an editor where you can manually revise the model's response. Once you've finished editing, select **Save** to store the correction.

        <Frame caption="The corrected text and correction will appear side by side, with the correction displayed in green.">
          <img src="https://mintcdn.com/orqai/x_6IXnot9ETOc_0g/images/docs/696d0fe-iScreen_Shoter_-_Google_Chrome_-_240715135648.jpg?fit=max&auto=format&n=x_6IXnot9ETOc_0g&q=85&s=4bc0d14bf27af264fbb26d7d091c5fa8" alt="Original assistant response shown in purple above a Correction box in green, with the corrected text entered and a Save button." width="2216" height="883" data-path="images/docs/696d0fe-iScreen_Shoter_-_Google_Chrome_-_240715135648.jpg" />
        </Frame>

        <Info>
          Corrections are valuable for building curated datasets. Learn more in [Creating a Curated Dataset](/docs/datasets/creating).
        </Info>
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="API & SDK" icon="code">
    Here are examples on how to use the API to annotate LLM responses.

    <AccordionGroup>
      <Accordion title="Add a Quality Rating" icon="star">
        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl -X POST "https://api.orq.ai/v2/traces/{trace_id}/spans/{span_id}/annotation" \
            -H "Authorization: Bearer $ORQ_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "annotations": [
                {
                  "key": "rating",
                  "value": "good"
                }
              ]
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          from orq_ai_sdk import Orq
          import os

          orq = Orq(api_key=os.getenv("ORQ_API_KEY"))

          result = orq.annotations.create(
              trace_id="<trace_id>",
              span_id="<span_id>",
              annotations=[
                  {
                      "key": "rating",
                      "value": "good"
                  }
              ]
          )

          print(result)
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const orq = new Orq({
            apiKey: process.env.ORQ_API_KEY,
          });

          const result = await orq.annotations.create({
            traceId: "<trace_id>",
            spanId: "<span_id>",
            annotations: [
              {
                key: "rating",
                value: "good"
              }
            ]
          });

          console.log(result);
          ```
        </CodeGroup>
      </Accordion>

      <Accordion title="Add Multiple Defects" icon="triangle-exclamation">
        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl -X POST "https://api.orq.ai/v2/traces/{trace_id}/spans/{span_id}/annotation" \
            -H "Authorization: Bearer $ORQ_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "annotations": [
                {
                  "key": "defects",
                  "value": ["grammatical", "spelling", "ambiguity"]
                }
              ]
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          from orq_ai_sdk import Orq
          import os

          orq = Orq(api_key=os.getenv("ORQ_API_KEY"))

          result = orq.annotations.create(
              trace_id="<trace_id>",
              span_id="<span_id>",
              annotations=[
                  {
                      "key": "defects",
                      "value": ["grammatical", "spelling", "ambiguity"]
                  }
              ]
          )

          print(result)
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const orq = new Orq({
            apiKey: process.env.ORQ_API_KEY,
          });

          const result = await orq.annotations.create({
            traceId: "<trace_id>",
            spanId: "<span_id>",
            annotations: [
              {
                key: "defects",
                value: ["grammatical", "spelling", "ambiguity"]
              }
            ]
          });

          console.log(result);
          ```
        </CodeGroup>
      </Accordion>

      <Accordion title="Add a Numeric Score" icon="gauge">
        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl -X POST "https://api.orq.ai/v2/traces/{trace_id}/spans/{span_id}/annotation" \
            -H "Authorization: Bearer $ORQ_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "annotations": [
                {
                  "key": "confidence_score",
                  "value": 0.95
                }
              ],
              "metadata": {
                "identityId": "user-123"
              }
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          from orq_ai_sdk import Orq
          import os

          orq = Orq(api_key=os.getenv("ORQ_API_KEY"))

          result = orq.annotations.create(
              trace_id="<trace_id>",
              span_id="<span_id>",
              annotations=[
                  {
                      "key": "confidence_score",
                      "value": 0.95
                  }
              ],
              metadata={
                  "identityId": "user-123"
              }
          )

          print(result)
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const orq = new Orq({
            apiKey: process.env.ORQ_API_KEY,
          });

          const result = await orq.annotations.create({
            traceId: "<trace_id>",
            spanId: "<span_id>",
            annotations: [
              {
                key: "confidence_score",
                value: 0.95
              }
            ],
            metadata: {
              identityId: "user-123"
            }
          });

          console.log(result);
          ```
        </CodeGroup>
      </Accordion>

      <Accordion title="Add a Text Correction" icon="pen">
        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl -X POST "https://api.orq.ai/v2/traces/{trace_id}/spans/{span_id}/annotation" \
            -H "Authorization: Bearer $ORQ_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "annotations": [
                {
                  "key": "correction",
                  "value": "The correct answer should emphasize scalability and fault tolerance."
                }
              ]
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          from orq_ai_sdk import Orq
          import os

          orq = Orq(api_key=os.getenv("ORQ_API_KEY"))

          result = orq.annotations.create(
              trace_id="<trace_id>",
              span_id="<span_id>",
              annotations=[
                  {
                      "key": "correction",
                      "value": "The correct answer should emphasize scalability and fault tolerance."
                  }
              ]
          )

          print(result)
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const orq = new Orq({
            apiKey: process.env.ORQ_API_KEY,
          });

          const result = await orq.annotations.create({
            traceId: "<trace_id>",
            spanId: "<span_id>",
            annotations: [
              {
                key: "correction",
                value: "The correct answer should emphasize scalability and fault tolerance."
              }
            ]
          });

          console.log(result);
          ```
        </CodeGroup>
      </Accordion>

      <Accordion title="Batch Add Multiple Annotations" icon="layer-group">
        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl -X POST "https://api.orq.ai/v2/traces/{trace_id}/spans/{span_id}/annotation" \
            -H "Authorization: Bearer $ORQ_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "annotations": [
                {
                  "key": "rating",
                  "value": "good"
                },
                {
                  "key": "confidence_score",
                  "value": 0.92
                },
                {
                  "key": "categories",
                  "value": ["helpful", "accurate", "concise"]
                }
              ]
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          from orq_ai_sdk import Orq
          import os

          orq = Orq(api_key=os.getenv("ORQ_API_KEY"))

          result = orq.annotations.create(
              trace_id="<trace_id>",
              span_id="<span_id>",
              annotations=[
                  {"key": "rating", "value": "good"},
                  {"key": "confidence_score", "value": 0.92},
                  {"key": "categories", "value": ["helpful", "accurate", "concise"]}
              ]
          )

          print(result)
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const orq = new Orq({
            apiKey: process.env.ORQ_API_KEY,
          });

          const result = await orq.annotations.create({
            traceId: "<trace_id>",
            spanId: "<span_id>",
            annotations: [
              { key: "rating", value: "good" },
              { key: "confidence_score", value: 0.92 },
              { key: "categories", value: ["helpful", "accurate", "concise"] }
            ]
          });

          console.log(result);
          ```
        </CodeGroup>
      </Accordion>

      <Accordion title="Remove Annotations" icon="trash">
        <CodeGroup>
          ```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
          curl -X DELETE "https://api.orq.ai/v2/traces/{trace_id}/spans/{span_id}/annotation" \
            -H "Authorization: Bearer $ORQ_API_KEY" \
            -H "Content-Type: application/json" \
            -d '{
              "keys": ["rating", "defects"]
            }'
          ```

          ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
          from orq_ai_sdk import Orq
          import os

          orq = Orq(api_key=os.getenv("ORQ_API_KEY"))

          result = orq.annotations.delete(
              trace_id="<trace_id>",
              span_id="<span_id>",
              keys=["rating", "defects"]
          )

          print(result)
          ```

          ```typescript TypeScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
          import { Orq } from "@orq-ai/node";

          const orq = new Orq({
            apiKey: process.env.ORQ_API_KEY,
          });

          const result = await orq.annotations.delete({
            traceId: "<trace_id>",
            spanId: "<span_id>",
            keys: ["rating", "defects"]
          });

          console.log(result);
          ```
        </CodeGroup>
      </Accordion>
    </AccordionGroup>

    **API Error Handling**

    | Status Code | Error                  | Example Message                                                          | Solution                                                                      |
    | ----------- | ---------------------- | ------------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
    | **404**     | Human Review Not Found | `The human review with key "rating" for workspace abc123 was not found.` | Create a Human Review with the specified key before annotating.               |
    | **404**     | Span Not Found         | `Span with id xyz789 for workspace abc123 was not found.`                | Verify the `trace_id` and `span_id` are correct and belong to your workspace. |
    | **400**     | Invalid Value          | `Invalid value: poor. Valid options are: good, bad.`                     | Ensure the value matches the options defined in the Human Review.             |
    | **400**     | Value Out of Range     | `Value 15 is out of range [0, 10].`                                      | Provide a number within the defined min/max range for the Human Review.       |
    | **400**     | String Too Long        | `String value exceeds maximum length of 200 characters.`                 | Shorten the string annotation to 200 characters or less.                      |

    <Callout icon="hat-chef" color="#7ecece">
      See a complete feedback loop implemented from scratch. Read our cookbook [Capturing User Feedback](/docs/tutorials/capturing-feedback-with-orq).
    </Callout>

    **Constraints**

    * **Batch Limits**: up to 10 annotations per create request, up to 10 keys per delete request
    * **String Length**: string values are limited to 200 characters maximum
    * **Deployment Span Propagation**: when annotating a deployment span, the associated log is automatically annotated with the same values
    * **Metadata Fields**: optional `metadata` object supports `identityId`, `source`, and `reviewerId` for tracking and attribution
  </Tab>
</Tabs>

## Create Annotation Queues

Annotation Queues help you organize and apply Human Reviews effectively to relevant incoming traces.

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    To create an Annotation Queue, head to **AI Studio > Annotation Queue**.

    Choose **Create Annotation Queue**.

    The following fields are configurable:

    * The **Name** of the queue
    * The **Description** of the Annotation Queue
    * The [**Human Reviews**](/docs/projects/human-review) that traces will be reviewed by

    <Frame>
      <img src="https://mintcdn.com/orqai/sryADi5wGnaYx1XV/images/creating-annotation-queue.png?fit=max&auto=format&n=sryADi5wGnaYx1XV&q=85&s=8e4794ae50295bafd81b737d63c73593" alt="Create Annotation Queue panel with fields for name, description, and human reviews, showing Defects, Interactions, and Rating tags selected." width="1180" height="1260" data-path="images/creating-annotation-queue.png" />
    </Frame>

    Annotation Queues can be filled with traces using [Trace Automations](/docs/observability/trace-automation), which automatically route traces to the appropriate queue based on your configured rules.
  </Tab>
</Tabs>

## Use Annotation Queues

<Tabs>
  <Tab title="AI Studio" icon="https://mintcdn.com/orqai/My16MDKJXrKALEHC/images/logos/ai-studio-round.svg?fit=max&auto=format&n=My16MDKJXrKALEHC&q=85&s=ac04dd509320d58ab9701cb6d6137733" width="100" height="100" data-path="images/logos/ai-studio-round.svg">
    When opening an Annotation Queue, you have easy access to all traces that need feedback.

    <Frame caption="All feedbacks and actions have keyboard shortcuts available">
      <img src="https://mintcdn.com/orqai/8LR_8MYngeJCi-9L/images/annotation-queue.png?fit=max&auto=format&n=8LR_8MYngeJCi-9L&q=85&s=955513aaab00c399c946f5ec7c785d53" alt="Annotation queue view showing a trace with system, user, and assistant messages on the left, and Defects and Interactions feedback options on the right, with keyboard-shortcut navigation." width="1735" height="1194" data-path="images/annotation-queue.png" />
    </Frame>

    On the right side of the panel, review and apply feedback to the conversation. Use **Next** to access the next trace in the queue.

    <Tip>
      You can add any trace manually to a [Dataset](/docs/datasets/overview) to use in a future [Experiment](/docs/experiments/overview), to ensure further testing on model behavior.
    </Tip>
  </Tab>
</Tabs>
