Azure OpenAI Assistant. How to programatically attach PDFs (or other MIME types) to a thread using TS/JS?

GenixPRO 116 Reputation points
2025-01-07T06:14:34.7133333+00:00

Hi Team,

  1. We're trying, without success, to programatically upload an attachment (PDF) to a thread for an Assistant created on gpt 4o. Can PDFs be uploaded as attachment? If yes, how? Can you pls. share any quickstart guide for this.
  2. If/when an attachment is uploaded (e.g. image), how do we display that in a thread? Doe we need to call some file-id using the assistant?
  3. Are we first supposed to upload the file to a vector store -> get it's ID -> then ask Assistant to refer to this file in answering any related queries? If yes, pls. share any references on uploading files to vector store.

Thanks.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,092 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AshokPeddakotla-MSFT 35,971 Reputation points Moderator
    2025-01-07T09:27:45.2933333+00:00

    GenixPRO Greetings!

    Please see below response.

    We're trying, without success, to programatically upload an attachment (PDF) to a thread for an Assistant created on gpt 4o. Can PDFs be uploaded as attachment? If yes, how? Can you pls. share any quickstart guide for this.

    AFAIK, Files can be uploaded via Studio, or programmatically. The file_ids parameter is required to give tools like code_interpreter access to files. When using the File upload endpoint, you must have the purpose set to assistants to be used with the Assistants API.

    Did you consider using REST API? Also, see the similar ask and check if that helps.

    If/when an attachment is uploaded (e.g. image), how do we display that in a thread? Doe we need to call some file-id using the assistant?

    See this https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/assistant#retrieve-file-id

    Are we first supposed to upload the file to a vector store -> get it's ID -> then ask Assistant to refer to this file in answering any related queries? If yes, pls. share any references on uploading files to vector store

    The file search tool uses the vector store object. Upload your files and create a vector store to contain them. Once the vector store is created, you should poll its status until all files are out of the in_progress state to ensure that all content has finished processing.

    See Azure OpenAI Assistants file search tool (Preview) for details.

    Do let me know if you have any further queries.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.