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
- Read the response body embedded in the message to identify the exact endpoint error
- Verify FUNCTIONNETWORK_API_KEY is set/valid with a single-input curl test against the embeddings endpoint
- Confirm the configured embedding model name is valid for FunctionNetwork
- 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
- Validate the API key with a minimal embed at startup
- Batch inputs within provider limits
- Trim env var whitespace
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
- await resp.text()
- Failed to parse config.json: ${e}
- MCP Connection ${serverId} not found
- Failed to fetch messages: ${response.statusText}
- No workspace directories found
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/c8530896588df094.
Report an issue: GitHub.