How to Fetch Azure OpenAI api_version and engine Dynamically After Resource Creation via Python?

Sudheer2
New Contributor III

Hello,

I am using Python to automate the creation of Azure OpenAI resources via the Azure Management API. I am successfully able to create the resource, but I need to dynamically fetch the following details after the resource is created:

  1. API Version (api_version)
  2. Engine (such as text-davinci-003, gpt-3.5-turbo, etc.)

Here are the steps I have taken so far:

  1. Created Resource: I use the Azure Management API to create the OpenAI resource (PUT request).
  2. Fetch API Keys: After the resource is created, I fetch the API keys by calling listKeys.

However, when the resource is created, I am unable to dynamically retrieve the API version and engine directly from the resource.

Problem:

  • The api_version returned is showing as Unknown even though I know there is a specific version associated with the OpenAI resource.
  • I am unable to retrieve the engine types dynamically (like text-davinci-003, gpt-3.5-turbo, etc.) after the resource creation.

What I’ve Tried:

  • I tried using the exportTemplate API, but it only gives me a template and not the specific api_version and engine I need.
  • I also tried checking the resource properties, but the api_version field remains Unknown.
  • I even tried making an API call to https://<resource_name>.openai.azure.com/v1/engines, but I receive DNS resolution issues.

My Goal:

I would like to automate the process of retrieving the API version and engine dynamically after the resource is created, using Python and Azure API.

Is there a way to retrieve this information directly after the resource creation or via a different API endpoint?

Any help or guidance would be greatly appreciated!

Thank you!