earendil-works/pi · error

Server URL must use http or https

Error message

Server URL must use http or https

What it means

URL validation in normalizeLlamaServerUrl: the configured llama.cpp server URL parsed successfully but its scheme is neither http nor https (e.g. file:, ws:, or a missing scheme). The client only speaks plain HTTP to the llama.cpp server.

Solutions

  1. Configure the server URL with an http:// or https:// prefix
  2. Include the port, e.g. http://127.0.0.1:8080
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/extensions/llama/client.ts:144 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/a540431826a34781. Report an issue: GitHub.

Appendix: source

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

	};
}

export function formatBytes(bytes: number): string {
	if (bytes < 1024) return `${bytes} B`;
	const units = ["KiB", "MiB", "GiB", "TiB"];
	let value = bytes / 1024;
	let unit = units[0]!;
	for (let index = 1; index < units.length && value >= 1024; index++) {
		value /= 1024;
		unit = units[index]!;
	}
	return `${value >= 10 ? value.toFixed(1) : value.toFixed(2)} ${unit}`;
}

export function normalizeLlamaServerUrl(value: string): string {
	const url = new URL(value.trim());
	if (url.protocol !== "http:" && url.protocol !== "https:") {
		throw new Error("Server URL must use http or https");
	}
	url.hash = "";
	url.search = "";
	url.pathname = url.pathname.replace(/\/+$/u, "").replace(/\/v1$/u, "") || "/";
	return url.toString().replace(/\/$/u, "");
}

export function llamaInferenceUrl(serverUrl: string): string {
	return `${normalizeLlamaServerUrl(serverUrl)}/v1`;
}

export class LlamaClient {
	readonly serverUrl: string;
	private readonly apiKey: string | undefined;

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

View on GitHub (pinned to 4af9d21d3b)