Chroma Query and Similarity Search API

Run nearest-neighbor vector similarity search over a collection with query embeddings, plus metadata (`where`) and full-text (`where_document`) filters, returning the closest records with configurable included fields (distances, documents, embeddings, metadatas, uris).

OpenAPI Specification

chroma-db-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: Chroma Server API (v2)
  description: >-
    Chroma is an open-source, AI-native vector (embedding) database for LLM, RAG,
    and semantic-search applications. This OpenAPI describes Chroma's HTTP/REST v2
    API, which is the same interface used by the Python, JavaScript/TypeScript,
    Rust, and other client libraries. The API is organized around a multi-tenancy
    hierarchy: tenants contain databases, databases contain collections, and
    collections contain records (embeddings with documents, metadata, and URIs).
    The core write and read operations are add, upsert, update, get, query
    (nearest-neighbor similarity search), and delete.

    ENDPOINTS MODELED: Path structure and the query-collection contract are
    grounded in the official Chroma reference docs (docs.trychroma.com) and the
    chroma-core sources. The exact request/response JSON SCHEMAS in this document
    are MODELED by API Evangelist from the documented client behavior and may
    differ in field-level detail from Chroma's own generated openapi.json served
    at `/openapi.json` on a running server. Treat schemas as representative, not
    authoritative; verify against your server's `/openapi.json`.
  version: '2.0'
  contact:
    name: Chroma
    url: https://www.trychroma.com
  license:
    name: Apache 2.0
    url: https://github.com/chroma-core/chroma/blob/main/LICENSE
servers:
  - url: https://api.trychroma.com
    description: Chroma Cloud (managed, serverless)
  - url: http://localhost:8000
    description: Local development / self-hosted Chroma server (default port 8000)
security:
  - chromaToken: []
tags:
  - name: System
    description: Server health, version, and pre-flight operational endpoints.
  - name: Tenants
    description: Top-level isolation boundary that owns databases.
  - name: Databases
    description: Logical grouping of collections within a tenant.
  - name: Collections
    description: Named vector stores holding embeddings and metadata.
  - name: Records
    description: Embeddings (with documents, metadata, URIs) inside a collection.
  - name: Query
    description: Nearest-neighbor vector similarity search over a collection.
paths:
  /api/v2/heartbeat:
    get:
      operationId: heartbeat
      tags:
        - System
      summary: Heartbeat
      description: Returns the current server time in nanoseconds; used as a liveness check.
      security: []
      responses:
        '200':
          description: Server heartbeat.
          content:
            application/json:
              schema:
                type: object
                properties:
                  'nanosecond heartbeat':
                    type: integer
                    format: int64
  /api/v2/healthcheck:
    get:
      operationId: healthcheck
      tags:
        - System
      summary: Health check
      description: Returns the health status of the server.
      security: []
      responses:
        '200':
          description: Health status.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
  /api/v2/version:
    get:
      operationId: version
      tags:
        - System
      summary: Get server version
      description: Returns the Chroma server version string.
      security: []
      responses:
        '200':
          description: Version string.
          content:
            application/json:
              schema:
                type: string
  /api/v2/pre-flight-checks:
    get:
      operationId: preFlightChecks
      tags:
        - System
      summary: Pre-flight checks
      description: >-
        Returns server limits and configuration used by clients before issuing
        requests, such as the maximum batch size.
      responses:
        '200':
          description: Pre-flight configuration.
          content:
            application/json:
              schema:
                type: object
                properties:
                  max_batch_size:
                    type: integer
                additionalProperties: true
  /api/v2/reset:
    post:
      operationId: reset
      tags:
        - System
      summary: Reset the database
      description: >-
        Deletes all data in the server. Only available on self-hosted deployments
        when ALLOW_RESET is explicitly enabled; not available on Chroma Cloud.
      responses:
        '200':
          description: Reset result.
          content:
            application/json:
              schema:
                type: boolean
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants:
    post:
      operationId: createTenant
      tags:
        - Tenants
      summary: Create a tenant
      description: Creates a new tenant, the top-level isolation boundary for databases.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTenant'
      responses:
        '200':
          description: The created tenant.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tenant'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}:
    parameters:
      - $ref: '#/components/parameters/Tenant'
    get:
      operationId: getTenant
      tags:
        - Tenants
      summary: Get a tenant
      description: Retrieves a tenant by name.
      responses:
        '200':
          description: The requested tenant.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Tenant'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /api/v2/tenants/{tenant}/databases:
    parameters:
      - $ref: '#/components/parameters/Tenant'
    get:
      operationId: listDatabases
      tags:
        - Databases
      summary: List databases
      description: Lists the databases within a tenant.
      parameters:
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/Offset'
      responses:
        '200':
          description: A list of databases.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Database'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createDatabase
      tags:
        - Databases
      summary: Create a database
      description: Creates a new database within a tenant.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateDatabase'
      responses:
        '200':
          description: The created database.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Database'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
    get:
      operationId: getDatabase
      tags:
        - Databases
      summary: Get a database
      description: Retrieves a database by name within a tenant.
      responses:
        '200':
          description: The requested database.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Database'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      operationId: deleteDatabase
      tags:
        - Databases
      summary: Delete a database
      description: Deletes a database and all collections within it.
      responses:
        '200':
          description: Deletion result.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /api/v2/tenants/{tenant}/databases/{database}/collections:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
    get:
      operationId: listCollections
      tags:
        - Collections
      summary: List collections
      description: Lists collections in a database, with optional pagination.
      parameters:
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/Offset'
      responses:
        '200':
          description: A list of collections.
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Collection'
        '401':
          $ref: '#/components/responses/Unauthorized'
    post:
      operationId: createCollection
      tags:
        - Collections
      summary: Create a collection
      description: >-
        Creates a new collection in a database. A collection has a name, optional
        metadata, an index configuration, and a distance metric.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCollection'
      responses:
        '200':
          description: The created collection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Collection'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}/collections_count:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
    get:
      operationId: countCollections
      tags:
        - Collections
      summary: Count collections
      description: Returns the number of collections in a database.
      responses:
        '200':
          description: Collection count.
          content:
            application/json:
              schema:
                type: integer
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    get:
      operationId: getCollection
      tags:
        - Collections
      summary: Get a collection
      description: Retrieves a collection by its ID.
      responses:
        '200':
          description: The requested collection.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Collection'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    put:
      operationId: updateCollection
      tags:
        - Collections
      summary: Update a collection
      description: Updates a collection's name, metadata, or index configuration.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCollection'
      responses:
        '200':
          description: Update result.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
    delete:
      operationId: deleteCollection
      tags:
        - Collections
      summary: Delete a collection
      description: Deletes a collection and all of its records.
      responses:
        '200':
          description: Deletion result.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/count:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    get:
      operationId: countRecords
      tags:
        - Records
      summary: Count records
      description: Returns the number of records (embeddings) in a collection.
      responses:
        '200':
          description: Record count.
          content:
            application/json:
              schema:
                type: integer
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/add:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    post:
      operationId: addRecords
      tags:
        - Records
      summary: Add records
      description: >-
        Adds records to a collection. Each record has an id and, optionally, an
        embedding, document, metadata, and URI. If embeddings are omitted, the
        collection's embedding function generates them from documents.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddRecords'
      responses:
        '201':
          description: Records added.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/upsert:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    post:
      operationId: upsertRecords
      tags:
        - Records
      summary: Upsert records
      description: Inserts new records or updates existing records matched by id.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddRecords'
      responses:
        '200':
          description: Records upserted.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/update:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    post:
      operationId: updateRecords
      tags:
        - Records
      summary: Update records
      description: Updates the embeddings, documents, metadata, or URIs of existing records by id.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddRecords'
      responses:
        '200':
          description: Records updated.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/get:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    post:
      operationId: getRecords
      tags:
        - Records
      summary: Get records
      description: >-
        Retrieves records by id and/or by metadata (`where`) and document
        (`where_document`) filters, returning the included fields.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetRecords'
      responses:
        '200':
          description: Matching records.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/delete:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    post:
      operationId: deleteRecords
      tags:
        - Records
      summary: Delete records
      description: Deletes records by id and/or by metadata and document filters.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteRecords'
      responses:
        '200':
          description: Records deleted.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '401':
          $ref: '#/components/responses/Unauthorized'
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/query:
    parameters:
      - $ref: '#/components/parameters/Tenant'
      - $ref: '#/components/parameters/Database'
      - $ref: '#/components/parameters/CollectionId'
    post:
      operationId: queryCollection
      tags:
        - Query
      summary: Query a collection (similarity search)
      description: >-
        Runs nearest-neighbor vector similarity search over a collection. Supply
        one or more query embeddings and, optionally, metadata (`where`) and
        full-text (`where_document`) filters. Returns the closest records with the
        requested included fields.
      parameters:
        - $ref: '#/components/parameters/Limit'
        - $ref: '#/components/parameters/Offset'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryRequest'
      responses:
        '200':
          description: Query results.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryResult'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  securitySchemes:
    chromaToken:
      type: apiKey
      in: header
      name: x-chroma-token
      description: >-
        Chroma Cloud API key passed in the `x-chroma-token` header. Self-hosted
        servers can be run open (no auth) or configured with static-token or
        basic authentication; Chroma Cloud always requires a token.
  parameters:
    Tenant:
      name: tenant
      in: path
      required: true
      description: The tenant name or UUID.
      schema:
        type: string
    Database:
      name: database
      in: path
      required: true
      description: The database name.
      schema:
        type: string
    CollectionId:
      name: collection_id
      in: path
      required: true
      description: The collection UUID.
      schema:
        type: string
    Limit:
      name: limit
      in: query
      required: false
      description: Maximum number of items to return.
      schema:
        type: integer
        minimum: 1
    Offset:
      name: offset
      in: query
      required: false
      description: Number of items to skip for pagination.
      schema:
        type: integer
        minimum: 0
  responses:
    Unauthorized:
      description: Missing or invalid API token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: The requested resource was not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    Tenant:
      type: object
      properties:
        name:
          type: string
    CreateTenant:
      type: object
      required:
        - name
      properties:
        name:
          type: string
    Database:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        tenant:
          type: string
    CreateDatabase:
      type: object
      required:
        - name
      properties:
        name:
          type: string
    Collection:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        metadata:
          type: object
          additionalProperties: true
        dimension:
          type: integer
          nullable: true
        tenant:
          type: string
        database:
          type: string
        configuration_json:
          type: object
          additionalProperties: true
    CreateCollection:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          description: Collection name (S3-bucket-style naming rules apply).
        metadata:
          type: object
          additionalProperties: true
        configuration:
          type: object
          description: Index configuration, including the distance metric (e.g. hnsw space cosine, l2, or ip).
          additionalProperties: true
        get_or_create:
          type: boolean
          description: If true, returns the existing collection when one with the same name exists.
    UpdateCollection:
      type: object
      properties:
        new_name:
          type: string
        new_metadata:
          type: object
          additionalProperties: true
        new_configuration:
          type: object
          additionalProperties: true
    AddRecords:
      type: object
      required:
        - ids
      properties:
        ids:
          type: array
          items:
            type: string
        embeddings:
          type: array
          description: One embedding vector per id. Optional when documents are supplied and the collection has an embedding function.
          items:
            type: array
            items:
              type: number
              format: float
        documents:
          type: array
          items:
            type: string
            nullable: true
        metadatas:
          type: array
          items:
            type: object
            nullable: true
            additionalProperties: true
        uris:
          type: array
          items:
            type: string
            nullable: true
    GetRecords:
      type: object
      properties:
        ids:
          type: array
          items:
            type: string
        where:
          type: object
          description: Metadata filter clause.
          additionalProperties: true
        where_document:
          type: object
          description: Full-text / document filter clause.
          additionalProperties: true
        limit:
          type: integer
        offset:
          type: integer
        include:
          $ref: '#/components/schemas/Include'
    GetResult:
      type: object
      properties:
        ids:
          type: array
          items:
            type: string
        documents:
          type: array
          items:
            type: string
            nullable: true
        metadatas:
          type: array
          items:
            type: object
            nullable: true
            additionalProperties: true
        embeddings:
          type: array
          items:
            type: array
            items:
              type: number
              format: float
        uris:
          type: array
          items:
            type: string
            nullable: true
    DeleteRecords:
      type: object
      properties:
        ids:
          type: array
          items:
            type: string
        where:
          type: object
          additionalProperties: true
        where_document:
          type: object
          additionalProperties: true
    QueryRequest:
      type: object
      required:
        - query_embeddings
      properties:
        query_embeddings:
          type: array
          description: One or more query embedding vectors.
          items:
            type: array
            items:
              type: number
              format: float
        n_results:
          type: integer
          description: Number of nearest neighbors to return per query embedding.
          default: 10
        ids:
          type: array
          description: Optional subset of record ids to restrict the search to.
          items:
            type: string
        where:
          type: object
          description: Metadata filter clause.
          additionalProperties: true
        where_document:
          type: object
          description: Full-text / document filter clause.
          additionalProperties: true
        include:
          $ref: '#/components/schemas/Include'
    Include:
      type: array
      description: Which fields to return in results.
      items:
        type: string
        enum:
          - distances
          - documents
          - embeddings
          - metadatas
          - uris
    QueryResult:
      type: object
      description: >-
        Results are returned as arrays-of-arrays, one inner array per query
        embedding.
      properties:
        ids:
          type: array
          items:
            type: array
            items:
              type: string
        distances:
          type: array
          items:
            type: array
            items:
              type: number
              format: float
        documents:
          type: array
          items:
            type: array
            items:
              type: string
              nullable: true
        metadatas:
          type: array
          items:
            type: array
            items:
              type: object
              nullable: true
              additionalProperties: true
        embeddings:
          type: array
          items:
            type: array
            items:
              type: array
              items:
                type: number
                format: float
        uris:
          type: array
          items:
            type: array
            items:
              type: string
              nullable: true