---
title: "Create a vector store file by attaching a [File](/docs/api-reference/files) to a [vector store](/docs/api-reference/vector-stores/object)."
url: "https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1/operations/createVectorStoreFile"
---

> Full API specification: https://kongair.terwilligar.com/apis/openai-api-2-3-0/versions/ea92d048-c746-4ead-a6a8-da28d93137d1.md

# Create a vector store file by attaching a [File](/docs/api-reference/files) to a [vector store](/docs/api-reference/vector-stores/object).

`POST` `/vector_stores/{vector_store_id}/files`

Operation ID: `createVectorStoreFile`

## Path parameters

- `vector_store_id` (string, required) - The ID of the vector store for which to create a File.

## Request body (required)

Content types: `application/json`

## Responses

- `200` - OK

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: OpenAI API
  version: 2.3.0
servers:
  - url: https://api.openai.com/v1
paths:
  /vector_stores/{vector_store_id}/files:
    post:
      operationId: createVectorStoreFile
      tags:
        - Vector stores
      summary: Create a vector store file by attaching a
        [File](/docs/api-reference/files) to a [vector
        store](/docs/api-reference/vector-stores/object).
      parameters:
        - in: path
          name: vector_store_id
          required: true
          schema:
            type: string
            example: vs_abc123
          description: |
            The ID of the vector store for which to create a File.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateVectorStoreFileRequest"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/VectorStoreFileObject"
      x-oaiMeta:
        name: Create vector store file
        group: vector_stores
        beta: true
        returns: A [vector store
          file](/docs/api-reference/vector-stores-files/file-object) object.
        examples:
          request:
            curl: |
              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"
                  }'
            python: |
              from openai import OpenAI
              client = OpenAI()

              vector_store_file = client.beta.vector_stores.files.create(
                vector_store_id="vs_abc123",
                file_id="file-abc123"
              )
              print(vector_store_file)
            node.js: >
              import OpenAI from "openai";

              const openai = new OpenAI();


              async function main() {
                const myVectorStoreFile = await openai.beta.vectorStores.files.create(
                  "vs_abc123",
                  {
                    file_id: "file-abc123"
                  }
                );
                console.log(myVectorStoreFile);
              }


              main();
          response: |
            {
              "id": "file-abc123",
              "object": "vector_store.file",
              "created_at": 1699061776,
              "usage_bytes": 1234,
              "vector_store_id": "vs_abcd",
              "status": "completed",
              "last_error": null
            }
security:
  - ApiKeyAuth: []
components:
  schemas:
    CreateVectorStoreFileRequest:
      type: object
      additionalProperties: false
      properties:
        file_id:
          description: A [File](/docs/api-reference/files) ID that the vector store should
            use. Useful for tools like `file_search` that can access files.
          type: string
        chunking_strategy:
          $ref: "#/components/schemas/ChunkingStrategyRequestParam"
      required:
        - file_id
    VectorStoreFileObject:
      type: object
      title: Vector store files
      description: A list of files attached to a vector store.
      properties:
        id:
          description: The identifier, which can be referenced in API endpoints.
          type: string
        object:
          description: The object type, which is always `vector_store.file`.
          type: string
          enum:
            - vector_store.file
          x-stainless-const: true
        usage_bytes:
          description: The total vector store usage in bytes. Note that this may be
            different from the original file size.
          type: integer
        created_at:
          description: The Unix timestamp (in seconds) for when the vector store file was
            created.
          type: integer
        vector_store_id:
          description: The ID of the [vector
            store](/docs/api-reference/vector-stores/object) that the
            [File](/docs/api-reference/files) is attached to.
          type: string
        status:
          description: 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.
          type: string
          enum:
            - in_progress
            - completed
            - cancelled
            - failed
        last_error:
          type: object
          description: The last error associated with this vector store file. Will be
            `null` if there are no errors.
          nullable: true
          properties:
            code:
              type: string
              description: One of `server_error` or `rate_limit_exceeded`.
              enum:
                - server_error
                - unsupported_file
                - invalid_file
            message:
              type: string
              description: A human-readable description of the error.
          required:
            - code
            - message
        chunking_strategy:
          type: object
          description: The strategy used to chunk the file.
          oneOf:
            - $ref: "#/components/schemas/StaticChunkingStrategyResponseParam"
            - $ref: "#/components/schemas/OtherChunkingStrategyResponseParam"
          x-oaiExpandable: true
      required:
        - id
        - object
        - usage_bytes
        - created_at
        - vector_store_id
        - status
        - last_error
      x-oaiMeta:
        name: The vector store file object
        beta: true
        example: |
          {
            "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
              }
            }
          }
    ChunkingStrategyRequestParam:
      type: object
      description: The chunking strategy used to chunk the file(s). If not set, will
        use the `auto` strategy.
      oneOf:
        - $ref: "#/components/schemas/AutoChunkingStrategyRequestParam"
        - $ref: "#/components/schemas/StaticChunkingStrategyRequestParam"
      x-oaiExpandable: true
    StaticChunkingStrategyResponseParam:
      type: object
      title: Static Chunking Strategy
      additionalProperties: false
      properties:
        type:
          type: string
          description: Always `static`.
          enum:
            - static
          x-stainless-const: true
        static:
          $ref: "#/components/schemas/StaticChunkingStrategy"
      required:
        - type
        - static
    OtherChunkingStrategyResponseParam:
      type: object
      title: Other Chunking Strategy
      description: This is returned when the chunking strategy is unknown. Typically,
        this is because the file was indexed before the `chunking_strategy`
        concept was introduced in the API.
      additionalProperties: false
      properties:
        type:
          type: string
          description: Always `other`.
          enum:
            - other
          x-stainless-const: true
      required:
        - type
    AutoChunkingStrategyRequestParam:
      type: object
      title: Auto Chunking Strategy
      description: The default strategy. This strategy currently uses a
        `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
      additionalProperties: false
      properties:
        type:
          type: string
          description: Always `auto`.
          enum:
            - auto
          x-stainless-const: true
      required:
        - type
    StaticChunkingStrategyRequestParam:
      type: object
      title: Static Chunking Strategy
      additionalProperties: false
      properties:
        type:
          type: string
          description: Always `static`.
          enum:
            - static
          x-stainless-const: true
        static:
          $ref: "#/components/schemas/StaticChunkingStrategy"
      required:
        - type
        - static
    StaticChunkingStrategy:
      type: object
      additionalProperties: false
      properties:
        max_chunk_size_tokens:
          type: integer
          minimum: 100
          maximum: 4096
          description: 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:
          type: integer
          description: >
            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`.
      required:
        - max_chunk_size_tokens
        - chunk_overlap_tokens
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
```
