Search code examples
azureazure-cognitive-servicesazure-openai

How can I validate the Azure Open AI model deployment configuration parameters (the <endpoint, key, deployment name> triple)?


I have Azure Open AI endpoint, api key and deployment name.

How can I test they are valid?

As I understand it, the simplest is invoke the Get Deployment REST API. But then again, this rest API does not exercise the Open AI endpoint, so it does not help.

So how can one validate the Azure Open AI configuration triplet - <endpoint, api key, deployment name> ?

EDIT 1

The purpose of this validation is kind of an extended health url. It would be a dedicated endpoint on the service which we can hit to check if the service has good connection to the Open AI service.

I do not think we can let it have elevated access to the Azure resources. It has to manage with the Open AI config triplet - <endpoint, key, deployment name>.

Right now I am doing this:

[HttpGet]
[Route("/healthz/openai")]
public async Task<ActionResult> OpenAIAsync()
{
    var config = m_configuration.GetSection(nameof(AzureOpenAIServiceConfig)).Get<AzureOpenAIServiceConfig>();

    var client = new OpenAIClient(new Uri(config.OpenAIResourceEndpoint), new AzureKeyCredential(config.OpenAIResourceKey));

    var completionsOptions = new ChatCompletionsOptions()
    {
        Messages = { new ChatMessage(ChatRole.Assistant, "When was Microsoft founded?") },
    };

    var completionsResponse = await client.GetChatCompletionsAsync(config.OpenAIDeploymentName, completionsOptions);
    return Ok(completionsResponse.Value.Choices[0].Message.Content);
}

And as Nicolas R has correctly noticed it is far from ideal, because it assumes the nature of the model deployment.


Solution

  • There are several options:

    • calling the deployed models directly, but here it will depend on the model type: making a call to an embedding model vs a DALL-E model vs a GPT model is not the same payload

    • doing it in several steps by using the management APIs: one to check the validity of the endpoint + deployment name by calling the "Deployments - Get" API you mentioned, and checking the "Account - List keys" API to check the API key. For those 2 calls, you will need to permissions on the Azure OpenAI resource