Assistant API setup: "ImportError: cannot import name 'OpenAI' from 'openai' "


I am trying to set up a python script and create/ access an assistant.

But I am failing to get the script run at all…

I get the error message: from openai import OpenAI
ImportError: cannot import name ‘OpenAI’ from ‘openai’

OpenAI version

 pip show openai
Name: openai
Version: 1.2.3

My script so far looks like this:

import os
import openai
from openai import OpenAI
openai.api_key = os.getenv("OPENAI_API_KEY")
client = OpenAI()

my_assistant = client.beta.assistants.create(
    instructions="You are a personal math tutor. When asked a question, write and run Python code to answer the question.",
    name="Math Tutor",
    tools=[{"type": "code_interpreter"}],

thread = client.beta.threads.create()

message = client.beta.threads.messages.create(
    thread_id =,
    role = "user",
    content = "Help me devide 10 by pi"

run = client.beta.threads.runs.create(
    thread_id =,
    assistant_id =,
    instruction = "Please helpt the user."

import time
run_status =
    thread_id =,
    run_id =
type or paste code here

Any ideas?

downgrading python to 3.10 wasa helping for me…