earendil-works/pi · error · PiMessagesResponseError

${response.status} ${response.statusText}: ${suffix}${codeSu

Error message

${response.status} ${response.statusText}: ${suffix}${codeSuffix}

What it means

Error "${response.status} ${response.statusText}: ${suffix}${codeSuffix}" thrown in earendil-works/pi.

Source

Thrown at packages/ai/src/api/pi-messages.ts:398

			}

			const response = await (options?.fetch ?? globalThis.fetch)(url, {
				method: "POST",
				headers: {
					authorization: `Bearer ${apiKey}`,
					accept: "text/event-stream",
					"content-type": "application/json",
					...providerHeadersToRecord(options?.headers),
				},
				body: JSON.stringify(payload),
				signal: options?.signal,
			});

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

			if (!response.ok) {
				const body = await response.text();
				throw createPiMessagesResponseError(model, url, response, body);
			}
			if (!response.body) {
				throw new Error(`${model.provider} response has no body`);
			}

			for await (const piEvent of readPiMessagesEvents(response.body)) {
				const event = convertEvent(piEvent);
				eventStream.push(event);
				if (event.type === "done" || event.type === "error") {
					return;
				}
			}

			throw new Error(`${model.provider} stream ended without a terminal event`);
		} catch (error) {
			eventStream.push(createErrorEvent(model, error, options?.signal?.aborted ?? false));
		}
	})();

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. The API returned an HTTP error; check the status code and response suffix for details.

When it happens

Trigger: Thrown at packages/ai/src/api/pi-messages.ts:398 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/8e58d0d50f313ce7. Report an issue: GitHub.