The current API Reference documentation for Assistants https://platform.openai.com/docs/api-reference/assistants is still for the V1 api. I need to know how the Messages API call has changed to allow a vector_store and files to be attached to a message in a thread. Specifically using the client.beta.threads.messages.create() function.
Perhaps check the file search documentation.
https://platform.openai.com/docs/assistants/tools/file-search
That is what I have been using. However it does not cover all the details like the API Reference documentation does. I was able to figure out my issue by trial and error just guessing based on how other things were shown in the file search documentation but it would still help to have details of the different SDK objects. Maybe they are waiting until it is more stable so they donāt have to do it more than once.
Facing a similar issue, would appreciate if you could share your finding - Iām sure it would be helpful to others as well ![]()

one just needs to expand properties several timesā¦
https://platform.openai.com/docs/api-reference/messages/createMessage
Here is what I did to get a file attached to a thread using the Messages object
file = client.files.create(file=open(file_path,ārbā),purpose=āassistantsā)
message = client.beta.threads.messages.create(thread_id=thread_id,role=āuserā,content=message_str,
attachments=[{ āfile_idā: file.id, ātoolsā: [{ātypeā: āfile_searchā}] }],
)
Thanks for sharing! For some reasong it doesnāt work for me. I pasted your code:
from openai import OpenAI
client = OpenAI(default_headers={"OpenAI-Beta": "assistants=v2"})
thread = client.beta.threads.create()
message = client.beta.threads.messages.create(thread_id=thread_id, role= "user" ,content=question,
attachments=[{ "file_id": "file-ADrHgfzr4oM4mV345ubP1Y8N", "tools": [{"type": "file_search"}] }])
and get this:
An error occurred: Messages.create() got an unexpected keyword argument āattachmentsā
Any further ideas?
- upgrade the openai library, because it validates and denies unknown parameters
- upgrade your programming to a non-openai library (and not assistants), so you have the portability of escaping this ecosystem.
For this thread topic: The API reference is now only beta v2 in the main assistants section. The latest official SDKs use it without asking. You must pass a header each call with the version; you donāt āsetā an assistant.
Make it work first without vision. Then:
Please share some python script that submits the image file_id and a text request in the message? Iām having a hard time getting that to workā¦.
See what Iāve come up with som far, version 500ā¦..
Create a new thread
thread = client.beta.threads.create()
file_id = āfile-7G9PFbPKImzPYtVNNSkfRDYJā
file = client.files.create(file=open(image_path,ārbā),purpose=āassistantsā)
Create a message with the correct attachment object format
message = client.beta.threads.messages.create(
thread_id=thread.id,
role=āuserā,
content=ā29.651634, -82.324829, Mayā,
attachments=[{āfile_idā: file.id, ātoolsā: [{ātypeā: āfile_searchā}] }]
)
Run the assistant
run = client.beta.threads.runs.create_and_poll(
thread_id=thread.id,
assistant_id=āasst_oGB3fY342s3h4xupTd3bRY8Zā
)
#print(run)
