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

Shafeeq Niyas 40 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 Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,144 questions
0 comments No comments
{count} votes

Accepted answer
  1. Charlie Wei 1,895 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!

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful