Hi @Ravi K
Welcome to Microsoft Q&A! Thanks for posting the question.
If you are using openai version > 0.28.1 then you need to change your python code like below to call a gpt-35-turbo or gpt-4 model
import os
from openai import AzureOpenAI
client = AzureOpenAI(
api_key = os.getenv("AZURE_OPENAI_KEY"),
api_version = "2023-05-15",
azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
)
response = client.chat.completions.create(
model="mygpt4", # model = "deployment_name".
messages=[
{"role": "system", "content": "Assistant is a large language model trained by OpenAI."},
{"role": "user", "content": "Who were the founders of Microsoft?"}
]
)
#print(response)
print(response.model_dump_json(indent=2))
print(response.choices[0].message.content)
Please refer to the documentation for details.
Please let me know if you have any other questions.
Please 'Accept as answer' and Upvote if it helped so that it can help others in the community looking for help on similar topics.