{"record":{"id":"6c759f0e9a58e409","repo":"openai/openai-python","slug":"async-runtime-async-library-is-not-supported-yet","errorCode":null,"errorMessage":"Async runtime {async_library} is not supported yet. Only asyncio or trio is supported","messagePattern":"Async runtime (.+?) is not supported yet\\. Only asyncio or trio is supported","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/openai/resources/vector_stores/file_batches.py","lineNumber":785,"sourceCode":"            # We only import if the library is being used.\n            # We support Python 3.7 so are using an older version of trio that does not have type information\n            import trio  # type: ignore # pyright: ignore[reportMissingTypeStubs]\n\n            async def trio_upload_file(limiter: trio.CapacityLimiter, file: FileTypes) -> None:\n                async with limiter:\n                    file_obj = await self._client.files.create(\n                        file=file,\n                        purpose=\"assistants\",\n                    )\n                    uploaded_files.append(file_obj)\n\n            limiter = trio.CapacityLimiter(max_concurrency)\n\n            async with trio.open_nursery() as nursery:\n                for file in files:\n                    nursery.start_soon(trio_upload_file, limiter, file)  # pyright: ignore [reportUnknownMemberType]\n        else:\n            raise RuntimeError(\n                f\"Async runtime {async_library} is not supported yet. Only asyncio or trio is supported\",\n            )\n\n        batch = await self.create_and_poll(\n            vector_store_id=vector_store_id,\n            file_ids=[*file_ids, *(f.id for f in uploaded_files)],\n            poll_interval_ms=poll_interval_ms,\n            chunking_strategy=chunking_strategy,\n        )\n        return batch\n\n\nclass FileBatchesWithRawResponse:\n    def __init__(self, file_batches: FileBatches) -> None:\n        self._file_batches = file_batches\n\n        self.create = _legacy_response.to_raw_response_wrapper(\n            file_batches.create,","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/openai/openai-python/blob/9917c6e28e66e90e1227b3d223c06a8c5441515a/src/openai/resources/vector_stores/file_batches.py#L767-L803","documentation":"`upload_and_poll` uploads files concurrently using either asyncio or trio, selected via `get_async_library()`. If the running async backend is neither (e.g. curio or a custom event loop), the SDK raises this RuntimeError because no compatible concurrency primitives are available for the fan-out uploads.","triggerScenarios":"Running `await client.vector_stores.file_batches.upload_and_poll(...)` inside a non-asyncio/non-trio async framework, or a runtime where `sniffio.get_async_library()` returns an unexpected library name.","commonSituations":"Embedding the SDK in a custom event loop, using curio, or test frameworks that replace the async backend; also version drift where an older sniffio/anyio combination reports a different library name.","solutions":["Run the call inside standard asyncio (`asyncio.run(main())`) or trio (`trio.run(main())`)","If you use a custom loop, port the upload logic to plain sequential `await client.vector_stores.files.upload_and_poll` calls and then create the batch yourself","Upgrade the openai package in case newer versions support your runtime"],"exampleFix":"# before\nawait client.vector_stores.file_batches.upload_and_poll(vs_id, files)  # inside custom loop\n\n# after\nimport asyncio\nasyncio.run(client.vector_stores.file_batches.upload_and_poll(vs_id, files))","handlingStrategy":"fallback","validationCode":"import sniffio\n\nlib = sniffio.current_async_library()\nif lib not in {\"asyncio\", \"trio\"}:\n    raise RuntimeError(f\"Run under asyncio or trio, not {lib!r}\")\nbatch = await client.vector_stores.file_batches.upload_and_poll(vs_id, files)","typeGuard":null,"tryCatchPattern":"try:\n    batch = await client.vector_stores.file_batches.upload_and_poll(vs_id, files)\nexcept RuntimeError as e:\n    if \"not supported yet\" in str(e):\n        # fallback: sequential uploads then create the batch manually\n        ids = [(await client.vector_stores.files.upload_and_poll(vs_id, f)).id for f in files]\n        batch = await client.vector_stores.file_batches.create_and_poll(vector_store_id=vs_id, file_ids=ids)\n    else:\n        raise","preventionTips":["Run SDK async code under standard asyncio or trio only","Avoid custom event loops for SDK calls; offload to a worker running asyncio","Pin sniffio/anyio versions compatible with your framework"],"tags":["asyncio","trio","runtime","upload-and-poll","vector-stores"],"backgroundTag":"unsupported-async-runtime","analyzedSha":"9917c6e28e66e90e1227b3d223c06a8c5441515a","analyzedAt":"2026-08-28T11:46:34.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}