There is no available documentation for the Assistants V2 API

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 :slight_smile:

image

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?

  1. upgrade the openai library, because it validates and denies unknown parameters
  2. 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)

The image becomes part of a list instead of string that you send as your content: