[Python] Using openai python api to upload a file to a chatgpt assistant

Discussão em 'Python' iniciado por Stack, Junho 2, 2025.

  1. Stack

    Stack Membro Participativo

    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?

    Continue reading...

Compartilhe esta Página