Issues with File Metadata Assignment in Azure OpenAI Vector Storage

I’m having trouble setting metadata properties for documents in my Azure OpenAI vector storage setup.

My configuration:

  • Azure OpenAI API (2025-04-01-preview)
  • Python SDK for document management
  • Trying to attach metadata like document_name and origin_link to uploaded files

The issue:
After uploading a document with purpose=“assistants” and attempting to assign metadata through client.vector_stores.files.create(), the metadata doesn’t get stored. The response shows attributes: null.

Code sample:

# Document upload
file_upload = client.files.create(
    file=document_data,
    purpose="assistants"  # This might be causing the problem
)
document_id = file_upload.id

# Metadata assignment - fails to work
vector_document = client.vector_stores.files.create(
    vector_store_id=storage_id,
    file_id=document_id,
    attributes={"document_name": "Sample Doc", "origin_link": "https://test.com"}
)

Interestingly, using the REST API directly works for updating metadata, but the Python SDK seems to ignore the attributes parameter. Has anyone run into this before or found a workaround?

Could there be specific limitations for metadata on files marked with purpose=“assistants”? Or might this be an SDK bug?

I encountered something similar about two months ago and it turned out to be related to the SDK version I was using. The attributes parameter in the Python SDK has been inconsistent across different versions, especially with the preview API endpoints. What worked for me was downgrading to an earlier SDK version temporarily, but that’s obviously not ideal for production. Another thing worth checking is whether you’re waiting long enough after the file upload before attempting the metadata assignment. I found that there’s sometimes a brief delay where the file isn’t fully processed yet, causing the metadata assignment to silently fail. Adding a small delay or checking the file status before proceeding with vector_stores.files.create() helped in my case. You might also want to verify that your vector store configuration supports custom metadata fields. Some setups have restrictions on metadata complexity or field names that aren’t always clearly documented.

This appears to be a known limitation with the current preview API version rather than an SDK issue. I’ve been working with Azure OpenAI vector stores for several months and ran into this exact problem. The attributes parameter in vector_stores.files.create() is essentially non-functional in the 2025-04-01-preview version when dealing with assistant-purpose files. What I ended up doing was implementing a hybrid approach where I store the metadata separately in my application database and reference it using the file_id as the key. Not elegant, but it works reliably. If you absolutely need the metadata within Azure’s system, you can try embedding the metadata directly into the document content as a header section before upload, though this affects the actual document content. Microsoft’s documentation mentions this limitation briefly but doesn’t provide clear workarounds. I’ve found that the REST API method you mentioned is more reliable, so you might want to stick with that approach until they fix the SDK implementation.

Had this exact headache last week! turns out the issue was mixing file purposes - when you upload with purpose=“assistants” the metadata handling gets weird. Try uploading without specifying purpose first, then add to vector store. also check if your using the right content-type headers, that tripped me up too.