OpenAI Response API and code interpreter tool

Siry, Gaetan 280 Reputation points
2025-10-21T03:47:47.0266667+00:00

Hello,

I recently switched to the OpenAI Response API in Aure ( instead of the Assistants API, which is set to be deprecated soon )
I am running into issues with the code interpreter tool, where it works for a bit then stops working saying that it cannot access my file.

my container type is set to auto which is supposed to automatically manage the creation of environments.

Could it be that my container is expiring ?
once it expires how can i recover from it so that it does not impact accessing files ?

I do not see a lot of people creating their own container .. instead every one seems to be using auto

Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
{count} votes

2 answers

Sort by: Most helpful
  1. Pilladi Padma Sai Manisha 85 Reputation points Microsoft External Staff Moderator
    2025-10-22T01:20:39.6333333+00:00

    Hi Siry, Gaetan,
    Sorry for the wait! Here is the answer to your question:

    When I say “files are re-uploaded or created anew each time,” I mean that the code interpreter (when run in a new container) cannot see files that were only present inside the previous temporary environment, it must be given access again to any files you wish to use.

    If you already uploaded files to Azure OpenAI Files (using their REST API or portal), you do not have to upload the original file again. Instead, you simply need to reference the correct file's file_id in your new request, this tells Azure to “mount” that file in the new container, making it accessible to code interpreter.

    To ensure a new container (after expiration) can access your files:

    Upload files once using the /openai/files endpoint, and retrieve the file_id for each file.

    For each new API call that needs file access, include these file_id under the container.file_ids property. This way, any new container will automatically have access to your desired files.

    You don’t have to manually re-upload the file every time, just use the file_id you already have.

    POST https://YOUR-RESOURCE-NAME.openai.azure.com/openai/responses?api-version=2025-04-01-preview
    Content-Type: application/json
    api-key: YOUR_AZURE_OPENAI_KEY
    {
      "input": [
        {
          "role": "user",
          "content": "analyze the attached data file"
        }
      ],
      "tools": [
        {
          "type": "code_interpreter",
          "container": {
            "type": "auto",
            "file_ids": [
              "file-xxxxxxxxxxxxxxxxxxxxxxxx"
            ]
          }
        }
      ],
      "model": "gpt-4.1",
      "stream": false
    }
    
    • Replace "file-xxxxxxxxxxxxxxxxxxxxxxxx" with your actual Azure OpenAI file ID.
    • The same file ID can be used for any number of new requests, including after containers expire, as long as the file remains in Azure OpenAI Files storage.

    I hope this helps clarify the situation! If you have more specific details or additional questions, feel free to share, and I can assist further!

    could you please accept the answer!

    Thankyou.

    1 person found this answer helpful.
    0 comments No comments

  2. Siry, Gaetan 280 Reputation points
    2025-10-21T07:01:59.7633333+00:00

    thank you .

    My files are in Azure OpenAI files .

    What exactly do you mean by "files are re-uploaded or created a new each time" ? even when the container expires, my files are still in Azure OpenAI files.

    What is the process of re-uploading so that a new container would see the files that I pass using the file id ?

    Can you share a sample REST request ?

    thank you


Your answer

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