earendil-works/pi · error · Error

OpenAI Codex device code request failed with status ${respon

Error message

OpenAI Codex device code request failed with status ${response.status}${responseBody ? `: ${responseBody}` : ""}

What it means

Error "OpenAI Codex device code request failed with status ${response.status}${responseBody ? `: ${responseBody}` : ""}" thrown in earendil-works/pi.

Source

Thrown at packages/ai/src/auth/oauth/openai-codex.ts:206

	return readTokenResponse(response, "refresh");
}

async function startOpenAICodexDeviceAuth(signal: AbortSignal): Promise<DeviceAuthInfo> {
	const response = await fetchWithLoginCancellation(DEVICE_USER_CODE_URL, {
		method: "POST",
		headers: { "Content-Type": "application/json" },
		body: JSON.stringify({ client_id: CLIENT_ID }),
		signal,
	});

	if (!response.ok) {
		if (response.status === 404) {
			throw new Error(
				"OpenAI Codex device code login is not enabled for this server. Use browser login or verify the server URL.",
			);
		}
		const responseBody = await response.text().catch(() => "");
		throw new Error(
			`OpenAI Codex device code request failed with status ${response.status}${responseBody ? `: ${responseBody}` : ""}`,
		);
	}

	const rawJson = await response.json();
	const json = rawJson as {
		device_auth_id?: string;
		user_code?: string;
		interval?: number | string;
	} | null;
	const intervalSeconds = typeof json?.interval === "string" ? Number(json.interval.trim()) : json?.interval;
	if (
		!json?.device_auth_id ||
		!json.user_code ||
		typeof intervalSeconds !== "number" ||
		!Number.isFinite(intervalSeconds) ||
		intervalSeconds < 0
	) {

View on GitHub (pinned to 4af9d21d3b)

Solutions

  1. Check the status and body; verify the server URL and device code endpoint.

When it happens

Trigger: Thrown at packages/ai/src/auth/oauth/openai-codex.ts:206 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/94190c1179c6cdd5. Report an issue: GitHub.