Uploading file to vector_stores not working with actual module version?

I try to run the following code :

import os, sys
from dotenv import load_dotenv
from openai import OpenAI

path = os.path.abspath(os.path.dirname(sys.argv[0])) 

fn = os.path.join(path, ".env")
load_dotenv(fn)
CHATGPT_API_KEY = os.environ.get("CHATGPT_API_KEY")
client = OpenAI(api_key = CHATGPT_API_KEY)

fn = os.path.join(path, "inp.pdf")
vector_store = client.beta.vector_stores.create(name="File")
file_paths = [fn]
file_streams = [open(path, "rb") for path in file_paths]
file_batch = client.beta.vector_stores.file_batches.upload_and_poll(
  vector_store_id=vector_store.id, files=file_streams
)
print(file_batch.status)
print(file_batch.file_counts)

When i run this with the version 1.65.0 everything works fine with this output:

(openai) C:\DEV\Fiverr2025\TRY\franksrn>python test2.py            
completed
FileCounts(cancelled=0, completed=1, failed=0, in_progress=0, total=1)

But when i try to run this with the actual version 1.70.0 i get this error:

(openai) C:\DEV\Fiverr2025\TRY\franksrn>python test2.py
Traceback (most recent call last):
  File "C:\DEV\Fiverr2025\TRY\franksrn\test2.py", line 13, in <module>
    vector_store = client.beta.vector_stores.create(name="File")
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Beta' object has no attribute 'vector_stores'

Why is this not working with the actual module-version?

vector_stores got moved out of beta in the client a while back (around v1.66.x). It’s now client.vector_stores instead of client.beta.vector_stores.

3 Likes

Work great - thanks a lot!