Vector stores
List vector store files
Lists vector store files matching the request filters.
Parametry ścieżki
vector_store_id
string
wymagane
The ID of the vector store that the files belong to.
Parametry zapytań
limit
integer
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.
order
enum
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
after
string
A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
before
string
A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
filter
enum
Filter by file status. One of in_progress, completed, failed, cancelled.
Odpowiedzi
The request has succeeded.
Treść
Żądanie
curl https://api.openai.com/v1/vector_stores/vs_abc123/files \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-H "OpenAI-Beta: assistants=v2"
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.files.list(
vector_store_id="vector_store_id",
)
page = page.data[0]
print(page.id)
import OpenAI from "openai";
const openai = new OpenAI();
async function main() {
const vectorStoreFiles = await openai.vectorStores.files.list(
"vs_abc123"
);
console.log(vectorStoreFiles);
}
main();
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 vectorStoreFile of client.vectorStores.files.list('vector_store_id')) {
console.log(vectorStoreFile.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.Files.List(
context.TODO(),
"vector_store_id",
openai.VectorStoreFileListParams{},
)
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.files.FileListPage;
import com.openai.models.vectorstores.files.FileListParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
FileListPage page = client.vectorStores().files().list("vector_store_id");
}
}
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
page = openai.vector_stores.files.list("vector_store_id")
puts(page)
Response
{
"object": "list",
"data": [
{
"id": "file-abc123",
"object": "vector_store.file",
"created_at": 1699061776,
"vector_store_id": "vs_abc123"
},
{
"id": "file-abc456",
"object": "vector_store.file",
"created_at": 1699061776,
"vector_store_id": "vs_abc123"
}
],
"first_id": "file-abc123",
"last_id": "file-abc456",
"has_more": false
}