tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > OpenAI API > OpenAI File Search and Vector Stores

OpenAI File Search and Vector Stores

Author: Venkata Sudhakar

OpenAI Vector Stores and the File Search tool allow you to upload documents and perform semantic search over them inside the Responses or Assistants API. ShopMax India uses Vector Stores to index product manuals, warranty documents, and return policy PDFs so that a GPT-powered support assistant can instantly retrieve the relevant section to answer customer questions without any custom embedding pipeline.

The workflow has three steps: upload files using client.files.create() with purpose=assistants, create a vector store using client.vector_stores.create() and attach the files, then query using client.responses.create() with a file_search tool and the vector_store_id. OpenAI automatically chunks the documents, generates embeddings, and handles retrieval. The response includes annotations showing which file and section was cited.

The below example shows ShopMax India uploading a product warranty PDF to a Vector Store and querying it through the Responses API to answer a customer warranty question.


It gives the following output,

File uploaded: file-abc123xyz
Vector store created: vs-def456uvw
Status: 1 files indexed

Answer: According to the Samsung TV warranty document, accidental damage including screen cracks or physical impact is not covered under the standard 1-year manufacturer warranty. ShopMax India customers may optionally purchase an Accidental Damage Protection plan at checkout for an additional Rs 1,499 which covers one accidental damage claim per year.
Source: samsung_tv_warranty.pdf - page 3

Vector Stores persist until you delete them - reuse the same store ID across sessions instead of re-uploading files on every run. Use client.vector_stores.file_batches.create() to add files in bulk and poll for completed status before querying. Set a max_num_results parameter on the file_search tool to control how many chunks are retrieved per query, balancing cost and answer quality. For large document libraries, organise files into separate Vector Stores by category (warranties, manuals, policies) and route queries to the appropriate store. Delete unused files and vector stores regularly to avoid storage charges.


 
  


  
bl  br