Vector store files
Beta

Vector store files represent files inside a vector store.source

Related guide: File Searchsource

Create vector store file
Beta

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

Create a vector store file by attaching a File to a vector store.source

Path parameters

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

Request body

A File ID 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

Returns

Example request
1
2
3
4
5
6
7
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" \
    -d '{
      "file_id": "file-abc123"
    }'
Response
1
2
3
4
5
6
7
8
9
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "created_at": 1699061776,
  "usage_bytes": 1234,
  "vector_store_id": "vs_abcd",
  "status": "completed",
  "last_error": null
}

List vector store files
Beta

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

Returns a list of vector store files.source

Path parameters

The ID of the vector store 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 \
  -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
}

Retrieve vector store file
Beta

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

Retrieves a vector store file.source

Path parameters

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

The ID of the file being retrieved.source

Returns

Example request
1
2
3
4
curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-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
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "created_at": 1699061776,
  "vector_store_id": "vs_abcd",
  "status": "completed",
  "last_error": null
}

Delete vector store file
Beta

delete https://api.openai.com/v1/vector_stores/{vector_store_id}/files/{file_id}

Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. To delete the file, use the delete file endpoint.source

Path parameters

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

The ID of the file to delete.source

Returns

Deletion statussource

Example request
1
2
3
4
5
curl https://api.openai.com/v1/vector_stores/vs_abc123/files/file-abc123 \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "OpenAI-Beta: assistants=v2" \
  -X DELETE
Response
1
2
3
4
5
{
  id: "file-abc123",
  object: "vector_store.file.deleted",
  deleted: true
}

The vector store file object
Beta

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

The total vector store usage in bytes. Note that this may be different from the original file size.source

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

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

The status of the vector store file, which can be either in_progress, completed, cancelled, or failed. The status completed indicates that the vector store file is ready for use.source

The last error associated with this vector store file. Will be null if there are no errors.source

The strategy used to chunk the file.source

OBJECT The vector store file object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
  "id": "file-abc123",
  "object": "vector_store.file",
  "usage_bytes": 1234,
  "created_at": 1698107661,
  "vector_store_id": "vs_abc123",
  "status": "completed",
  "last_error": null,
  "chunking_strategy": {
    "type": "static",
    "static": {
      "max_chunk_size_tokens": 800,
      "chunk_overlap_tokens": 400
    }
  }
}