Naar hoofdinhoud gaan

Deze browser wordt niet meer ondersteund.

Upgrade naar Microsoft Edge om te profiteren van de nieuwste functies, beveiligingsupdates en technische ondersteuning.

Microsoft Edge downloaden Meer informatie over Internet Explorer en Microsoft Edge
microsoft-foundry.rest.security.o-auth2-auth

Vector stores

Search a vector store

POST /openai/v1/vector_stores/{vector_store_id}/search

Searchs a vector store.

Padparameters

vector_store_id string vereist

The ID of the vector store to search.

Aanvraagbody

The request body.

Content-Type: application/json
query string | string[] vereist

A query string for a search

Een van de volgende:
string
string[]
rewrite_query boolean

Whether to rewrite the natural language query for vector search.

max_num_results integer
filters OpenAI.ComparisonFilter | OpenAI.CompoundFilter

A filter to apply based on file attributes.

Een van de volgende:
type enum vereist

Specifies the comparison operator: eq, ne, gt, gte, lt, lte, in, nin. - eq: equals - ne: not equal - gt: greater than - gte: greater than or equal - lt: less than - lte: less than or equal - in: in - nin: not in

eqnegtgteltlteinnin
key string vereist

The key to compare against the value.

value string | OpenAI.numeric | boolean | (string | OpenAI.numeric)[] vereist

The value to compare against the attribute key; supports string, number, or boolean types.

Een van de volgende:
string
number
boolean
(string | OpenAI.numeric)[]
type enum vereist

Type of operation: and or or.

andor
filters (OpenAI.ComparisonFilter | OpenAI.CompoundFilter)[] vereist

Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.

ranking_options OpenAI.VectorStoreSearchRequestRankingOptions
ranker enum
noneautodefault-2024-11-15
score_threshold number

Antwoorden

The request has succeeded.

Hoofdtekst

Content-Type: application/json
object enum vereist

The object type, which is always vector_store.search_results.page

vector_store.search_results.page
search_query string[] vereist
data OpenAI.VectorStoreSearchResultItem[] vereist

The list of search result items.

has_more boolean vereist

Indicates if there are more results to fetch.

next_page string | null vereist

Client error

Hoofdtekst

Content-Type: application/json
error OpenAI.Error vereist
code string | null vereist
message string vereist
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Een van de volgende:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string vereist

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Hoofdtekst

Content-Type: application/json
error OpenAI.Error vereist
code string | null vereist
message string vereist
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Een van de volgende:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string vereist

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Aanvraag

curl -X POST \
https://api.openai.com/v1/vector_stores/vs_abc123/search \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "What is the return policy?", "filters": {...}}'
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const vectorStoreSearchResponse of client.vectorStores.search('vs_abc123', {
  query: 'string',
})) {
  console.log(vectorStoreSearchResponse.file_id);
}
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)
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    page, err := client.VectorStores.Search(
        context.TODO(),
        "vs_abc123",
        openai.VectorStoreSearchParams{
            Query: openai.VectorStoreSearchParamsQueryUnion{
                OfString: openai.String("string"),
            },
        },
    )
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", page)
}
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.vectorstores.VectorStoreSearchPage;
import com.openai.models.vectorstores.VectorStoreSearchParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        VectorStoreSearchParams params = VectorStoreSearchParams.builder()
            .vectorStoreId("vs_abc123")
            .query("string")
            .build();
        VectorStoreSearchPage page = client.vectorStores().search(params);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

page = openai.vector_stores.search("vs_abc123", query: "string")

puts(page)

Respons

{
  "object": "vector_store.search_results.page",
  "search_query": "What is the return policy?",
  "data": [
    {
      "file_id": "file_123",
      "filename": "document.pdf",
      "score": 0.95,
      "attributes": {
        "author": "John Doe",
        "date": "2023-01-01"
      },
      "content": [
        {
          "type": "text",
          "text": "Relevant chunk"
        }
      ]
    },
    {
      "file_id": "file_456",
      "filename": "notes.txt",
      "score": 0.89,
      "attributes": {
        "author": "Jane Smith",
        "date": "2023-01-02"
      },
      "content": [
        {
          "type": "text",
          "text": "Sample text content from the vector store."
        }
      ]
    }
  ],
  "has_more": false,
  "next_page": null
}
nl-nl
Uw privacykeuzes
  • AI-disclaimer
  • Vorige versies
  • Blog
  • Bijdragen
  • Privacy
  • Privacy van gezondheidsdata
  • Gebruiksvoorwaarden
  • Handelsmerken
  • © Microsoft 2026