Can someone explain how to attach files to assistants in V2 using API?

I understand how to attach files to assistants in V1 by getting the assistant ID then attaching the file ID but Im really lost on how to upload the files to the assistant in V2. Im a complete beginner and don’t know how to code I’m learning as I go so simple explanations are appreciated! Or if anyone has a good rec for a youtube video

v1 had a knowledge feature called “retrieval”.

v2 is now “file search”.

While you still upload files to storage, the difference is that file IDs are not directly connected to an assistant or attached. The intermediate step is adding the file ID to a new mechanism called vector store.

Vector store extracts the document text, splits it into chunks, and then performs OpenAI embeddings on the chunks. This prepares them for a similarity search the AI can do.

Then the vector store must be attached to an assistant to enable the file search for that assistant, or to multiple assistants.

There are also message attachment methods that will create temporary vector stores for a thread.

With that overview, diving into documentation should be more straightforward.

The API reference has how you must actually send those API requests.

1 Like

Thanks. So, I did set it up correctly. The issue I was having was I didn’t realize you could only attach one vector store per assistant. Thus the way it is set up now on my site is that I add files to a vector store and then attach a vector store when creating the assistant. Does it make more sense to upload files and create a vector store at the same time as creating an assistant or have it done separately? I would like to keep it separate if it is likely that we will be allowed to attach more than one vector store in the future. Also just to be clear, it is not possible to add files to a vector store or an assistant by using file ids right?

An assistant can be modified, to have its vector store added or removed.

Files can be added or removed from a vector store.

If you have a plan already, the chronological way to avoid the messing about is to upload files, create the vector store that fits the assistants purpose, and create the assistants with the vector store ID as one of the parameters sent to API.

You should ensure clear scoping - a vector store for assistants that could be used across any users, and if you allow user file uploads, a clear delineation of thread vector store that is specific to that user.

All vector stores are combined into the one tool the AI uses. It can’t tell the difference between its “programming” knowledge and a user’s attempts at “programming” by upload, so it is good practice (not mentioned by OpenAI) to allow only one type of use.

1 Like