Search code examples
pythongpt-3chatgpt-api

Invalid URL (POST /v1/chat/completions) error in Python


I have a tts Python program that interprets speech-to-text data, and after that it asks this prompt to the GPT davinci-003 API and answers back, but I just switched to GPT 3.5 turbo, and it doesn't work because of the Invalid URL (POST /v1/chat/completions) error.

I tried checking the model endpoint compatibility web page and also tried asking GPT-3 and GPT-4. I didn’t get any answer.

I checked Reddit as well, but I didn’t find anything. Also, I checked Stack Overflow, but I didn’t find anything either.

This is the API endpoint URL or at least the one I tried.

Enter image description here

My current GPT-3.5 turbo engine code:

Enter image description here


Solution

  • Using engines is deprecated. Use model instead.

    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=messages,
        max_tokens=1000,
        n=1,
        temperature=0.3,
    )