Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Vector Store Search Params

From Leeroopedia
Revision as of 13:41, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Vector_Store_Search_Params.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for specifying parameters when searching within a VectorStore via the OpenAI API, provided by the openai-python SDK.

Description

VectorStoreSearchParams is a TypedDict that defines the parameters for performing a vector search within a vector store. The required query field accepts a string or list of strings. Optional fields include filters (a ComparisonFilter or CompoundFilter union), max_num_results (1 to 50), ranking_options (controlling the ranker and score threshold), and rewrite_query (whether to rewrite the natural language query for vector search). A nested RankingOptions TypedDict provides ranker configuration.

Usage

Import this type when you need to type-annotate keyword arguments for client.vector_stores.search() or when constructing search parameter dictionaries with filters and ranking options.

Code Reference

Source Location

Signature

class VectorStoreSearchParams(TypedDict, total=False):
    query: Required[Union[str, SequenceNotStr[str]]]
    filters: Filters
    max_num_results: int
    ranking_options: RankingOptions
    rewrite_query: bool


Filters: TypeAlias = Union[ComparisonFilter, CompoundFilter]


class RankingOptions(TypedDict, total=False):
    ranker: Literal["none", "auto", "default-2024-11-15"]
    score_threshold: float

Import

from openai.types import VectorStoreSearchParams

I/O Contract

Fields (VectorStoreSearchParams)

Name Type Required Description
query Union[str, SequenceNotStr[str]] Yes A query string or list of query strings for the search.
filters Union[ComparisonFilter, CompoundFilter] No A filter to apply based on file attributes.
max_num_results int No The maximum number of results to return (1-50).
ranking_options RankingOptions No Ranking options for search result ordering.
rewrite_query bool No Whether to rewrite the natural language query for vector search.

Fields (RankingOptions)

Name Type Required Description
ranker Literal["none", "auto", "default-2024-11-15"] No Enable re-ranking; set to "none" to disable for reduced latency.
score_threshold float No Minimum score threshold for returned results.

Usage Examples

from openai import OpenAI
from openai.types import VectorStoreSearchParams

client = OpenAI()

params: VectorStoreSearchParams = {
    "query": "How do I configure authentication?",
    "max_num_results": 10,
    "ranking_options": {
        "ranker": "auto",
        "score_threshold": 0.5,
    },
    "rewrite_query": True,
}

results = client.vector_stores.search("vs_abc123", **params)
for result in results.data:
    print(result.filename, result.score)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment