I get an error saying file_ids is an unexpected keyword when I try to upload a file in a message using the python openai package. I created a chatgpt-4o thread and I'm trying to upload the file in a message. Here's the code I use:
# Create a message with the uploaded file
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="Here is the HTML content for the seminar page.",
file_ids=[file.id] # Use the file ID here
)
Trying to run this I get the error
An error occurred: Messages.create() got an unexpected keyword argument 'file_ids'
I followed instructions from the API guide, and they are consistent with what chatgpt himself suggested. I also reinstalled the latest version of the OpenAI package. Any ideas?
EDIT: I now can't find the reference to file_ids in the api guide, maybe it was just chatgpt that insisted on this
Following a comment by @furas, I changed the code to use the attachments keyword instead of file_ids, and now it works. Here's the corrected code:
# Create a new assistant
assistant = client.beta.assistants.create(
name="Seminar HTML to CSV Assistant",
instructions=instructions,
model="gpt-4",
tools=[{"type": "code_interpreter"}],
)
# Create a thread
thread = client.beta.threads.create()
# Create a message with the uploaded file
message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content="Here is the HTML content for the seminar page.",
attachments=[{"file_id": file.id, "tools": [{"type": "code_interpreter"}]}]
)
# Run the assistant
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id
)