Пропустить и перейти к основному содержимому

Этот браузер больше не поддерживается.

Выполните обновление до Microsoft Edge, чтобы воспользоваться новейшими функциями, обновлениями для системы безопасности и технической поддержкой.

Скачать Microsoft Edge Дополнительные сведения об Internet Explorer и 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.

Параметры пути

vector_store_id string обязательно

The ID of the vector store to search.

Текст запроса

The request body.

Content-Type: application/json
query string | string[] обязательно

A query string for a search

Один из следующих:
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.

Один из следующих:
type enum обязательно

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 обязательно

The key to compare against the value.

value string | OpenAI.numeric | boolean | (string | OpenAI.numeric)[] обязательно

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

Один из следующих:
string
number
boolean
(string | OpenAI.numeric)[]
type enum обязательно

Type of operation: and or or.

andor
filters (OpenAI.ComparisonFilter | OpenAI.CompoundFilter)[] обязательно

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

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

Ответы

The request has succeeded.

Текст

Content-Type: application/json
object enum обязательно

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

vector_store.search_results.page
search_query string[] обязательно
data OpenAI.VectorStoreSearchResultItem[] обязательно

The list of search result items.

has_more boolean обязательно

Indicates if there are more results to fetch.

next_page string | null обязательно

Client error

Текст

Content-Type: application/json
error OpenAI.Error обязательно
code string | null обязательно
message string обязательно
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Любое из следующих:
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 обязательно

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Текст

Content-Type: application/json
error OpenAI.Error обязательно
code string | null обязательно
message string обязательно
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Любое из следующих:
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 обязательно

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Запрос

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)

Response

{
  "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
}
ru-ru
Ваши варианты выбора параметров конфиденциальности
  • Заявление об отказе ИИ
  • Предыдущие версии
  • Блог
  • Участие в доработке
  • Конфиденциальность
  • Конфиденциальность медицинских данных потребителей
  • Условия использования
  • Товарные знаки
  • © Microsoft 2026