OpenAI's platform surfaces a broad set of resources grouped around projects, files/uploads, assistants/threads/runs, vector stores, fine-tuning, batches, and organization-level admin objects (API keys, certificates, users). The following narrative explains how those pieces fit together, what to call first to get the IDs you will need, common multi-step workflows users request, and the non-obvious behaviors that cause mistakes.
Core entities and how they relate
-
Projects vs Organization
- Projects are the primary scoping unit for most operational resources: project-scoped API keys, service accounts, rate limits, and project membership live under a
project_id. Many management operations require aproject_id. Organization-level resources include organization admin API keys and organization certificates (there are also project-level certificates).
- Projects are the primary scoping unit for most operational resources: project-scoped API keys, service accounts, rate limits, and project membership live under a
-
Files, Uploads, and Parts
- A large-file upload is a two-step flow: create an
Uploadobject, addParts(each part ≤ 64 MB) withaddUploadPart, then callcompleteUploadspecifying the ordered list of Part IDs to produce aFileobject. Uploads expire after an hour and can be canceled withcancelUpload. For single-file uploads within the size limit,createFileproduces aFiledirectly. - Files are referenced by
file_idacross other features: fine-tuning, batches, vector stores, and assistants' file-search tool.
- A large-file upload is a two-step flow: create an
-
Vector stores and files
- Create a vector store (
createVectorStore) to get avector_store_id. Add data by attaching aFileviacreateVectorStoreFileor batch withcreateVectorStoreFileBatch. UsesearchVectorStoreto query. You can fetch parsed content withretrieveVectorStoreFileContentand update file attributes withupdateVectorStoreFileAttributes. - Deleting a vector store file (via
deleteVectorStoreFile) removes it from the store but does not delete the underlyingFileobject; to remove the file from the system, calldeleteFileseparately.
- Create a vector store (
-
Assistants, Threads, Runs, Messages
- Assistants are configuration objects (
createAssistant,getAssistant,modifyAssistant,deleteAssistant), used by higher-level assistant tooling. - Conversations are modeled as
threadobjects. Create a thread (createThread) and then create runs (createRun) to execute assistant logic. You can create a thread and run it in one call (createThreadAndRun). Runobjects containsteps(sequence of operations the assistant performed) and may generaterequired_actionstates. UselistRunSteps/getRunStepto inspect steps andlistRuns/getRunto inspect runs.- Messages belong to threads (
createMessage,listMessages,getMessage,modifyMessage,deleteMessage). A run may create messages; messages can be filtered byrun_idwhen listing. - When a run enters
requires_actionwithrequired_action.type == submit_tool_outputs, you must submit all tool outputs in a singlesubmitToolOuputsToRuncall for that run to continue.
- Assistants are configuration objects (
-
Responses and Chat Completions
- Newer flows use
createResponse(Responses) which supports richer behavior (tooling, structured outputs, multimodal inputs). Legacy chat-style generation still exists ascreateChatCompletion. Both can return streaming or non-streaming types — check the returned object type to decide whether you received a stream event versus a final object. - Stored chat completions are only accessible for retrieval/modification/deletion if they were created with
store=true. Only stored completions appear inlistChatCompletions,getChatCompletion,updateChatCompletion, anddeleteChatCompletion.
- Newer flows use
-
Fine-tuning and checkpoints
- Fine-tuning jobs are created via
createFineTuningJob. Jobs have checkpoints and events you can list (listFineTuningJobCheckpoints,listFineTuningEvents). Sharing a checkpoint across projects and deleting/inspecting checkpoint permissions requires an organization admin API key (admin-only endpoints are explicitly noted).
- Fine-tuning jobs are created via
-
Batches
- Batches accept a
.jsonlfile of requests and produce outputs. You create a batch (createBatch) from an uploaded file and can cancel it (cancelBatch); cancellation is asynchronous and a batch may becancellingfor minutes before becomingcancelledwith partial results available.
- Batches accept a
-
API keys, service accounts, users, invites
- Organization admin API keys are separate from project-level API keys. Creating organization admin keys and some checkpoint-permission operations require the admin-level key. Creating a project service account returns an unredacted API key — treat it as a secret immediately after creation. Invites can be deleted only while pending; once accepted they cannot be deleted.
Recommended entry points (what to call first)
-
To operate on a particular project: call
list-projects(orretrieve-projectif you already have a project id) to obtainproject_id. Many project-scoped endpoints require this (service accounts, project API keys, rate limits, users, certificates). -
To work with files and data:
- If the user will upload >512 MB or needs parallel part uploads, start with
createUploadthenaddUploadPartand finish withcompleteUploadto get aFileobject. - For smaller uploads or when the platform-specific file creation is acceptable, use
createFile. - Use
listFilesorretrieveFileto locate existingfile_idvalues.
- If the user will upload >512 MB or needs parallel part uploads, start with
-
To run assistant behavior or reproduce a conversation:
- Create (or retrieve) the
threadwithcreateThread/getThreadand then run it withcreateRun(orcreateThreadAndRunfor one-shot). Inspect progress vialistRuns,getRun,listRunSteps, andgetRunStep.
- Create (or retrieve) the
-
To build a vector-based retrieval flow:
- Call
createVectorStoreto getvector_store_id, attach data viacreateVectorStoreFile/createVectorStoreFileBatch, thensearchVectorStoreto query. UselistVectorStoresandlistVectorStoreFilesto monitor ingestion status.
- Call
-
To generate text/embeddings/images/audio:
- For new development prefer
createResponsefor richest features, orcreateChatCompletion/createCompletionfor chat/completion flows. UsecreateEmbeddingfor vector embeddings. ChecklistModelsif you need model capabilities or availability.
- For new development prefer
Common multi-step workflows
-
Large-file upload then use elsewhere:
createUploadto getupload_id.- Parallel
addUploadPartcalls with each part's bytes and part index. completeUploadwith the ordered list of Part IDs; the response includes a nestedFileobject withfile_id.- Use that
file_idwithcreateFineTuningJob,createBatch,createVectorStoreFile, or assistant file-search tools.
-
Create a vector retrieval pipeline:
createVectorStore→ obtainvector_store_id.- Attach a file with
createVectorStoreFileor create a batch withcreateVectorStoreFileBatchfor larger/parallel ingestion. - Monitor ingestion with
listVectorStoreFiles/getVectorStoreFile/getVectorStoreFileBatch. - Query with
searchVectorStoreand optionally fetch parsed content withretrieveVectorStoreFileContent.
-
Run a thread that requires tool outputs:
- Start or identify a
thread_idand run it (createRun). - If the run returns
status: "requires_action"withrequired_action.type == "submit_tool_outputs", gather all tool outputs and submit them in a singlesubmitToolOuputsToRuncall. Partial submissions will not resume the run — all outputs must be included together.
- Start or identify a
-
Fine-tune a model:
- Prepare a
.jsonlfile in the fine-tuning format and upload it (usecreateFilefor files under the allowed limit or the Upload flow for larger ones). createFineTuningJobreferencing thefile_id.- Monitor job events and checkpoints with
listFineTuningEventsandlistFineTuningJobCheckpoints. - Sharing or deleting checkpoint permissions across projects requires an organization admin API key.
- Prepare a
Non-obvious behaviors and gotchas
-
Upload expiry and sizes
Uploadobjects expire after one hour. Parts can be uploaded in parallel, but you must callcompleteUploadbefore expiry and the total bytes on completion must match the original upload object.- Individual
Part≤ 64 MB, upload total ≤ 8 GB. SeparatecreateFileaccepts files up to 512 MB (and the overall org storage limit applies). - Assistants' file tools and some flows accept much larger tokenized sizes (Assistants support files up to ~2M tokens); check the target feature before choosing the upload method.
-
Streaming vs final responses
- Several generation endpoints can produce either a streaming response type or a final object (
createChatCompletion,createResponse,createTranscriptionetc.). Do not assume the shape; inspect the returned result to decide whether it's a stream event or the final resource.
- Several generation endpoints can produce either a streaming response type or a final object (
-
Stored chat completions
- Only completions created with
store=trueare returned by list/retrieve/update/delete chat-completion endpoints. If a user asks to modify or delete a stored chat, first ensure that the completion was stored.
- Only completions created with
-
Admin-only operations
- Some permission and checkpoint operations explicitly require an organization admin API key (organization-level admin privileges). Attempts to call those with a project-level key will fail authorization.
-
Deletion constraints and semantics
delete-inviteonly works for pending invites. Once accepted, an invite cannot be deleted.deleteCertificaterequires that the certificate be inactive at both the organization and project levels before deletion.- Deleting a vector store file removes it from the vector store but does not delete the underlying
Fileobject from the organization's file list. - Deleting a fine-tuned model requires Owner role in the organization.
-
Cancellation is often asynchronous
- Cancelling a batch (
cancelBatch) or some other long-running work sets an in-flight status such ascancellingfor a period; expect partial results to be available after the cancel completes.
- Cancelling a batch (
-
Service accounts and API keys
- Creating a project service account returns the unredacted API key once — store or surface it securely to the user immediately. Project API keys vs organization admin API keys have different scopes and capabilities.
-
Usage endpoints
- Usage endpoints require a
start_timeand optionalend_timeand support grouping and paging. Thepageornext_pagecursor is used to retrieve additional buckets.
- Usage endpoints require a
-
Response includes additional fields via include parameters
- Several endpoints accept
includequery parameters (for exampleinclude[]when creating a run or fetching steps) to fetch nested or large fields like file-search result content. Only request these when you need them, as they can enlarge the response.
- Several endpoints accept
Quick checklist for common user requests
- Generate text or conversation:
createResponse(preferred; richer features) orcreateChatCompletion/createCompletion. - Get embeddings:
createEmbedding. - Upload a large file and get a
file_id:createUpload→addUploadPart→completeUpload(orcreateFilefor small files). - Fine-tune a model: upload
.jsonlfile →createFineTuningJob→ monitor withretrieveFineTuningJobandlistFineTuningEvents. - Run an assistant flow for a saved thread:
createRun(orcreateThreadAndRun) → monitorlistRuns/getRun→ inspect steps withlistRunSteps/getRunStep. - Build a vector search:
createVectorStore→createVectorStoreFile/createVectorStoreFileBatch→searchVectorStore.
Use these patterns as composable building blocks: first acquire the canonical ID the downstream call requires (project_id, file_id, upload_id, vector_store_id, thread_id, run_id, response_id), then perform the operation that consumes that ID. When an endpoint warns of admin-only access or special size/format constraints, prefer the specialized endpoint (e.g., Upload + Parts for large files, admin endpoints for checkpoint permissions).
When something looks incomplete
- If a listing response is truncated, request the next page with the provided cursor parameter (
afterorpage). - If a run stops with
requires_action, inspectrequired_actionto decide whether to callsubmitToolOuputsToRun(note: all tool outputs must be submitted in one request) or other follow-ups. - If a creation endpoint returns an ephemeral secret (service account or realtime session), return that secret to the caller immediately—these values are unredacted only on creation.
This guidance highlights the platform patterns that most frequently block multi-step flows: where to get the IDs you need, which objects are project-scoped vs organization-scoped, upload/file size and expiry constraints, and the special semantics around stored completions, admin-only permissions, and run-required-actions. Follow the entity-first pattern (acquire the resource ID, then call the consumer operation) and prefer the Upload flow for large files, createFile for smaller files, and createResponse for newer generation features.