V2 API Retrieving Message from Existing Assistant

Trying currently to retrieve an Assistant V2 message but currently cannot get assistant messages at all. Have tried a couple of options but cannot figure out how to finish this code. Python3

import os
import openai
from dotenv import load_dotenv

# Load environment variables from .env file

# Set API key
openai.api_key = os.getenv('OPENAI_API_KEY')

# Retrieve the assistant ID from environment variables
assistant_id = os.getenv('ASSISTANT_ID')

# Retrieve the assistant
my_assistant = openai.beta.assistants.retrieve(assistant_id)
print(f"This is the assistant object: {my_assistant.id} \n")

# Create a thread
my_thread = openai.beta.threads.create()
print(f"This is the thread object: {my_thread.id} \n")

# Add a message to the thread
my_thread_message = openai.beta.threads.messages.create(
print(f"This is the message object: {my_thread_message} \n")

# Run the assistant
my_run = openai.beta.threads.runs.create(
print(f"This is the run object: {my_run} \n")

my_run = client.beta.threads.runs.retrieve(

You didn’t include the status of your run, i.e., my_run.status?
I’d recommend temporarily using an alternative to initiating your run (for comparison) by using the create and poll method. See the overview example starting at step 4 and without streaming

1 Like

Thanks so much. The poll method definitely worked.

I will now test out streaming.