AI / Core OpenAI Codex Application Fundamentals Interview Questions
What is the OpenAI Files API and how is it used for document management?
The Files API allows you to upload files to OpenAI's servers for use across multiple API features - fine-tuning, batch processing, assistants, and the file_search tool. Files are identified by a file ID and persist until explicitly deleted.
from openai import OpenAI client = OpenAI() # 1. Upload a file with open("technical-docs.pdf", "rb") as f: uploaded = client.files.create( file=f, purpose="assistants" # or "fine-tune", "batch", "vision" ) file_id = uploaded.id # e.g. "file-abc123" print(f"Uploaded: {file_id}, size: {uploaded.bytes} bytes") # 2. List files files = client.files.list(purpose="assistants") for f in files.data: print(f.id, f.filename, f.created_at) # 3. Use file in a Vector Store for file_search: vector_store = client.vector_stores.create(name="TechDocs") client.vector_stores.files.create( vector_store_id=vector_store.id, file_id=file_id ) # 4. Use vector store with file_search tool: response = client.responses.create( model="gpt-5.5", tools=[{ "type": "file_search", "vector_store_ids": [vector_store.id] }], input="What is the maximum API request size?" ) print(response.output_text) # 5. Delete file when done: client.files.delete(file_id)
| purpose | Used for |
|---|---|
| assistants | Assistants API and file_search in Responses API |
| fine-tune | Fine-tuning training data |
| batch | Batch API input files |
| vision | Image files for vision tasks |
Vector Stores (previously part of the Assistants API) are now a standalone resource, usable directly with the file_search tool in the Responses API. They handle chunking, embedding, and indexing automatically.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
