# Assistant example not working

**URL:** <https://community.openai.com/t/assistant-example-not-working/766532>\
**Category:** API\
**Tags:** api\
**Created:** [May 20, 2024, 9:18am UTC](https://community.openai.com/t/assistant-example-not-working/766532 "2024-05-20T09:18:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![af2](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@af2](https://community.openai.com/u/af2)\
**Post date:** [May 20, 2024, 9:18am UTC](https://community.openai.com/t/assistant-example-not-working/766532/1 "2024-05-20T09:18:39Z")

</div>

Hi, Im trying out the example from OpenAI documentation but I am getting failed only. Here is the code I am using:

```auto
import os
from openai import OpenAI
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())

client = OpenAI(
    api_key = os.getenv("OPENAI_API_KEY"),
)
  
assistant = client.beta.assistants.create(
  name="Math Tutor",
  instructions="You are a personal math tutor. Write and run code to answer math questions.",
  tools=[{"type": "code_interpreter"}],
  model="gpt-3.5-turbo-0125",
)

thread = client.beta.threads.create()

message = client.beta.threads.messages.create(
  thread_id=thread.id,
  role="user",
  content="I need to solve the equation `3x + 11 = 14`. Can you help me?"
)

run = client.beta.threads.runs.create_and_poll(
  thread_id=thread.id,
  assistant_id=assistant.id,
  instructions="Please address the user as Jane Doe. The user has a premium account."
)

# Wait for the run to complete and get the response
while run.status not in ["completed", "failed"]:
    run = client.beta.threads.runs.retrieve(
        thread_id=thread.id,
        run_id=run.id
    )

# If the run completed successfully, get the latest messages
if run.status == "completed":
    messages = client.beta.threads.messages.list(
        thread_id=thread.id
    )
    print(messages)
if run.status == "failed":
    print("F")

```

---

<div class="post-metadata">

**Author:** ![MrFriday](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/mrfriday/32/350887_2.png) [@MrFriday](https://community.openai.com/u/MrFriday)\
**Post date:** [May 20, 2024, 11:34am UTC](https://community.openai.com/t/assistant-example-not-working/766532/2 "2024-05-20T11:34:20Z")

</div>

Hey Welcome to the Community. Do you see any errors? Provide little more details on the issue you’re facing.
