Share via

Azure openai API - files upload expires_after not supported

Dariusz Kowalczyk 10 Reputation points
2025-08-20T20:32:04.23+00:00

When uploading a file with purpose=assistants, I am unable to set the expires_after parameter. This issue occurs in both the Preview and v1 API versions.

According to the API documentation, the expires_after parameter should be supported.

Here is a sample request:

curl https://your_resource.openai.azure.com/openai/v1/files\?api-version\=preview \
  -H "Authorization: Bearer your_token" \
  -F purpose="assistants" \
  -F file="@fake_file.md" \
  -F 'expires_after={"anchor":"created_at","seconds":1209600}'

However, the parameter appears to be ignored or results in an error.

Steps to reproduce:

  1. Attempt to upload a file with purpose=assistants and set the expires_after parameter.
  2. Observe that the parameter is not set or an error is returned.

Expected: The expires_after parameter should be accepted and the file should expire after the specified duration.

Actual: The parameter is not set, or the API returns an error.

Azure OpenAI Service
Azure OpenAI Service

An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 41,291 Reputation points Volunteer Moderator
    2025-08-29T17:56:14.21+00:00

    Hello Dariusz !

    Thank you for posting on Microsoft Learn.

    Although the expires_after parameter isn't supported for assistant-purpose file uploads, you can apply expiration when creating or updating vector stores, which are used by the file_search tool.

    vector_store = client.beta.vector_stores.create_and_poll(
      name="Product Documentation",
      file_ids=['file_1','file_2'],
      expires_after={
        "anchor": "last_active_at",
        "days": 7
      }
    )
    

    This sets the vector store to expire 7 days after its last activity.

    https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/file-search

    Uploads made through assistant messages into threads automatically have a default expiration of seven days after last activity, even without specifying expires_after. You can override these settings only by managing vector stores explicitly.

    If controlling file expiration is essential, you could:

    • upload your files via purpose=assistants for use with your assistant
    • individually create a vector store attaching the same file(s), and specify an expires_after policy there attach that vector store to your assistant or thread as needed, allowing you to leverage expiration control

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.