How to delete a file in the new vectorstore API

I’m uncertain about the correct method for deleting a file in the new Assistant API vectorstore. From what I’ve gathered, files can be automatically removed by specifying an expiration term in the vectorStore policy.

In addition to this method, would calling the create_and_poll method with a new list of files, excluding the one I want to delete, also suffice? My primary goal is to optimize costs, and I would appreciate guidance on how to avoid being billed for unused storage space.

I am also unsure if storage space is billed for files that are created but not added to a vectorStore.

Not sure If I understand your issue properly but there’s a method provided in API Reference on Deleting File from Vector Stores.

It’s not billed on File Uploaded, but for the Vector Storage.

For File Search using Assistant:

$0.10 / GB of vector-storage per day (1 GB free)

Code Interpreter using Assistant:

$0.03 / session

Let me know if this answered your question.

1 Like

Perfect, thanks!

That’s exactly the two answers I was looking for

Have a nice day

L

1 Like

To delete a stored file in vector store first check all the available files.

To list all the available files for particular api key

from openai import OpenAI
client = OpenAI(api_key="sk-proj-xxxx")  # use your api_key

### List all vector stores
vector_stores = client.vector_stores.list()
print(vector_stores)

you will be able to see all the stored files , identify the file by id which you want to delete

for ex: ‘vs_684283d44a288191bb3b2b7c’

from openai import OpenAI
client = OpenAI(api_key="sk-proj-xxxx")  # use your api_key

deleted_vector_store = client.vector_stores.delete(
vector_store_id="vs_684283d44a288191bb3b2b7c")
print(deleted_vector_store)