LLM Output Validation
Parse AI output as JSON, repair common syntax mistakes and check supported schema rules. Returns parsed output and validation errors.
Pay by wallet (x402)
llm-output-validate Example
Example answer
{
"valid": false,
"errors": [],
"auto_fixed": false,
"error_count": 1,
"parse_error": "Unexpected token 'e', \"test\" is not valid JSON",
"parsed_output": null
} Inputs
| Field | Type | Required | What it is |
|---|---|---|---|
llm_output | string | Yes | Raw LLM output string |
strict_mode | boolean | No | — |
expected_schema | object | No | JSON Schema to validate against |
Output fields
How reliably each field appears in a successful answer.
| Field | Type | Appears |
|---|---|---|
valid | boolean | Always (present in every successful answer) |
errors | array | Always (present in every successful answer) |
auto_fixed | boolean | Always (present in every successful answer) |
parsed_output | any | Always (present in every successful answer) |
auto_fixed_output | string | Usually (present for most inputs) |
How to call it
The same tool through each route. MCP clients reach it through Strale’s server at https://api.strale.io/mcp; the call below is what the agent sends.
# Needs an API key. max_price_cents caps what this call may cost.
curl -X POST https://api.strale.io/v1/do \
-H "Authorization: Bearer $STRALE_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"capability_slug": "llm-output-validate",
"inputs": {
"llm_output": "{\"name\": \"Alice\", \"age\": 30, \"active\": true}"
},
"max_price_cents": 5
}' {
"tool": "strale_execute",
"arguments": {
"slug": "llm-output-validate",
"inputs": {
"llm_output": "{\"name\": \"Alice\", \"age\": 30, \"active\": true}"
},
"max_price_cents": 5
}
} import { Strale } from "straleio";
const strale = new Strale({ apiKey: process.env.STRALE_API_KEY! });
const result = await strale.do({
capability_slug: "llm-output-validate",
inputs: {
"llm_output": "{\"name\": \"Alice\", \"age\": 30, \"active\": true}"
},
max_price_cents: 5,
}); import os
from straleio import Strale, DoRequest
strale = Strale(api_key=os.environ["STRALE_API_KEY"])
result = strale.do(DoRequest(
capability_slug="llm-output-validate",
inputs={
"llm_output": "{\"name\": \"Alice\", \"age\": 30, \"active\": true}",
},
max_price_cents=5,
)) # No account. The first request answers 402 with the price in USDC;
# an x402 client pays it from your wallet and repeats the request.
curl -i 'https://api.strale.io/x402/v2/llm-output-validate?llm_output=%7B%22name%22%3A+%22Alice%22%2C+%22age%22%3A+30%2C+%22active%22%3A+true%7D' Limitations
Factual correctness is not checked
Checks output structure and format only. It does not verify that the content is factually correct.
What to do instead: Combine with domain-specific validation (e.g., schema checks, reference lookups) for factual verification
Related tools
- Code Review €0.20
- Prompt Optimiser €0.15