Hello
Try the following steps to resolve the issue with assigning the file to the vector store:
-
After uploading the file and getting a “status”: “ready”, wait a few seconds (e.g., time.sleep(5)) before trying to assign it. The file might not be fully indexed immediately even if it appears ready.
-
Make sure the file format is supported and readable—PDFs must contain extractable text (not just scanned images). To confirm, test with a simple .txt file.
-
Double-check that you’re using the correct file_id from the upload response, and that your vector_store_id is valid (it should start with vs_…).
-
Use this API call to assign the file:
openai.beta.vector_stores.file_batches.create(
vector_store_id=“vs_xxx”,
file_ids=[“file-xxx”]
)
- Wrap the request in a try/except block to capture any error messages from the API:
try:
openai.beta.vector_stores.file_batches.create(…)
except openai.OpenAIError as e:
print(e)
This should help isolate whether it’s a timing issue, file format issue, or an API constraint.
I hope this will help you
Nicholas