earendil-works/pi · error

llama.cpp returned HTTP

Error message

llama.cpp returned HTTP ${response.status}

What it means

HTTP error surface in LlamaClient.request: the llama.cpp server responded with a non-2xx status to a REST call (load/unload/list/download). The server's error payload message is preferred; this generic status text is the fallback when the body has none.

Solutions

  1. Check that the llama.cpp server is running and reachable at the configured URL
  2. For 404s, verify llama.cpp is built with router-mode server support
  3. Inspect the server logs for the failing request and retry after fixing
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at packages/coding-agent/src/extensions/llama/client.ts:178 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/6b0cf6c0f569441a. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/extensions/llama/client.ts:178

	constructor(serverUrl: string, apiKey?: string) {
		this.serverUrl = normalizeLlamaServerUrl(serverUrl);
		this.apiKey = apiKey;
	}

	private async request(path: string, init: RequestInit = {}): Promise<unknown> {
		const headers = new Headers(init.headers);
		if (init.body !== undefined) headers.set("Content-Type", "application/json");
		if (this.apiKey) headers.set("Authorization", `Bearer ${this.apiKey}`);
		const timeout = AbortSignal.timeout(15_000);
		const signal = init.signal ? AbortSignal.any([init.signal, timeout]) : timeout;
		const response = await fetch(`${this.serverUrl}${path}`, { ...init, headers, signal });
		let payload: unknown;
		try {
			payload = await response.json();
		} catch {
			payload = undefined;
		}
		if (!response.ok) throw new Error(errorMessage(payload, `llama.cpp returned HTTP ${response.status}`));
		return payload;
	}

	async list(options: { reload?: boolean; signal?: AbortSignal } = {}): Promise<LlamaModelInfo[]> {
		const payload = await this.request(`/models${options.reload ? "?reload=1" : ""}`, { signal: options.signal });
		if (typeof payload !== "object" || payload === null || !Array.isArray((payload as { data?: unknown }).data)) {
			throw new Error("llama.cpp returned an invalid model catalog");
		}
		const data = (payload as { data: unknown[] }).data;
		if (!data.every(isModelInfo)) throw new Error("Server is not running in llama.cpp router mode");
		return data;
	}

	async load(model: string, signal?: AbortSignal): Promise<void> {
		await this.request("/models/load", { method: "POST", body: JSON.stringify({ model }), signal });
	}

	async unload(model: string, signal?: AbortSignal): Promise<void> {

View on GitHub (pinned to 4af9d21d3b)