Assistance Needed with OpenAI Assistant ID Not Being Recognized

Hello,

I’m working on integrating the OpenAI Assistants API into my chatbot, and I’ve run into a problem. Despite ensuring that both my API key and Assistant ID are correct, I’m getting a NotFoundError that indicates the Assistant ID does not exist.

Here’s the error message I’m receiving:
NotFoundError: Error code: 404 - {'error': {'message': 'The model asst_XXXXXXXX does not exist', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

I’ve double-checked the Assistant ID and API key, and everything seems to be in order. Has anyone else encountered this issue? Any guidance on how to resolve this would be greatly appreciated.

Thanks in advance for your help!

Did you try List Assistant to see which one you have access to?

( https://platform.openai.com/docs/api-reference/assistants/listAssistants )

https://api.openai.com/v1/assistants

3 Likes

+1 to @jlvanhulst 's suggestion, you should check and make sure you have access to the assistant via the same API key you are trying to query it with.

3 Likes

This was the response I reseived.
The ID is the same I am using in my code.


{
  "object": "list",
  "data": [
    {
      "id": "asst_XXXX",
      "object": "assistant",
      "created_at": 1702777176,
      "name": "BLablablabla",
      "description": null,
      "model": "gpt-4-1106-preview",
      "instructions": "XXXX",
      "tools": [
        {
          "type": "retrieval"
        }
      ],
      "file_ids": [
        "file-XXXX"
      ],
      "metadata": {}
    }
  ],
  "first_id": "asst_XXXX",
  "last_id": "asst_XXX",
  "has_more": false
}

Welcome to the dev forum @felipestoker

Can you share the code that’s running the thread on the assistant.

I find this interesting. Are you passing the assistant ID as model?

2 Likes

Yes, the code is here.

import openai

openai.api_key = "APIKEY"

def chatbot_my(conversation_history, assistant_id):
    response = openai.chat.completions.create(
        model=assistant_id,
        messages=conversation_history
    )
    return response.choices[0].message.content.strip()

if __name__ == "__main__":
    assistant_id = "MYID"
    conversation_history = []

    while True:
        user_input = input("Você: ")
        if user_input.lower() in ["quit", "exit"]:
            break

        conversation_history.append({"role": "user", "content": user_input})
        chatbot_response = chatbot_my(conversation_history, assistant_id)
        conversation_history.append({"role": "assistant", "content": chatbot_response})

        print("Chatbot:", chatbot_response)

1 Like

That’s precisely the reason why you’re facing the error.

Here’s the docs on how to use assistants API.

Alternatively, you can use models on the ChatCompletions endpoint.

1 Like