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 Response

From Leeroopedia
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete tool for representing a single search result from a VectorStore search operation, provided by the openai-python SDK.

Description

VectorStoreSearchResponse is a Pydantic BaseModel subclass that represents an individual search result returned by the vector store search endpoint. Each result includes the matched content chunks (a list of Content objects), the file_id and filename of the source file, a similarity score, and optional attributes (key-value metadata). The nested Content model contains the text content and its type (always "text").

Usage

Import this type when you need to type-annotate or inspect individual search results returned by client.vector_stores.search(). The response from the search endpoint contains a list of these objects.

Code Reference

Source Location

Signature

class Content(BaseModel):
    text: str
    type: Literal["text"]


class VectorStoreSearchResponse(BaseModel):
    attributes: Optional[Dict[str, Union[str, float, bool]]] = None
    content: List[Content]
    file_id: str
    filename: str
    score: float

Import

from openai.types import VectorStoreSearchResponse

I/O Contract

Fields (VectorStoreSearchResponse)

Name Type Required Description
attributes Optional[Dict[str, Union[str, float, bool]]] No Key-value pairs attached to the object for filtering and metadata.
content List[Content] Yes Content chunks from the matched file.
file_id str Yes The ID of the vector store file.
filename str Yes The name of the vector store file.
score float Yes The similarity score for the result.

Fields (Content)

Name Type Required Description
text str Yes The text content returned from search.
type Literal["text"] Yes The type of content, always "text".

Usage Examples

from openai import OpenAI
from openai.types import VectorStoreSearchResponse

client = OpenAI()

results = client.vector_stores.search("vs_abc123", query="setup guide")

for result in results.data:
    result: VectorStoreSearchResponse
    print(f"File: {result.filename} (score: {result.score})")
    for chunk in result.content:
        print(f"  {chunk.text[:100]}...")

Related Pages

Page Connections

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