Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I select the proper openai.api_version?

I read on https://learn.microsoft.com/en-us/azure/cognitive-services/openai/how-to/chatgpt?pivots=programming-language-chat-completions:

openai.api_version = "2023-05-15" 

and on https://learn.microsoft.com/en-us/answers/questions/1193969/how-to-integrate-tiktoken-library-with-azure-opena:

openai.api_version = "2023-03-15-preview" 

This makes me wonder: How can I select the proper openai.api_version? Does that depend on my Azure OpenAI instance or deployed models or which features I use in my Python code? Or something else?

I couldn't find the info in my deployed models:

enter image description here

like image 600
Franck Dernoncourt Avatar asked Nov 22 '25 23:11

Franck Dernoncourt


2 Answers

The API Version property depends on the method you are calling in the API: all methods are not supported in all API versions.

Details are listed here: https://learn.microsoft.com/en-US/azure/cognitive-services/openai/reference

And preview API lifecycle is described here: https://learn.microsoft.com/en-us/azure/ai-services/openai/api-version-deprecation => check those pages for up-to-date references

As of March 7th, 2024: Example: "completions" endpoint is available in the following versions (ordered by date):

  • 2024-02-15-preview
  • 2023-12-01-preview (retiring April 2, 2024)
  • 2023-09-01-preview (retiring April 2, 2024)
  • 2023-08-01-preview (retiring April 2, 2024)
  • 2023-07-01-preview (retiring April 2, 2024)
  • 2023-06-01-preview (still supported, due to DALL-E 2)
  • 2023-05-15
  • 2023-03-15-preview (retiring April 2, 2024)
  • 2022-12-01

But "chat completions" endpoint is available only in the following versions (ordered by date):

  • 2024-02-15-preview
  • 2023-12-01-preview (retiring April 2, 2024)
  • 2023-09-01-preview (retiring April 2, 2024)
  • 2023-08-01-preview (retiring April 2, 2024)
  • 2023-07-01-preview (retiring April 2, 2024)
  • 2023-06-01-preview (still supported, due to DALL-E 2)
  • 2023-05-15
  • 2023-03-15-preview (retiring April 2, 2024) Because basically it was not offered in the initial API.

Generally, use the latest "not preview" version for production when possible, as the preview versions might be retired on a more frequent basis.

like image 158
Nicolas R Avatar answered Nov 24 '25 15:11

Nicolas R


As a complement to Nicolas R's answer: the API version property also depends on the model you are calling in the API. For example:

Support for the o1 series models was added in API version 2024-09-01-preview.

Note that, confusingly, if one tries to use an API version that doesn't exist (e.g., 2024-09-01-previewwww), one gets this error message:

openai.NotFoundError: Error code: 404 - {'error': {'code': '404', 'message': 'Resource not found'}}

like image 33
Franck Dernoncourt Avatar answered Nov 24 '25 13:11

Franck Dernoncourt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!