Skip to content

Error "Your request contains invalid content filter policy. Please provide a valid policy." calling AzureOpenAI.GenerateChatCompletion #6660

@Doriano-Ponzo-EOS

Description

@Doriano-Ponzo-EOS

Title

Error "Your request contains invalid content filter policy" when calling AzureOpenAI.GenerateChatCompletion with standard policy in Azure AI Foundry

Describe the bug

When calling AzureOpenAI.GenerateChatCompletion from AL using Azure AI Foundry, the request fails if a standard or default content filter policy is applied.

The following error is returned:

Your request contains invalid content filter policy. Please provide a valid policy.

This happens even when using the default / standard policy (for example Microsoft.DefaultV2) or when setting the policy parameters manually.

If the policy is explicitly set to empty, the same request succeeds and the chat completion is generated correctly.

This suggests that Business Central / AL currently sends an invalid or incompatible policy identifier to Azure AI Foundry.

Steps to reproduce

  1. Configure Azure OpenAI via Azure AI Foundry
  2. Call AzureOpenAI.GenerateChatCompletion from AL
  3. Apply a standard / default content filter policy
  4. Execute the request

Expected behavior

Chat completion should work with standard or default content filter policies, without requiring the policy to be cleared.

Actual behavior

The request fails unless the content filter policy is explicitly set to an empty value.

Code example / workaround

// We set empty policy. Custom policies are not managed!
// Policy "Microsoft.DefaultV2" returns error
// "Your request contains invalid content filter policy. Please provide a valid policy."

PolicyParams := ChatCompletionParams.GetAOAIPolicyParams();
PolicyParams.SetCustomAOAIPolicy('');
ChatCompletionParams.SetAOAIPolicyParams(PolicyParams);

AzureOpenAI.GenerateChatCompletion(ChatMessages, ChatCompletionParams, OperationResponse);
if not OperationResponse.IsSuccess() then
    Error(OperationResponse.GetError());

Additional context

  • The issue occurs when using Azure AI Foundry
  • The same request succeeds once the policy is cleared
  • This looks like a mismatch between Business Central policy handling and Foundry-supported policies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions