Create vector store file

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

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

Path parameters

  • vector_store_id
    string
    Required
    The ID of the vector store for which to create a File.

Request body

  • file_id
    string
    Required

    A File ID that the vector store should use. Useful for tools like file_search that can access files.

  • chunking_strategy
    object

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

    • Auto Chunking Strategy
      object

      The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400.

      • type
        string
        Required

        Always auto.

        • auto
          string
    • Static Chunking Strategy
      object
      Customize your own chunking strategy by setting chunk size and chunk overlap.
      • type
        string
        Required

        Always static.

        • static
          string
      • static
        object
        Required
        • max_chunk_size_tokens
          integer
          Required

          The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096.

        • chunk_overlap_tokens
          integer
          Required

          The number of tokens that overlap between chunks. The default value is 400.

          Note that the overlap must not exceed half of max_chunk_size_tokens.

  • attributes
    object or null
    Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters, booleans, or numbers.

Response

Example request
1
curl https://api.openai.com/v1/vector_stores/vs_abc123/files \
2
-H "Authorization: Bearer $OPENAI_API_KEY" \
3
-H "Content-Type: application/json" \
4
-H "OpenAI-Beta: assistants=v2" \
5
-d '{
6
"file_id": "file-abc123"
7
}'
Example response
1
{
2
"id": "file-abc123",
3
"object": "vector_store.file",
4
"created_at": 1699061776,
5
"usage_bytes": 1234,
6
"vector_store_id": "vs_abcd",
7
"status": "completed",
8
"last_error": null
9
}
Built with