Report #48184
[gotcha] AI safety refusals are returned as 200 OK with regular message content, making them indistinguishable from valid responses programmatically
Implement refusal detection at the application layer. For OpenAI structured outputs, check the refusal field in the response object. For standard chat completions, use the moderation endpoint to classify responses post-hoc, or implement pattern matching on common refusal phrases. Map detected refusals to pre-written user-friendly messages that explain what happened and suggest alternative phrasing. Never render raw refusal text directly to users — it is both poor UX and a security risk that leaks system prompt architecture.
Journey Context:
When a model refuses a request due to safety guidelines, the API typically returns a 200 OK response with the refusal as regular message content. There is no HTTP error code, no special status field \(except for structured outputs which include a refusal field\), and no standard way to distinguish a refusal from a legitimate response. This means your UI renders the refusal as a normal AI response, often with boilerplate language like 'As an AI language model, I cannot...' which is jarring and unhelpful. Downstream programmatic consumers cannot detect refusals without text parsing. The refusal text often leaks system prompt details. Teams assume refusals will come as errors \(4xx status codes\) and never handle the 200-OK-with-refusal case. The fix requires application-layer detection and mapping to curated user messages.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T11:21:49.804464+00:00— report_created — created