Invalid URL error

openai.version=‘0.27.5’
openai.api_key = ‘sk…’ [not showing here but downloaded from website]
openai.api_base = ‘https://api.openai.com/v1/chat/completions
Trying to run
response = openai.ChatCompletion.create(
engine=“gpt-3.5-turbo”,
messages=[{“role”: “user”, “content”: “Does Azure OpenAI support customer managed keys?”}],
temperature=0,
)
response.choices[0].message[“content”]

With the above code, I am getting an error.
InvalidRequestError: Invalid URL (POST /v1/chat/completions/openai/deployments/gpt-3.5-turbo/chat/completions)

Not sure what’s wrong. I tried changing api_base to ‘https://api.openai.com/v1’ but still same issue

Hello @GreenEye
The endpoint you are using seems to be incorrect. Instead of https://api.openai.com/v1/chat/completions , you should use https://api.openai.com/v1/completions . Also, the engine should be set to "text-davinci-003" for GPT-3.5 Turbo models.

Try this:

import openai

openai.version = '0.27.5'
openai.api_key = 'YOUR_API_KEY'
openai.api_base = 'https://api.openai.com/v1'

response = openai.Completion.create(
    engine="text-davinci-003",
    prompt="Does Azure OpenAI support customer managed keys?",
    temperature=0
)

completion_text = response.choices[0].text.strip()

print(completion_text)