“load” via the API: this Python script will retrieve by steps of 5 for the query string limit. You can see if it breaks at one size or one potential bad database error, or even set the stepping lower than that.
# pip install httpx + OPENAI_API_KEY env var
import os
import sys
import httpx
API_KEY = os.getenv("OPENAI_API_KEY")
if not API_KEY:
print("Set OPENAI_API_KEY environment variable.", file=sys.stderr)
sys.exit(1)
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"OpenAI-Beta": "assistants=v2",
}
def main():
url = "https://api.openai.com/v1/vector_stores"
consecutive_under = 0
with httpx.Client(timeout=30) as client:
for limit in range(5, 31, 5):
try:
resp = client.get(url, headers=HEADERS, params={"limit": limit})
except Exception as e:
print(f"limit={limit} request_error={e}")
break
ok = resp.status_code == 200
if not ok:
print(f"limit={limit} status={resp.status_code} body={resp.text[:200]}")
break
data = resp.json()
items = data.get("data", []) or []
ids = [it.get("id") for it in items if isinstance(it, dict)]
count = len(ids)
has_more = data.get("has_more")
print(f"limit={limit} status=200 count={count} has_more={has_more} ids={', '.join(ids) if ids else '(none)'}")
if count < limit:
consecutive_under += 1
else:
consecutive_under = 0
if consecutive_under > 2:
print("Terminating: more than two successive under-limit results.")
break
if __name__ == "__main__":
main()