{"record":{"id":"71e8cac4ae380fbf","repo":"chroma-core/chroma","slug":"error-calling-chroma-embedding-api-error-messag","errorCode":null,"errorMessage":"Error calling Chroma Embedding API: ${error.message}","messagePattern":"Error calling Chroma Embedding API: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clients/new-js/packages/ai-embeddings/chroma-cloud-qwen/src/index.ts","lineNumber":139,"sourceCode":"      texts,\n      instructions: instruction,\n    };\n\n    try {\n      const response = await fetch(this.url, {\n        method: \"POST\",\n        headers: this.headers,\n        body: JSON.stringify(snakeCase(body)),\n      });\n\n      const data = (await response.json()) as ChromaCloudEmbeddingsResponse;\n      if (!data || !data.embeddings) {\n        throw new Error(\"Failed to generate embeddings.\");\n      }\n      return data.embeddings;\n    } catch (error) {\n      if (error instanceof Error) {\n        throw new Error(`Error calling Chroma Embedding API: ${error.message}`);\n      } else {\n        throw new Error(`Error calling Chroma Embedding API: ${error}`);\n      }\n    }\n  }\n\n  public async generateForQueries(texts: string[]): Promise<number[][]> {\n    if (texts.length === 0) {\n      return [];\n    }\n\n    let instruction = \"\";\n    if (this.task && this.task in this.instructions) {\n      instruction =\n        this.instructions[this.task][ChromaCloudQwenEmbeddingTarget.QUERY];\n    }\n\n    const body: ChromaCloudEmbeddingRequest = {","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/clients/new-js/packages/ai-embeddings/chroma-cloud-qwen/src/index.ts#L121-L157","documentation":"Top-level error from ChromaCloudQwenEmbeddingFunction.generate(): any Error thrown inside the request block — fetch network failures, response.json() parse failures on non-JSON bodies (HTML error pages), or the inner \"Failed to generate embeddings.\" check — is caught and re-wrapped with the prefix \"Error calling Chroma Embedding API:\" plus the original message. Read the suffix to find the real cause: network errors mention fetch/ENOTFOUND, parse errors mention JSON, and the bare suffix \"Failed to generate embeddings.\" means the API answered with a JSON body lacking embeddings.","triggerScenarios":"fetch() rejects: DNS failure, connection refused, TLS errors, offline; response.json() rejects because a proxy/gateway returned HTML; the inner no-embeddings check fired (auth/model/request errors answered as JSON).","commonSituations":"Corporate proxies intercepting the embed URL; transient network drops during large batch embedding; misconfigured custom embed URL; expired or missing CHROMA_API_KEY causing JSON error bodies.","solutions":["Read the suffix after the colon: it names the underlying failure — fix that (network, key, or model).","For network causes, verify connectivity to the embed endpoint and proxy settings (HTTPS_PROXY).","For \"Failed to generate embeddings.\" suffix, fix the API key / model as per that error.","Add retry with backoff around generate() for transient network failures; batch texts so one retry does not re-embed everything."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async function embedWithRetry(ef: { generate(t: string[]): Promise<number[][]> }, texts: string[], tries = 3) {\n  for (let i = 1; i <= tries; i++) {\n    try {\n      return await ef.generate(texts);\n    } catch (e) {\n      const msg = (e as Error).message;\n      const transient = /fetch|network|ENOTFOUND|ECONN|timeout/i.test(msg);\n      if (i === tries || !transient) throw e;\n      await new Promise((r) => setTimeout(r, 2 ** i * 500));\n    }\n  }\n  throw new Error(\"unreachable\");\n}","preventionTips":["Classify by the suffix after 'Error calling Chroma Embedding API:' before deciding to retry.","Retry only transient network suffixes; fix key/model for missing-embeddings suffixes.","Batch texts and checkpoint progress so retries re-embed only the failed batch."],"tags":["embeddings","cloud-api","qwen","network","error-wrapping"],"backgroundTag":"embedding-api-request-failed","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}