Add a file to a vector store

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

For uploading multiple files to the same vector store, use the file batches endpoint to reduce request volume.

Request

POST

https://ai.api.cloud.yandex.net/v1/vector_stores/{vector_store_id}/files
        

Path parameters

Name

Description

vector_store_id

Type: string

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

Example: ``

Body

application/json
{
          "file_id": "example",
          "chunking_strategy": {
            "type": "auto"
          },
          "attributes": null
        }
        

Name

Description

file_id

Type: string

A File ID that the vector store should use.

Example: example

attributes

Type: VectorStoreFileAttributes

Default: null

Example
{}
        

chunking_strategy

Type: ChunkingStrategyRequestParam

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

Example
{
          "type": "auto"
        }
        

AutoChunkingStrategyRequestParam

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

Name

Description

type

Type: string

Always auto.

Const: auto

Example: example

Example
{
          "type": "auto"
        }
        

StaticChunkingStrategy

Name

Description

chunk_overlap_tokens

Type: integer

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.

max_chunk_size_tokens

Type: integer

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

Min value: 100

Max value: 4096

Example
{
          "max_chunk_size_tokens": 100,
          "chunk_overlap_tokens": 0
        }
        

StaticChunkingStrategyRequestParam

Customize your own chunking strategy by setting chunk size and chunk overlap.

Name

Description

static

Type: StaticChunkingStrategy

Example
{
          "max_chunk_size_tokens": 100,
          "chunk_overlap_tokens": 0
        }
        

type

Type: string

Always static.

Const: static

Example: example

Example
{
          "type": "static",
          "static": {
            "max_chunk_size_tokens": 100,
            "chunk_overlap_tokens": 0
          }
        }
        

ChunkingStrategyRequestParam

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

Type: object

One of 2 types
  • Auto Chunking Strategy

    Type: AutoChunkingStrategyRequestParam

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

    Example
    {
              "type": "auto"
            }
            
  • Static Chunking Strategy

    Type: StaticChunkingStrategyRequestParam

    Customize your own chunking strategy by setting chunk size and chunk overlap.

    Example
    {
              "type": "static",
              "static": {
                "max_chunk_size_tokens": 100,
                "chunk_overlap_tokens": 0
              }
            }
            
Example
{
          "type": "auto"
        }
        

VectorStoreFileAttributes

Any of 2 types
  • Type: object

    [additional]

    One of 3 types
    • Type: string

      Max length: 512

      Example: example

    • Type: number

    • Type: boolean

    Example: example

    Set of 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.

    Max properties: 16

    Example
    {}
            
  • Type: unknown

    Example: null

Default: null

Responses

200 OK

OK

Body

application/json
{
          "id": "example",
          "object": "vector_store.file",
          "usage_bytes": 0,
          "created_at": 0,
          "vector_store_id": "example",
          "status": "in_progress",
          "last_error": null
        }
        

Name

Description

created_at

Type: integer

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

id

Type: string

The identifier, which can be referenced in API endpoints.

Example: example

last_error

Any of 2 types
  • Type: object

    code

    Type: string

    One of server_error, unsupported_file, or invalid_file.

    Enum: server_error, unsupported_file, invalid_file

    message

    Type: string

    A human-readable description of the error.

    Example: example

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

    Example
    {
              "code": "server_error",
              "message": "example"
            }
            
  • Type: unknown

    Example: null

Default: null

object

Type: string

The object type, which is always vector_store.file.

Const: vector_store.file

Example: example

status

Type: string

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.

Enum: in_progress, completed, cancelled, failed

usage_bytes

Type: integer

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

vector_store_id

Type: string

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

Example: example

Предыдущая
Следующая