Vector store file batches
Beta

Vector store file batches represent operations to add multiple files to a vector store. Related guide: File Searchsource

Create vector store file batch
Beta

post https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches

Create a vector store file batch.source

Path parameters

The ID of the vector store for which to create a File Batch.source

Request body

A list of File IDs that the vector store should use. Useful for tools like file_search that can access files.source

The chunking strategy used to chunk the file(s). If not set, will use the auto strategy.source

Example request
1
2
3
4
5
6
7
curl https://api.openai.com/v1/vector_stores/vs_abc123/file_batches \
    -H "Authorization: Bearer $OPENAI_API_KEY" \
    -H "Content-Type: application/json \
    -H "OpenAI-Beta: assistants=v2" \
    -d '{
      "file_ids": ["file-abc123", "file-abc456"]
    }'
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_abc123",
  "object": "vector_store.file_batch",
  "created_at": 1699061776,
  "vector_store_id": "vs_abc123",
  "status": "in_progress",
  "file_counts": {
    "in_progress": 1,
    "completed": 1,
    "failed": 0,
    "cancelled": 0,
    "total": 0,
  }
}

Retrieve vector store file batch
Beta

get https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}

Retrieves a vector store file batch.source

Path parameters

The ID of the vector store that the file batch belongs to.source

The ID of the file batch being retrieved.source

Example request
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123 \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2"
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_abc123",
  "object": "vector_store.file_batch",
  "created_at": 1699061776,
  "vector_store_id": "vs_abc123",
  "status": "in_progress",
  "file_counts": {
    "in_progress": 1,
    "completed": 1,
    "failed": 0,
    "cancelled": 0,
    "total": 0,
  }
}

Cancel vector store file batch
Beta

post https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/cancel

Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible.source

Path parameters

The ID of the vector store that the file batch belongs to.source

The ID of the file batch to cancel.source

Returns

The modified vector store file batch object.source

Example request
1
2
3
4
5
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/cancel \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2" \
  -X POST
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_abc123",
  "object": "vector_store.file_batch",
  "created_at": 1699061776,
  "vector_store_id": "vs_abc123",
  "status": "cancelling",
  "file_counts": {
    "in_progress": 12,
    "completed": 3,
    "failed": 0,
    "cancelled": 0,
    "total": 15,
  }
}

List vector store files in a batch
Beta

get https://api.openai.com/v1/vector_stores/{vector_store_id}/file_batches/{batch_id}/files

Returns a list of vector store files in a batch.source

Path parameters

The ID of the vector store that the files belong to.source

The ID of the file batch that the files belong to.source

Query parameters

A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.source

Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.source

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.source

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.source

Filter by file status. One of in_progress, completed, failed, cancelled.source

Returns

A list of vector store file objects.source

Example request
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123/files_batches/vsfb_abc123/files \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2"
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
  "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
}

The vector store files batch object
Beta

A batch of files attached to a vector store.source

The identifier, which can be referenced in API endpoints.source

The object type, which is always vector_store.file_batch.source

The Unix timestamp (in seconds) for when the vector store files batch was created.source

The ID of the vector store that the File is attached to.source

The status of the vector store files batch, which can be either in_progress, completed, cancelled or failed.source

OBJECT The vector store files batch object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
{
  "id": "vsfb_123",
  "object": "vector_store.files_batch",
  "created_at": 1698107661,
  "vector_store_id": "vs_abc123",
  "status": "completed",
  "file_counts": {
    "in_progress": 0,
    "completed": 100,
    "failed": 0,
    "cancelled": 0,
    "total": 100
  }
}