> ## Documentation Index
> Fetch the complete documentation index at: https://openai-hd4n6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Search vector store

> Search a vector store for relevant chunks based on a query and file attributes filter.



## OpenAPI

````yaml api-definition.yaml post /vector_stores/{vector_store_id}/search
openapi: 3.0.0
info:
  title: OpenAI API
  description: >-
    The OpenAI REST API. Please see
    https://platform.openai.com/docs/api-reference for more details.
  version: 2.3.0
  termsOfService: https://openai.com/policies/terms-of-use
  contact:
    name: OpenAI Support
    url: https://help.openai.com/
  license:
    name: MIT
    url: https://github.com/openai/openai-openapi/blob/master/LICENSE
servers:
  - url: https://api.openai.com/v1
security:
  - ApiKeyAuth: []
tags:
  - name: Assistants
    description: Build Assistants that can call models and use tools.
  - name: Audio
    description: Turn audio into text or text into audio.
  - name: Chat
    description: >-
      Given a list of messages comprising a conversation, the model will return
      a response.
  - name: Completions
    description: >-
      Given a prompt, the model will return one or more predicted completions,
      and can also return the probabilities of alternative tokens at each
      position.
  - name: Embeddings
    description: >-
      Get a vector representation of a given input that can be easily consumed
      by machine learning models and algorithms.
  - name: Evals
    description: Manage and run evals in the OpenAI platform.
  - name: Fine-tuning
    description: Manage fine-tuning jobs to tailor a model to your specific training data.
  - name: Batch
    description: Create large batches of API requests to run asynchronously.
  - name: Files
    description: >-
      Files are used to upload documents that can be used with features like
      Assistants and Fine-tuning.
  - name: Uploads
    description: Use Uploads to upload large files in multiple parts.
  - name: Images
    description: Given a prompt and/or an input image, the model will generate a new image.
  - name: Models
    description: List and describe the various models available in the API.
  - name: Moderations
    description: >-
      Given text and/or image inputs, classifies if those inputs are potentially
      harmful.
  - name: Audit Logs
    description: List user actions and configuration changes within this organization.
paths:
  /vector_stores/{vector_store_id}/search:
    post:
      tags:
        - Vector stores
      summary: Search vector store
      description: >-
        Search a vector store for relevant chunks based on a query and file
        attributes filter.
      operationId: searchVectorStore
      parameters:
        - in: path
          name: vector_store_id
          required: true
          schema:
            type: string
            example: vs_abc123
          description: The ID of the vector store to search.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VectorStoreSearchRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VectorStoreSearchResultsPage'
components:
  schemas:
    VectorStoreSearchRequest:
      type: object
      additionalProperties: false
      properties:
        query:
          description: A query string for a search
          oneOf:
            - type: string
            - type: array
              items:
                type: string
                description: A list of queries to search for.
                minItems: 1
        rewrite_query:
          description: Whether to rewrite the natural language query for vector search.
          type: boolean
          default: false
        max_num_results:
          description: >-
            The maximum number of results to return. This number should be
            between 1 and 50 inclusive.
          type: integer
          default: 10
          minimum: 1
          maximum: 50
        filters:
          description: A filter to apply based on file attributes.
          oneOf:
            - $ref: '#/components/schemas/ComparisonFilter'
            - $ref: '#/components/schemas/CompoundFilter'
          x-oaiExpandable: true
        ranking_options:
          description: Ranking options for search.
          type: object
          additionalProperties: false
          properties:
            ranker:
              type: string
              enum:
                - auto
                - default-2024-11-15
              default: auto
            score_threshold:
              type: number
              minimum: 0
              maximum: 1
              default: 0
      required:
        - query
      x-oaiMeta:
        name: Vector store search request
    VectorStoreSearchResultsPage:
      type: object
      additionalProperties: false
      properties:
        object:
          type: string
          enum:
            - vector_store.search_results.page
          description: The object type, which is always `vector_store.search_results.page`
          x-stainless-const: true
        search_query:
          type: array
          items:
            type: string
            description: The query used for this search.
            minItems: 1
        data:
          type: array
          description: The list of search result items.
          items:
            $ref: '#/components/schemas/VectorStoreSearchResultItem'
        has_more:
          type: boolean
          description: Indicates if there are more results to fetch.
        next_page:
          type: string
          description: The token for the next page, if any.
          nullable: true
      required:
        - object
        - search_query
        - data
        - has_more
        - next_page
      x-oaiMeta:
        name: Vector store search results page
    ComparisonFilter:
      type: object
      additionalProperties: false
      title: Comparison Filter
      description: >
        A filter used to compare a specified attribute key to a given value
        using a defined comparison operation.
      properties:
        type:
          type: string
          default: eq
          enum:
            - eq
            - ne
            - gt
            - gte
            - lt
            - lte
          description: >
            Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`,
            `lte`.

            - `eq`: equals

            - `ne`: not equal

            - `gt`: greater than

            - `gte`: greater than or equal

            - `lt`: less than

            - `lte`: less than or equal
        key:
          type: string
          description: The key to compare against the value.
        value:
          oneOf:
            - type: string
            - type: number
            - type: boolean
          description: >-
            The value to compare against the attribute key; supports string,
            number, or boolean types.
      required:
        - type
        - key
        - value
      x-oaiMeta:
        name: ComparisonFilter
    CompoundFilter:
      type: object
      additionalProperties: false
      title: Compound Filter
      description: Combine multiple filters using `and` or `or`.
      properties:
        type:
          type: string
          description: 'Type of operation: `and` or `or`.'
          enum:
            - and
            - or
        filters:
          type: array
          description: >-
            Array of filters to combine. Items can be `ComparisonFilter` or
            `CompoundFilter`.
          items:
            oneOf:
              - $ref: '#/components/schemas/ComparisonFilter'
      required:
        - type
        - filters
      x-oaiMeta:
        name: CompoundFilter
    VectorStoreSearchResultItem:
      type: object
      additionalProperties: false
      properties:
        file_id:
          type: string
          description: The ID of the vector store file.
        filename:
          type: string
          description: The name of the vector store file.
        score:
          type: number
          description: The similarity score for the result.
          minimum: 0
          maximum: 1
        attributes:
          $ref: '#/components/schemas/VectorStoreFileAttributes'
        content:
          type: array
          description: Content chunks from the file.
          items:
            $ref: '#/components/schemas/VectorStoreSearchResultContentObject'
      required:
        - file_id
        - filename
        - score
        - attributes
        - content
      x-oaiMeta:
        name: Vector store search result item
    VectorStoreFileAttributes:
      type: object
      description: >
        Set of 16 key-value pairs that can be attached to an object. This can
        be 

        useful for storing additional information about the object in a
        structured 

        format, and querying for objects via API or the dashboard. Keys are
        strings 

        with a maximum length of 64 characters. Values are strings with a
        maximum 

        length of 512 characters, booleans, or numbers.
      maxProperties: 16
      additionalProperties:
        oneOf:
          - type: string
            maxLength: 512
          - type: number
          - type: boolean
      x-oaiTypeLabel: map
      nullable: true
    VectorStoreSearchResultContentObject:
      type: object
      additionalProperties: false
      properties:
        type:
          description: The type of content.
          type: string
          enum:
            - text
        text:
          description: The text content returned from search.
          type: string
      required:
        - type
        - text
      x-oaiMeta:
        name: Vector store search result content object
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer

````