# Corrected Outputs

Corrections allow you to capture improved versions of LLM outputs directly in trace and observation views. Domain experts can document what the model should have generated, creating a foundation for fine-tuning datasets and continuous improvement.

## Why Use Corrections?
- **Domain expert feedback**: Subject matter experts provide what the model should have output based on their expertise  
- **Fine-tuning datasets**: Export corrected outputs alongside original inputs to create high-quality training data from production traces  
- **Quality benchmarking**: Compare actual vs expected outputs across your production traces to identify systematic issues  
- **Human-in-the-loop workflows**: Capture corrections during review processes, especially useful in [annotation queues](/content/docs/evaluation/evaluation-methods/annotation-queues/index.html)

## How It Works
Add corrected outputs to any trace or observation through the UI or API. Corrections appear alongside the original output with a diff view showing what changed. Each trace or observation can have one corrected output.

## Adding Corrections

### Via the UI
Navigate to any trace or observation detail page:
1. Find the **"Corrected Output"** field below the original output  
2. Click to add or edit the correction  
3. Enter the improved version of the output  
4. Toggle between **JSON validation mode** and **plain text mode** to match your data format  
5. View the **diff** to compare original vs corrected output

The editor auto-saves as you type and provides real-time validation feedback in JSON mode.

### Via API/SDK
Corrections are created as scores with `dataType: "CORRECTION"` and `name: "output"`.

```python
from langfuse import Langfuse

langfuse = Langfuse()

# Add correction to a trace
langfuse.create_score(
    trace_id="trace-123",
    name="output",
    value="The corrected output text here",
    data_type="CORRECTION"
)

# Add correction to an observation
langfuse.create_score(
    trace_id="trace-123",
    observation_id="obs-456",
    name="output",
    value="The corrected output text here",
    data_type="CORRECTION"
)
```

```typescript
import { LangfuseClient } from "@langfuse/client";

const langfuse = new LangfuseClient();

// Add correction to a trace
langfuse.score.create({
  traceId: "trace-123",
  name: "output",
  value: "The corrected output text here",
  dataType: "CORRECTION"
});

// Add correction to an observation
langfuse.score.create({
  traceId: "trace-123",
  observationId: "obs-456",
  name: "output",
  value: "The corrected output text here",
  dataType: "CORRECTION"
});
```

```bash
curl -X POST https://cloud.langfuse.com/api/public/scores \
  -H "Content-Type: application/json" \
  -H "Authorization: Basic <base64_encoded_credentials>" \
  -d '{
    "traceId": "trace-123",
    "observationId": "obs-456",
    "name": "output",
    "value": "The corrected output text here",
    "dataType": "CORRECTION"
  }'
```

## Fetching Corrections
Corrections are stored as scores and can be fetched programmatically to build datasets or analyze model performance.

* * *
