continuedev/continue · error · Error

await resp.text()

Error message

await resp.text()

What it means

Thrown by the FunctionNetwork embedder._embed when the POST to the embeddings endpoint returns a non-2xx status; the raw response body text becomes the error message. The body carries FunctionNetwork's error payload identifying auth, model, or validation failures.

Source

Thrown at core/llm/llms/FunctionNetwork.ts:55

  public supportsPrefill(): boolean {
    return false;
  }

  protected async _embed(chunks: string[]): Promise<number[][]> {
    const resp = await this.fetch(new URL("embeddings", this.apiBase), {
      method: "POST",
      body: JSON.stringify({
        input: chunks,
        model: this.model,
      }),
      headers: {
        Authorization: `Bearer ${this.apiKey}`,
        "Content-Type": "application/json",
      },
    });

    if (!resp.ok) {
      throw new Error(await resp.text());
    }

    const data = (await resp.json()) as any;
    return data.data.map((result: { embedding: number[] }) => result.embedding);
  }
}

export default FunctionNetwork;

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Read the response body embedded in the message to identify the exact endpoint error
  2. Verify FUNCTIONNETWORK_API_KEY is set/valid with a single-input curl test against the embeddings endpoint
  3. Confirm the configured embedding model name is valid for FunctionNetwork
  4. Batch inputs within limits and add backoff for 429s
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.FUNCTIONNETWORK_API_KEY) throw new Error('FUNCTIONNETWORK_API_KEY missing');
const batch = texts.slice(0, 64); // stay within batch limits

Type guard

function isFunctionNetworkEmbedError(e: unknown): boolean {
  return e instanceof Error && !(e instanceof TypeError) && /embed|api|key|limit/i.test(e.message);
}

Try / catch

try { await embedder.embed(batch); }
catch (e) {
  if (e instanceof Error && /401|unauthorized|api key/i.test(e.message)) throw new ConfigError('Bad FUNCTIONNETWORK_API_KEY');
  throw e;
}

Prevention

When it happens

Trigger: Calling embed() with a missing/invalid FunctionNetwork API key (401), an embedding model name not offered by the endpoint (404/400), inputs array exceeding endpoint batch/token limits, or rate limiting (429).

Common situations: FUNCTIONNETWORK_API_KEY env var unset or with stray quotes, model slugs copied from OpenAI docs, bulk indexing hitting per-request input limits or QPS caps.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/c8530896588df094. Report an issue: GitHub.