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.