earendil-works/pi · error · MistralHttpError

statusText || `Request failed with status ${statusCode}`

Error message

statusText || `Request failed with status ${statusCode}`

What it means

Error "statusText || `Request failed with status ${statusCode}`" thrown in earendil-works/pi.

Source

Thrown at packages/ai/src/api/mistral-conversations.ts:310

): Promise<AsyncIterable<MistralCompletionEvent>> {
	const baseUrl = new URL(model.baseUrl);
	baseUrl.pathname = `${baseUrl.pathname.replace(/\/+$/u, "")}/`;
	const url = new URL("v1/chat/completions", baseUrl);
	const headers = buildMistralHeaders(model, apiKey, options);
	const timeoutSignal = AbortSignal.timeout(options?.timeoutMs ?? 60_000);
	const signal = options?.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
	const response = await (options?.fetch ?? globalThis.fetch)(url, {
		method: "POST",
		headers,
		body: JSON.stringify(toMistralWirePayload(payload)),
		signal,
	});

	await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);

	if (!response.ok) {
		const body = await response.text();
		throw new MistralHttpError(response.status, body, response.statusText);
	}
	if (!response.body) {
		throw new Error("Mistral response has no body");
	}

	return readMistralEvents(response.body, signal);
}

class MistralHttpError extends Error {
	statusCode: number;
	body: string;

	constructor(statusCode: number, body: string, statusText: string) {
		super(statusText || `Request failed with status ${statusCode}`);
		this.name = "MistralHttpError";
		this.statusCode = statusCode;
		this.body = body;
	}

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Check the HTTP status code and response body for the failure reason.

When it happens

Trigger: Thrown at packages/ai/src/api/mistral-conversations.ts:310 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/3e2ad4600fc35f03. Report an issue: GitHub.