{
  "product": "SafeResponse",
  "base_url": "https://saferesponse.ai",
  "endpoint": "/api/validate.php",
  "examples": [
    {
      "name": "PASS - valid customer record",
      "use_case": "Agent extracted structured customer data correctly on the first try.",
      "input": {
        "response": "{\"name\":\"Alice\",\"email\":\"alice@example.com\",\"age\":30}",
        "schema": {
          "required": {
            "name": "string",
            "email": "string",
            "age": "integer"
          }
        },
        "cost_per_llm_call": 0.02,
        "assumed_blind_retries": 2,
        "src": "docs"
      },
      "output": {
        "ok": true,
        "action": "pass",
        "reason": "Valid JSON matches schema",
        "data": {
          "name": "Alice",
          "email": "alice@example.com",
          "age": 30
        },
        "estimated_savings": {
          "usd": 0.04,
          "formula": "$0.0200 × 2 prevented retries"
        }
      },
      "why_it_matters": "Agent can continue immediately with no blind retry."
    },
    {
      "name": "RETRY - missing required field",
      "use_case": "Agent returned JSON but forgot the email field.",
      "input": {
        "response": "{\"name\":\"Alice\",\"age\":30}",
        "schema": {
          "required": {
            "name": "string",
            "email": "string",
            "age": "integer"
          }
        },
        "cost_per_llm_call": 0.02,
        "assumed_blind_retries": 2,
        "src": "docs"
      },
      "output": {
        "ok": false,
        "action": "retry",
        "reason": "Schema validation failed",
        "errors": [
          {
            "field": "email",
            "error": "missing_required_field",
            "expected": "string"
          }
        ],
        "retry_prompt": "Return ONLY valid JSON matching the required schema. No prose, no markdown, no code fences.",
        "estimated_savings": {
          "usd": 0.02,
          "formula": "$0.0200 × 1 prevented retries"
        }
      },
      "why_it_matters": "Retry only when recovery is likely."
    },
    {
      "name": "FAIL - invalid JSON",
      "use_case": "Model responded with prose instead of machine-readable output.",
      "input": {
        "response": "Here is the result: Alice, alice@example.com, 30",
        "schema": {
          "required": {
            "name": "string",
            "email": "string",
            "age": "integer"
          }
        },
        "cost_per_llm_call": 0.02,
        "assumed_blind_retries": 2,
        "src": "docs"
      },
      "output": {
        "ok": false,
        "action": "fail",
        "reason": "Invalid JSON: Syntax error",
        "retry_prompt": "Return ONLY valid JSON matching the required schema. No prose, no markdown, no code fences.",
        "estimated_savings": {
          "usd": 0.04,
          "formula": "$0.0200 × 2 prevented retries"
        }
      },
      "why_it_matters": "Stops broken downstream parsing and infinite loops."
    },
    {
      "name": "FAIL - empty response",
      "use_case": "LLM returned nothing because upstream failed silently.",
      "input": {
        "response": "",
        "schema": {
          "required": {
            "ticket_id": "string",
            "classification": "string"
          }
        },
        "cost_per_llm_call": 0.05,
        "assumed_blind_retries": 2,
        "src": "docs"
      },
      "output": {
        "ok": false,
        "action": "fail",
        "reason": "Empty response payload",
        "estimated_savings": {
          "usd": 0.1,
          "formula": "$0.0500 × 2 prevented retries"
        }
      },
      "why_it_matters": "Prevents wasted runs when the model returns nothing."
    }
  ]
}