Skip to main content
⚠️ 400 Bad Request Azure OpenAI / Microsoft Foundry .NET 10 ✓ Verified Oct 2026

Fix: Azure OpenAI 400 Output Blocked by Content Filtering Policy

Fix Azure OpenAI 400 content_filter error in C#. Catch ClientResultException, parse category severity scores, and handle silent streaming stops.

Raw Error Payload / Console String
{
  "error": {
    "message": "The response was filtered due to the prompt triggering Azure OpenAI's content management policy.",
    "type": "invalid_request_error",
    "param": "prompt",
    "code": "content_filter",
    "innererror": {
      "code": "ResponsibleAIPolicyViolation",
      "content_filter_result": {
        "hate": { "filtered": false, "severity": "safe" },
        "violence": { "filtered": true, "severity": "medium" }
      }
    }
  }
}

Trigger Scenario

User prompt or generated completion exceeds configured safety severity thresholds (hate, violence, sexual, self-harm) in Microsoft Foundry.

Root Cause

Azure OpenAI content filter evaluated the request against safety policies and blocked execution. In streaming calls, Semantic Kernel may cancel silently without throwing.

Step-by-Step Resolution

1
Catch ClientResultException Catch ClientResultException from Azure.Core and inspect Status == 400.
2
Parse inner error severity JSON Parse ex.GetRawResponse()?.Content.ToString() to determine the filtered category.
3
Check FinishReason on streaming chunks In streaming loops, check chunk.FinishReason == ChatFinishReason.ContentFilter.
Verified C# (.NET 10) Solution Code
try
{
    var response = await chatClient.CompleteChatAsync(userPrompt);
}
catch (ClientResultException ex) when (ex.Status == 400)
{
    var raw = ex.GetRawResponse()?.Content.ToString();
    if (raw?.Contains("content_filter") == true)
    {
        Console.WriteLine("Content filtered by policy. Returning safe default response.");
    }
}
Comprehensive Engineering Guide

Fix Azure OpenAI 400 content_filter Error in C# (.NET)

Read Full Deep Dive