Formerly known as Azure AI Services or Azure Cognitive Services is a unified collection of prebuilt AI capabilities within the Microsoft Foundry platform
Hi Michael Vivet ,
Thank you for reaching out on Microsoft Q&A.
You can fix the Unauthorized error by using the models inference endpoint instead of the project URI and authenticating correctly. Use:
// Using project API key
var endpoint = new Uri("https://<resource>.services.ai.azure.com/models");
services.AddAzureAIInferenceChatCompletion("gpt-4.1", apiKey: "<PROJECT_API_KEY>", endpoint: endpoint);
// Or using Entra ID token
var endpoint = new Uri("https://<resource>.services.ai.azure.com/models");
services.AddAzureAIInferenceChatCompletion("gpt-4.1", credential: new DefaultAzureCredential(), endpoint: endpoint);
References:
SK AddAzureAIInferenceChatCompletion
I hope this helps! If the information is useful, please accept the answer and upvote so it can assist other community members as well.