Is it me or everyone else? GPT api doesn't work any more

it always gives me this, and I follow the document it still doesn’t work.

APIRemovedInV1:

You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at GitHub - openai/openai-python: The official Python library for the OpenAI API for the API.

You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

Alternatively, you can pin your installation to the old version, e.g. pip install openai==0.28

A detailed migration guide is available here: v1.0.0 Migration Guide · openai/openai-python · Discussion #742 · GitHub

2 Likes

Same here, lloking for a solution ASAP

Same over here its working locally but after creating the docker image this error occurs, is there a solution yet?

I have the same error… found an answer yet?


image

do this guys, you need to strictly follow the guide GitHub - openai/openai-python: The official Python library for the OpenAI API

v1.0.0 Migration Guide · openai/openai-python · Discussion #742 · GitHub

1 Like

hi, i have it set as an env var for my app and still getting this error.

'''example completion with openai > 1.1'''
from openai import OpenAI
client = OpenAI()
prompt = "True or false: a banana is smaller than a lemon.\n\n"

response = client.completions.create(
    prompt=prompt,
    model="gpt-3.5-turbo-instruct",
    top_p=0.5, max_tokens=50,
    stream=True)
for part in response:
    print(part.choices[0].text or "")

False

1 Like

It worked for me, thanks. Wasn’t referencing the message object under response

You can alternatively run
openai migrate
This will automatically update all your existing old code.

1 Like

i am still having the same issue here , please assist me on how i should get rid of it, which file should i edit to troubleshoot this problem?

@will007

As this topic has a selected solution, can it be closed?

It worked for me. I had problems with using " * openai.Completion.create()client.completions.create()"

Thanks

That’s great to hear! The code snippet above, mind you, is for gpt-3.5-turbo-instruct, a special “completion” model that operates a bit differently than the “chat” you may be expecting.

Here’s getting a response from the chat gpt-3.5-turbo AI with the latest Python openai library:

from openai import OpenAI
client = OpenAI()
system = [{"role": "system", "content": "You are HappyBot."}]
chat_history = []  # past user and assistant turns for AI memory
user = [{"role": "user", "content": "Are you fully operational?"}]
chat_completion = client.chat.completions.create(
  messages = system + chat_history + user,
  model="gpt-3.5-turbo",
  max_tokens=25, top_p=0.9,
  )
print(chat_completion.choices[0].message.content)
1 Like