Linking file to an assistant

Hi guys,

I am having a little issue here with my nodejs project: users on my app each have one assistant to which they should be able to add files with instructions.

I can upload the file, but then I am struggling to link it to the assistant. Here is the code:

const file = await openai.files.create({
        file: fs.createReadStream(filePath),
        purpose: "assistants",
    console.log(' : ' +;
    try {
        await openai.beta.assistants.files.create(assistantId, {
    catch (error) {

And the error message i get :

TypeError: Cannot read properties of undefined (reading 'create')

Any solution?

Thank you!

@lemontec - You should pass it under tool_resources according to the docs:

Attaching files to thread-


assistant = client.beta.assistants.create(
  instructions="You are a personal math tutor. When asked a math question, write and run code to answer the question.",
  tools=[{"type": "code_interpreter"}],
    "code_interpreter": {
      "file_ids": []

Hope this helps, Cheers!


Ok I will check that, thank you!

For reference I actually used vector stores that seems to be much better.
The process was:

  • create a vector,
  • create an assistant with file search tool and the vector id
  • upload files
  • add uploaded files ids to the vector
1 Like