Issue Accessing Custom Assistants via OpenAI API

I’m trying to interact with my custom assistants created through the OpenAI platform using their unique identifiers in API requests. However, I consistently receive a 404 error indicating that the assistant’s model does not exist.

Verifications Made:

  • Confirmed that the API keys are correct and have the necessary permissions.
  • Checked the presence of the assistants in my OpenAI workspace.
  • Included the Organization ID in the API requests.
  • Successfully tested with standard and fine-tuned models via the API, indicating that the base configuration and authentication are correct.

Debugging Steps:

  • Used the assistant’s identifier in the Python script to interact via the API.
  • Updated the script according to the latest version of the OpenAI API (1.3.4).
  • Received a 404 error despite the assistants’ identifiers being correctly listed in my OpenAI interface.

Here is the script I am using:

pythonCopy code

# Configuration of the API keys and the organization ID
API_KEY = 'sk-duTcDpp0v***************Zd4OwgipZm8s'
OPENAI_ENGINE = 'asst_eskDg5R***********AEPGds8I'
OPENAI_ORGANIZATION_ID = 'org-pCqrL5A***********DsVNsnhSFU'

# Initialization of the OpenAI client with the organization ID
client = OpenAI(api_key=API_KEY, organization=OPENAI_ORGANIZATION_ID)

# Definition of the question
question = "What's the weather like today?"

try:
    # Sending the question to the assistant and receiving the response
    response = client.completions.create(
        model=OPENAI_ENGINE,
        prompt=question,
        max_tokens=50
    )

    # Displaying the response
    print("Assistant's response:", response.choices[0].text.strip())
except Exception as e:
    print("An error occurred while communicating with the OpenAI API.")
    print(e)

Okay, I’m a beginner, but I think it’s pretty obvious, so I don’t think I need to mention it… :slightly_smiling_face:
Any help or insight into this issue would be greatly appreciated. I’ve been unable to determine why I’m encountering this error despite following all the recommended steps and configurations.

Thank you!

The problem is you are using Completions API code. You should be using Assistants API code.

1 Like