{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreifrydzfdnyygcq57mpq7ocwclrrioqodk3glfkn4optqoxntfbulq",
"uri": "at://did:plc:lk3jfj3zq4k4wxnk474axylu/app.bsky.feed.post/3mmvstlgfmjp2"
},
"path": "/t/vector-store-api-calls-returning-504s-503s-and-generally-being-slow/1381938#post_1",
"publishedAt": "2026-05-28T09:47:24.000Z",
"site": "https://community.openai.com",
"tags": [
"@param",
"@returns"
],
"textContent": "3 months ago, I set up an AI chatbot that uses resources from the OpenAI vector store as references. The resources within the vector store needed to be cycled weekly, as they are frequently updated, with items removed and added.\n\nTo ensure everything is cycled correctly, I built a cron job that clears the vector stores and reloads the new set of resources. The code behind the cron job worked perfectly over the last couple of months, but is now failing when listing files from a vector store.\n\nThis is the code I’m using to call the API:\n\n\n /**\n * Gets all file IDs from a vector store.\n * @param openai - An initialized OpenAI client\n * @param vectorStoreId - The ID of the vector store\n * @returns An array of file IDs\n */\n export async function getVectorStoreFileIds(openai: OpenAI, vectorStoreId: string): Promise<string[]> {\n const fileIds: string[] = [];\n let hasMorePages = true;\n let paginationCursor: string | undefined;\n\n while (hasMorePages) {\n const params: { limit: number; after?: string; } = { limit: 100 };\n if (paginationCursor) {\n params.after = paginationCursor;\n }\n\n const filesPage = await openai.vectorStores.files.list(vectorStoreId, params);\n\n if (filesPage.data.length === 0) {\n hasMorePages = false;\n break;\n }\n\n fileIds.push(...filesPage.data.map((f) => f.id));\n\n hasMorePages = filesPage.hasNextPage();\n\n if (hasMorePages && filesPage.data.length > 0) {\n paginationCursor = filesPage.data[filesPage.data.length - 1].id;\n }\n }\n\n return fileIds;\n }\n\n\nI use this to get all of the `fileIds` so I can then delete them in batches. When I run this, I get either a 504:\n\n\n Fatal error: InternalServerError: 504 status code (no body)\n at Function.generate (/my-repo/node_modules/openai/src/core/error.ts:100:14)\n at OpenAI.makeStatusError (/my-repo/node_modules/openai/src/client.ts:478:28)\n at OpenAI.makeRequest (/my-repo/node_modules/openai/src/client.ts:728:24)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async getVectorStoreFileIds (/my-repo/scripts/vector-store-sync/shared.ts:121:23)\n at async clearVectorStore (/my-repo/scripts/vector-store-sync/shared.ts:90:29)\n at async main (/my-repo/scripts/vector-store-sync/sync-resources.ts:82:3)\n at async main (/my-repo/scripts/vector-store-sync/sync-all-vector-stores.ts:34:27) {\n status: 504,\n headers: Headers {\n date: 'Thu, 28 May 2026 09:33:18 GMT',\n 'content-type': 'application/json; charset=utf-8',\n 'content-length': '899',\n connection: 'keep-alive',\n 'retry-after': '120',\n 'cache-control': 'private, max-age=0, no-store, no-cache, must-revalidate, post-check=0, pre-check=0',\n expires: 'Thu, 01 Jan 1970 00:00:01 GMT',\n 'referrer-policy': 'same-origin',\n 'x-frame-options': 'SAMEORIGIN',\n 'access-control-expose-headers': 'CF-Ray',\n server: 'cloudflare',\n 'cf-ray': '<removed>',\n 'alt-svc': 'h3=\":443\"; ma=86400'\n },\n requestID: null,\n error: undefined,\n code: undefined,\n param: undefined,\n type: undefined\n }\n\n\nOr a 503 error:\n\n\n InternalServerError: 503 System is overloaded. Please retry in a few minutes.\n at Function.generate (/my-repo/node_modules/openai/src/core/error.ts:100:14)\n at OpenAI.makeStatusError (/my-repo/node_modules/openai/src/client.ts:478:28)\n at OpenAI.makeRequest (/my-repo/node_modules/openai/src/client.ts:728:24)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async getVectorStoreFileIds (/my-repo/functions/src/vector-store-sync/openai-helpers.ts:141:23)\n at async detachAllFilesFromVectorStore (/my-repo/functions/src/vector-store-sync/openai-helpers.ts:62:19)\n at async syncVectorStores (/my-repo/functions/src/vector-store-sync/sync-vector-stores.ts:97:3)\n at async run (/my-repo/tests/manual/test-sync-vector-stores.ts:45:18) {\n status: 503,\n headers: Headers {},\n requestID: '<removed>',\n error: {\n message: 'System is overloaded. Please retry in a few minutes.',\n type: 'service_unavailable_error',\n param: null,\n code: null\n },\n code: null,\n param: null,\n type: 'service_unavailable_error'\n }\n\n\nThis is completely disrupting my chatbot and service. What is happening here?",
"title": "Vector Store API calls returning 504s, 503s, and generally being slow"
}