AttributeError: module 'openai' has no attribute 'Thread'

Hey everyone. I’ve been trying to run a python script with assistants, but I constantly get this error ‘AttributeError: module ‘openai’ has no attribute ‘Thread’’. I’ve checked multiple times my python is up to date, and the openai module. I’ve tried on multiple different machines, playgrounds, VS, Idle, everything. It’s driving me insane. Does anyone know what would be causing it?

1 Like

Any other file or directory named “openai” in the directory or path, including the script you write, can override the python installation’s library.

Then it seems you are using an uppercase call for an object instance or doing something odd with the code of yours that doesn’t work.

Bouncing over to “API Reference”:

from openai import OpenAI
client = OpenAI()

empty_thread = client.beta.threads.create()
1 Like

Please share the stack dump. Usually it looks something like this:

/usr/local/lib/python3.10/site-packages/langchain/embeddings/ in _get_len_safe_embeddings
    response = embed_with_retry(
/usr/local/lib/python3.10/site-packages/langchain/embeddings/ in embed_with_retry
    retry_decorator = _create_retry_decorator(embeddings)
/usr/local/lib/python3.10/site-packages/langchain/embeddings/ in _create_retry_decorator
E   AttributeError: module 'openai' has no attribute 'error'