> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vectoraidb.actian.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create collection

> Create a new collection with a specified vector configuration. You must provide the vector dimension and distance metric. Supported distance metrics are `Cosine`, `Euclid`, `Dot`, and `Manhattan`.



## OpenAPI

````yaml put /collections/{collection_name}
openapi: 3.0.3
info:
  title: Actian VectorAI DB - Collections API
  description: Collection management API for Actian VectorAI DB.
  version: 1.0.0
  contact:
    name: Actian Corporation
    url: https://www.actian.com
servers:
  - url: http://localhost:6573
    description: Local development server (REST API)
  - url: https://api.vectorai.actian.com
    description: Production server
security:
  - bearerAuth: []
tags:
  - name: Collections
    description: Collection lifecycle management operations
paths:
  /collections/{collection_name}:
    put:
      tags:
        - Collections
      summary: Create collection
      description: >-
        Create a new collection with a specified vector configuration. You must
        provide the vector dimension and distance metric. Supported distance
        metrics are `Cosine`, `Euclid`, `Dot`, and `Manhattan`.
      operationId: create_collection
      parameters:
        - name: collection_name
          in: path
          required: true
          description: The name of the new collection.
          schema:
            type: string
            example: my_collection
        - name: timeout
          in: query
          required: false
          description: The maximum time to wait for the operation to complete, in seconds.
          schema:
            type: integer
            example: 30
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - vectors
              properties:
                vectors:
                  type: object
                  required:
                    - size
                    - distance
                  properties:
                    size:
                      type: integer
                      description: The number of dimensions for vectors in this collection.
                      example: 128
                    distance:
                      type: string
                      enum:
                        - Cosine
                        - Euclid
                        - Dot
                        - Manhattan
                      example: Cosine
                hnsw_config:
                  type: object
                  properties:
                    m:
                      type: integer
                      description: >-
                        The number of bidirectional links per element in the
                        HNSW graph.
                      example: 16
                    ef_construct:
                      type: integer
                      description: >-
                        The size of the dynamic candidate list during index
                        construction. Higher values improve index quality at the
                        cost of slower builds.
                      example: 200
                    ef_search:
                      type: integer
                      description: >-
                        The size of the dynamic candidate list during search.
                        Higher values improve recall at the cost of latency.
                      example: 50
            examples:
              basic:
                summary: Basic collection
                value:
                  vectors:
                    size: 128
                    distance: Cosine
              with_hnsw:
                summary: With HNSW config
                value:
                  vectors:
                    size: 256
                    distance: Euclid
                  hnsw_config:
                    m: 32
                    ef_construct: 200
                    ef_search: 100
      responses:
        '200':
          description: Collection created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  usage:
                    type: object
                    properties:
                      hardware:
                        type: object
                        nullable: true
                        description: >-
                          Hardware resource counters for the operation,
                          including CPU, payload I/O, payload index I/O, and
                          vector I/O metrics.
                  time:
                    type: number
                    format: double
                    example: 0.06091602
                    description: Time spent to process this request, in seconds.
                  status:
                    type: string
                    example: ok
                    description: Operation status.
                  result:
                    type: boolean
                    example: true
                    description: Whether the operation completed successfully.
              examples:
                success:
                  value:
                    usage:
                      hardware: null
                    time: 0.06091602
                    status: ok
                    result: true
      x-codeSamples:
        - lang: Python
          label: Create basic collection
          source: >
            from actian_vectorai_client import VectorAIClient, VectorParams,
            Distance


            with VectorAIClient("localhost:6574") as client:
                # Create a basic collection
                client.collections.create(
                    "my_collection",
                    vectors_config=VectorParams(size=128, distance=Distance.Cosine)
                )
                print("✓ Collection created")
        - lang: Python
          label: Create with HNSW config
          source: |
            from actian_vectorai_client import (
                VectorAIClient,
                VectorParams,
                Distance,
                HnswConfigDiff
            )

            with VectorAIClient("localhost:6574") as client:
                # Create collection with custom HNSW parameters
                client.collections.create(
                    "my_collection",
                    vectors_config=VectorParams(size=256, distance=Distance.Euclid),
                    hnsw_config=HnswConfigDiff(m=32, ef_construct=200)
                )
                print("✓ Collection created with custom HNSW config")
        - lang: JavaScript
          label: Create basic collection
          source: |
            import { VectorAIClient } from '@actian/vectorai-client';

            const client = new VectorAIClient('localhost:6574');

            await client.collections.create('my_collection', {
                dimension: 4,
                distanceMetric: 'COSINE',
            });
            console.log('Created collection');

            client.close();
        - lang: JavaScript
          label: Create with HNSW config
          source: |
            import { VectorAIClient } from '@actian/vectorai-client';

            const client = new VectorAIClient('localhost:6574');

            await client.collections.create('my_collection', {
                dimension: 4,
                distanceMetric: 'COSINE',
                hnswConfig: { m: 32, efConstruct: 200 },
            });
            console.log('Created collection with custom HNSW');

            client.close();
        - lang: cURL
          label: Create collection
          source: |
            curl -X PUT "http://localhost:6573/collections/my_collection" \
              -H "Content-Type: application/json" \
              -H 'Authorization: Bearer <admin-jwt-or-access-token>' \
              -d '{
                "vectors": {
                  "size": 128,
                  "distance": "Cosine"
                }
              }'
        - lang: cURL
          label: Create with HNSW config
          source: |
            curl -X PUT "http://localhost:6573/collections/my_hnsw_collection" \
              -H "Content-Type: application/json" \
              -H 'Authorization: Bearer <admin-jwt-or-access-token>' \
              -d '{
                "vectors": {
                  "size": 256,
                  "distance": "Euclid"
                },
                "hnsw_config": {
                  "m": 32,
                  "ef_construct": 200,
                  "ef_search": 100
                }
              }'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Admin JWT or access token for authenticating requests to VectorAI DB.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.