400 Error Requesting GPT-4o Assistants in v2 with API in v1 via Make

Within Make, an automation collects and organizes data which is then routed to various Assistants.

I created a new project and configured all the assistants within. Each assistant is on v2 - ChatGPT-4o, but the API key is still linked to v1. When the Make automation reaches that point of the flow, this message appears at the point of failure:

The operation failed with an error. [400] The requested model 'gpt-4o-2024-05-13' cannot be used with the Assistants API in v1. Follow the migration guide to upgrade to v2: / docs / assistants / migration

Using Terminal, I followed the various instructions, but I can’t seem to resolve this issue. My OpenAI API key is still showing as v1, which I believe could be the cause of the conflict.

Can anyone shed any light on this? Thanks in advance.

Did you try following the steps in the migration guide?

I did. My Assistant APIs are all on v2. However, I believe the issue is with the overarching API which is still show v1. I’m not sure. Here’s a quick look at the steps I took.

I launched Terminal and followed the steps, ultimately creating the openai_test.py file:

cd ~/Desktop

python3 openai_test.py

This should have executed the Python script, set the default headers to use the v2 version of the OpenAI API, make a request to the API using the gpt-4o model and the openai.beta.completions.create() method, and print the response.

I’ve uninstalled twice:
pip3 uninstall openai

Reinstalled two ways:

pip3 install --upgrade openai
pip3 install git+https://github.com/openai/openai-python.git

But… I’m still getting this:

AttributeError: ‘Beta’ object has no attribute ‘completions’

Where the heck did this fabrication come from?

Lesson: don’t trust an AI model produced in 2024 by OpenAI with your code.


The crux of the problem is: you must send the correct “v2” header to the API when making the request to the API, or you will be denied usage of the new model in Assistants.

Neither an assistant or an API key has any setting that indicates the API version within, it is all selected by network requests.

1 Like

That came directly from Terminal in response to running: openai_test.py:

import openai

openai.api_key = "YOUR_API_KEY"
openai.default_headers = {"OpenAI-Beta": "assistants=v2"}

response = openai.beta.completions.create(
    model="gpt-4o",
    prompt="Hello, how are you?"
)

print(response)

Please enlighten me with the proper code for my txt file. Ultimately, I am trying to resolve my automations within Make.

The site is not sending the headers required. If you cannot update the OpenAI libraries or code being used, there is nothing you can do to fix this, apart from writing a complete request yourself with network requests that can pass headers.

Assistants, the only place where one would need the header, does not have a “completion” method. There is a multi-step procedure for creating resources and running a job.

https://platform.openai.com/docs/assistants/overview

Very well then. I will take it up with Make to see if they’ll push the necessary headers. Thank you for your time.

I would really appreciate it if you could update me on whether and how it was fixed. I’m having the same problem.

I’ve just got this error too.

Maybe try this piece of code.

def call_chat_client(prompt):
        completion = client.chat.completions.create(
            model="gpt-4o",
            messages=[
                {"role": "system", "content": "You are a helpful assistant."},
                {"role": "user", "content": prompt}
            ],
            max_tokens=50,
        )
        return completion.choices[0].message.content

Also,
pip show openai will show you the version of openAI is being used as below.

Name: openai
Version: 1.30.1
Summary: The official Python library for the openai API
Home-page:
Author:
Author-email: OpenAI support@openai.com
License:

pip install --upgrade openai shall upgrade to the latest version.

Happy to help.