# AgentDiet Structured Output — JSON Repair & Schema Validator

> AgentDiet Structured Output — JSON Repair & Schema Validator is a paid API for AI agents from agentdiet.dev, paid per call via x402 or MPP, $0.002/call, status unknown (last checked 2026-10-20).

Repairs truncated or malformed LLM JSON outputs (trailing commas, markdown fences, single quotes) and validates them against schemas so multi-agent pipelines never crash.

## Facts

- Endpoint: GET https://agentdiet.dev/v1/structured-output?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402, MPP
- Status: unknown
- Last checked: 2026-10-20
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agentdiet-structured-output-json-repair-schema-validator-4f0e31ce
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_BfbSsGwnMmPqKQyibC2Ls

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agentdiet-structured-output-json-repair-schema-validator-4f0e31ce
```

Example prompt: This JSON from the LLM is broken — it has trailing commas and markdown fences wrapping it. Can you repair it and give me back clean, valid JSON? Here's the raw string: ```{"name": "Alice", "age": 30,}```

## When to prefer this

Choose this endpoint when your multi-agent pipeline receives JSON from an LLM that may contain trailing commas, markdown code fences, single quotes, or truncation artifacts and you need deterministic repair before passing to the next stage. Prefer this over prompt-engineering retries when reliability and latency matter, or when you cannot re-invoke the LLM.

## Known failure modes

- Input JSON is so severely malformed it cannot be deterministically repaired — returns error indicating unparseable input
- Schema mismatch if output validation is requested and repaired JSON does not conform — returns validation error with field details
- Empty or null raw_json input — returns 400-style error
- Non-JSON input (e.g. plain text prose) — may return error or attempt best-effort repair with low confidence

## How this service works

Repairs truncated or malformed LLM JSON outputs (trailing commas, markdown fences, single quotes) so multi-agent pipelines never crash. (Live x402 v2, IETF MPP & MCP endpoint at https://agentdiet.dev/v1/structured-output)

## Output

A repaired, syntactically valid JSON object with all common LLM-induced malformations fixed — trailing commas removed, markdown fences stripped, single quotes replaced with double quotes, truncations resolved — ready for downstream consumption in an agent pipeline.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "raw_json"
 ],
 "properties": {
  "raw_json": {
   "type": "string",
   "minLength": 1,
   "description": "Malformed, truncated, or markdown-wrapped JSON string to deterministically repair"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object"
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agentdiet-structured-output-json-repair-schema-validator-4f0e31ce/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agentdiet.dev](https://www.zero.xyz/host/agentdiet.dev/llms.txt)
