Gpt-35-turbo 0301 and 2023-09-15-preview support client.chat.completions.create

Shafeeq Niyas 60 Reputation points
2024-03-12T18:41:45.3366667+00:00

i am using Gpt-35-turbo 0301 and 2023-09-15-preview in azure open ai ,When I try to connect using this code, I get a message that the API isn't supported

import openai

# Set your Azure OpenAI credentials
client = OpenAI(api_key = "", base_url="h/")


# Now you can make calls to the OpenAI API using these credentials
response = client.chat.completions.create(
  model="gpt-35-turbo",
  messages=[
    {
      "role": "system",
      "content": "Given the following SQL tables, your job is to write queries given a user’s request."
    },
    {
      "role": "user",
      "content": "Write a SQL query which computes the average total order value for all orders on 2023-04-01."
    }
  ],
  temperature=0.7,
  max_tokens=64,
  top_p=1
)


Azure OpenAI in Foundry Models
0 comments No comments

Answer accepted by question author
Charlie Wei 3,335 Reputation points
2024-03-13T02:23:33.05+00:00

Hello Shafeeq Niyas,

I believe you are currently utilizing OpenAI rather than Azure OpenAI. Please consider modifying the initial part of the code as follows. Additionally, it is advisable to consult the Quickstart provided.

import os
from openai import AzureOpenAI

client = AzureOpenAI(
  azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"), 
  api_key=os.getenv("AZURE_OPENAI_API_KEY"),  
  api_version="YOUR_API_VERSION"
)

Best regards,
Charlie


If you find my response helpful, please consider accepting this answer and voting 'yes' to support the community. Thank you!

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.