How to access files generated by AI Assistants (Assistants API)?

GenixPRO 116 Reputation points
2025-05-23T05:14:00.14+00:00

Hi.

  1. Our mobile app deploys assistants (create once in AI Foundry, then use assistant_id to create thread for each user @ runtime) to generate a variety of plans (PDFs) or images.
  2. These files are being generated and saved in Data files sandbox: /mnt/data/<filename>
  3. How do we retrieve these files from Data files using File ID? How do we access Data files location? When user requests access path or link to generated file, assistant replies with a sandbox location. However that's not a fully qualified URL that user can access publicly.
  4. Solution: We may retrieve the file based on File ID and purpose = "assistant_output" -> save to a public URL and share the URL back with user to access. Would that be considered a better approach to render any type of file display?
  5. Is there an easier way to access file directly from Data files (storage) and render in-app?

Appreciate help.

Thanks.

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
3,629 questions
0 comments No comments
{count} votes

Accepted answer
  1. kothapally Snigdha 3,020 Reputation points Microsoft External Staff Moderator
    2025-05-26T05:24:42.62+00:00

    Hi @GenixPRO

    I understand that you are encountering an issue with accessing the files via the assistant API. Here are some potential solutions. To retrieve files saved in your Data files sandbox, you can utilize the files. Content endpoint.

    
    from openai import AzureOpenAI
    
    client = AzureOpenAI(
        api_key=os.getenv("AZURE_OPENAI_API_KEY"),
        api_version="2024-05-01-preview",
        azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT")
    )
    
    # Replace 'your_file_id' with your actual File ID
    file_data = client.files.content("your_file_id")
    with open("downloaded_file.pdf", "wb") as file:
        file.write(file_data.read())
    
    
    

     After retrieving the file, saving it to a public URL is a recommended method for sharing. You can use services such as Azure Blob Storage to host your files publicly and obtain the URL. Currently, accessing files directly from the Data files location with a fully qualified public URL is not straightforward, as it is more of a secure sandbox. The suggested approach is to download the file programmatically and then upload it to a public storage solution.

    Hope this helps. Do let us know if you any further queries.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. David Hsieh 0 Reputation points
    2025-07-05T04:10:17.9866667+00:00

    How to access the file: "Click here to download the Excel template with closest point calculation"?

    0 comments No comments

  2. David Hsieh 0 Reputation points
    2025-07-05T05:14:58.6633333+00:00

    how to create a"Download the Excel file: Skew_Line_Distance_Closest_Points.xlsx

    This version includes:

    • ✅ Minimum distance between the two skew lines
    • 📍 Coordinates of the closest points on each line
    • 🧮 Intermediate vector math, all clearly labeled

    Let me know if you’d like a visualization or if there’s anything else you’d like to add to the sheet — like error checking, 3D plotting, or even VR-ready coordinate exports.

    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.