Getting API error while running a project. details mentioned

Hello Everyone,

I am building an AI AGENT where my bot can generate a twitter thread for any blockchain based project say ETHEREUM but the error I am getting is this.

Error generating thread: 

You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python 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`

I am using this model and method:

 response = openai.ChatCompletion.create(
    model="gpt-4o-mini",  # Ensure "gpt-4o-mini" is a valid model
    messages=[
        {"role": "system", "content": "You are a professional crypto analyst who writes engaging Twitter threads."},
        {"role": "user", "content": prompt}
    ],
    max_tokens=500,
    temperature=0.7
)

Can someone help? I credited $5 to ensure I have access to all latest models but the issue is still same.

I am using latest version of openAI

Used this

!pip install openai --upgrade

Thanks

Hi @airdropsarjun and welcome to the community.

This is how you create a chat completions call nowadays:

completion = client.chat.completions.create(
  model="gpt-4o-mini",
  messages=[
    {"role": "developer", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ]
)

See here for reference documentation.