chroma-core/chroma · error · ChromaValueError

Missing API key. Please provide it to the CloudClient…

Error message

Missing API key. Please provide it to the CloudClient constructor or set your CHROMA_API_KEY environment variable

What it means

CloudClient constructor guard: neither an apiKey argument nor the CHROMA_API_KEY environment variable was available, so the client cannot authenticate to Chroma Cloud and fails fast instead of on the first request.

Solutions

  1. Pass apiKey to the CloudClient constructor
  2. Export CHROMA_API_KEY in the environment before constructing
  3. Retrieve the key from the Chroma Cloud console and store it securely
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at clients/new-js/packages/chromadb/src/cloud-client.ts:33 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/b6cac3300283c7b9. Report an issue: GitHub.

Appendix: source

Thrown at clients/new-js/packages/chromadb/src/cloud-client.ts:33

  constructor(
    args: Partial<{
      /** API key for authentication (or set CHROMA_API_KEY env var) */
      apiKey?: string;
      /** Host address of the Chroma cloud server. Defaults to 'api.trychroma.com' */
      host?: string;
      /** Port number of the Chroma cloud server. Defaults to 443 */
      port?: number;
      /** Tenant name for multi-tenant deployments */
      tenant?: string;
      /** Database name to connect to */
      database?: string;
      /** Additional fetch options for HTTP requests */
      fetchOptions?: RequestInit;
    }> = {},
  ) {
    const apiKey = args.apiKey || process.env.CHROMA_API_KEY;
    if (!apiKey) {
      throw new ChromaValueError(
        "Missing API key. Please provide it to the CloudClient constructor or set your CHROMA_API_KEY environment variable",
      );
    }

    const tenant = args.tenant || process.env.CHROMA_TENANT;
    const database = args.database || process.env.CHROMA_DATABASE;

    super({
      host: args.host || "api.trychroma.com",
      port: args.port || 443,
      ssl: true,
      tenant,
      database,
      headers: { "x-chroma-token": apiKey },
      fetchOptions: args.fetchOptions,
    });

    // Override from ChromaClient construction in case undefined. This will trigger auto-resolution in the "path" function

View on GitHub (pinned to aecdd12c8a)