Skip to content

Add vector stores support to beta namespace #2353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sidakwalia
Copy link

Add Vector Stores Support to client.beta Namespace

Description
This PR restores the ability to access vector store resources through the client.beta namespace in the Python SDK, matching the API documentation. Previously, although vector_stores could be imported via client.vector_stores, attempting to reach it under client.beta.vector_stores resulted in an AttributeError.

Problem
The OpenAI API docs describe creating and managing vector stores via the beta namespace, for example:

vector_store = client.beta.vector_stores.create(name="My Vector Store")

However, in SDK v1.78.0:

print("vector_stores" in dir(client.beta))  # → False  
client.beta.vector_stores                  # → AttributeError

This discrepancy broke user workflows—especially around the Assistants API’s file_search tool, which relies on vector stores for semantic retrieval.

Changes Made

  • Imported all relevant vector store classes in beta.py:
from ...resources.vector_stores import (
    VectorStores,
    AsyncVectorStores,
    VectorStoresWithRawResponse,
    AsyncVectorStoresWithRawResponse,
    VectorStoresWithStreamingResponse,
    AsyncVectorStoresWithStreamingResponse,
)
  • Exposed vector_stores as a cached property on each beta client class (Beta, AsyncBeta, BetaWithRawResponse, etc.):

@cached_property
def vector_stores(self) -> VectorStores:
    from ...resources.vector_stores import VectorStores
    return VectorStores(self._client)

  • Followed the established pattern used for other beta resources (e.g., assistants, chat_completions) to ensure consistency across sync, async, raw-response, and streaming-response variants.

Testing

Verified that after this change:


from openai import OpenAI
client = OpenAI(api_key="your-api-key")

# Now returns True
print("vector_stores" in dir(client.beta))  

# Properly instantiates the VectorStores class
vector_store = client.beta.vector_stores.create(name="My Vector Store")

# File-search tool with vector store integration works as expected
response = client.beta.assistants.create(
    tools=[{"type": "file_search"}],
    tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}
)

Why This Fix Is Needed
Aligns the SDK’s implementation with its own documentation and user expectations. Full beta–namespace support for vector stores is critical for enabling semantic file search workflows in the Assistants API.

Related Issue
Resolves #2347

@sidakwalia sidakwalia requested a review from a team as a code owner May 12, 2025 02:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vector_stores not exposed in SDK 1.78.0 beta.client despite official release
1 participant