Create Autocorrection
POST /v1/autocorrect
Creates a new autocorrection job to detect and fix hallucinations, factual errors, or quality issues in AI-generated responses.
Authentication
- Type: Bearer Token
Request Body
Field | Type | Required | Description |
---|---|---|---|
prompt | string | Yes | The original user prompt or question |
response | string | Yes | The AI-generated response to check and potentially correct |
context | string | Yes | Reference information to verify against |
top_k | number | No | Number of top chunks to consider (default: 3) |
Configuration Parameters
Parameter | Type | Required | Description |
---|---|---|---|
risk_threshold | number | No | Threshold for detecting issues (0-1, default: 0.7) |
enable_tools | boolean | No | Allow tools usage for verification (default: false) |
web_search | boolean | No | Enable web search for fact verification (default: false) |
correction_strategy | string | No | Strategy for corrections: "conservative" or "aggressive" |
Example Request
curl -X POST https://sandbox-api.pegasi.ai/v1/autocorrect \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"prompt": "What were Apple\'s Q1 2025 earnings?",
"response": "Apple reported $150 billion in revenue for Q1 2025, a 12% increase year-over-year.",
"context": "Apple Inc. (NASDAQ: AAPL) today announced financial results for its fiscal 2025 first quarter ended December 28, 2024. The Company posted quarterly revenue of $123.9 billion, an increase of 8% year over year.",
"top_k": 3,
"risk_threshold": 0.65,
"enable_tools": true,
"web_search": true,
"correction_strategy": "conservative"
}'
Response
{
"id": "autocorr_8f7d6e5c4b3a2f1e",
"status": "processing",
"created_at": "2025-06-11T22:34:30Z"
}
You can check the status and results of the autocorrection using the Get Autocorrection endpoint with the returned ID.
Tool Usage
When enable_tools
is set to true
, the autocorrection system can use various verification tools:
- Web Search: When
web_search
istrue
, searches the web for factual verification - Calculator: Verifies numerical calculations and comparisons
- Date Checker: Validates temporal claims and date references
- Entity Resolver: Disambiguates and verifies entity references
Correction Strategies
- Conservative: Only corrects clear factual errors while preserving the original response style and structure
- Aggressive: Makes more extensive corrections including style, clarity, and completeness improvements