{"record":{"id":"7d7beaa9a4b307a7","repo":"continuedev/continue","slug":"await-resp-text","errorCode":null,"errorMessage":"await resp.text()","messagePattern":"await resp\\.text\\(\\)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/llm/llms/Cohere.ts","lineNumber":300,"sourceCode":"\n  protected async _embed(chunks: string[]): Promise<number[][]> {\n    const resp = await this.fetch(new URL(\"embed\", this.apiBase), {\n      method: \"POST\",\n      body: JSON.stringify({\n        texts: chunks,\n        model: this.model,\n        input_type: \"search_document\",\n        embedding_types: [\"float\"],\n        truncate: \"END\",\n      }),\n      headers: {\n        Authorization: `Bearer ${this.apiKey}`,\n        \"Content-Type\": \"application/json\",\n      },\n    });\n\n    if (!resp.ok) {\n      throw new Error(await resp.text());\n    }\n\n    const data = (await resp.json()) as any;\n    return data.embeddings.float;\n  }\n\n  async rerank(query: string, chunks: Chunk[]): Promise<number[]> {\n    const resp = await this.fetch(new URL(\"rerank\", this.apiBase), {\n      method: \"POST\",\n      headers: {\n        Authorization: `Bearer ${this.apiKey}`,\n        \"Content-Type\": \"application/json\",\n      },\n      body: JSON.stringify({\n        model: this.model,\n        query,\n        documents: chunks.map((chunk) => chunk.content),\n      }),","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/Cohere.ts#L282-L318","documentation":"Thrown by Cohere embedder._embed when the POST to the Cohere embeddings endpoint returns a non-2xx status; the raw response body text becomes the error message. The body typically contains Cohere's JSON error describing the actual failure (invalid API key, invalid model, too many inputs).","triggerScenarios":"Calling embed() with a bad/expired Cohere API key (401), using an embedding model name your key cannot access (404/400), exceeding batch size limits (inputs array too large, 400), or a rate-limited key (429).","commonSituations":"Wrong COHERE_API_KEY env var, using embed-english-v3.0 vs embed-v4.0 model name mismatches, embedding hundreds of chunks in one call exceeding the 96-input batch limit.","solutions":["Read the response body in the message: it names the exact Cohere error (invalid api token, model not found, etc.)","Verify COHERE_API_KEY is set and valid with a curl test against https://api.cohere.com/v2/embed","Confirm the embedding model name exists on your Cohere account/tier","Batch inputs to <=96 per call and chunk oversized text"],"exampleFix":"// before\nconst embeddings = await embedder.embed(allTexts);\n// after\nconst embeddings = [];\nfor (let i = 0; i < allTexts.length; i += 96) {\n  embeddings.push(...await embedder.embed(allTexts.slice(i, i + 96)));\n}","handlingStrategy":"validation","validationCode":"if (!process.env.COHERE_API_KEY) throw new Error('COHERE_API_KEY missing');\nconst inputs = texts.slice(0, 96); // Cohere batch limit","typeGuard":"function isCohereEmbedError(e: unknown): e is Error {\n  return e instanceof Error && /invalid|embed|token|limit/i.test(e.message) && !(e instanceof TypeError);\n}","tryCatchPattern":"try {\n  await embedder.embed(batch);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('invalid api token')) throw new ConfigError('Bad COHERE_API_KEY');\n  throw e;\n}","preventionTips":["Validate the API key at startup with a 1-token embed call","Chunk inputs to <=96 per request","Trim env var whitespace"],"tags":["cohere","embeddings","api-key","batching"],"backgroundTag":"embedding-api-error","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}