Search vector store
vector_stores.search(strvector_store_id, VectorStoreSearchParams**kwargs) -> SyncPage[VectorStoreSearchResponse]
POST/vector_stores/{vector_store_id}/search
Search a vector store for relevant chunks based on a query and file attributes filter.
Parameters
vector_store_id: str
max_num_results: Optional[int]
The maximum number of results to return. This number should be between 1 and 50 inclusive.
minimum1
maximum50
Whether to rewrite the natural language query for vector search.
Returns
Search vector store
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ.get("OPENAI_API_KEY"), # This is the default and can be omitted
)
page = client.vector_stores.search(
vector_store_id="vs_abc123",
query="string",
)
page = page.data[0]
print(page.file_id){
"data": [
{
"attributes": {
"foo": "string"
},
"content": [
{
"text": "text",
"type": "text"
}
],
"file_id": "file_id",
"filename": "filename",
"score": 0
}
],
"has_more": true,
"next_page": "next_page",
"object": "vector_store.search_results.page",
"search_query": [
"string"
]
}Returns Examples
{
"data": [
{
"attributes": {
"foo": "string"
},
"content": [
{
"text": "text",
"type": "text"
}
],
"file_id": "file_id",
"filename": "filename",
"score": 0
}
],
"has_more": true,
"next_page": "next_page",
"object": "vector_store.search_results.page",
"search_query": [
"string"
]
}