earendil-works/pi · error · Error

No API key found for

Error message

No API key found for ${provider}.

Use /login to log into a provider via OAuth or API key. See:
  ${getDocsPath()}/providers.md
  ${getDocsPath()}/models.md

What it means

Thrown by AgentSession._getRequiredRequestAuth when no credential resolves for the model's provider: either getAuth returned nothing or the provider's authHeader could not resolve an API key (detected via the 'authHeader requires a resolved API key' cause). The message directs the user to /login and provider docs.

Solutions

  1. Run /login to authenticate the provider via OAuth or API key
  2. Set the provider's API key environment variable
  3. See providers.md and models.md docs for supported auth methods per provider
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/core/agent-session.ts:426 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/1933a627414d9938. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/core/agent-session.ts:426

	}

	get modelRuntime(): ModelRuntime {
		return this._modelRuntime;
	}

	private async _getRequiredRequestAuth(model: Model<any>): Promise<{
		model: Model<any>;
		apiKey?: string;
		headers?: Record<string, string>;
		env?: Record<string, string>;
	}> {
		let result: AuthResult | undefined;
		try {
			result = await this._modelRuntime.getAuth(model);
		} catch (error) {
			const cause = error instanceof Error ? error.cause : undefined;
			if (cause instanceof Error && cause.message === "authHeader requires a resolved API key") {
				throw new Error(formatNoApiKeyFoundMessage(model.provider));
			}
			throw error;
		}
		if (result && (result.auth.apiKey || result.auth.headers)) {
			const requestModel = result.auth.baseUrl ? { ...model, baseUrl: result.auth.baseUrl } : model;
			return {
				model: requestModel,
				apiKey: result.auth.apiKey,
				headers: withoutDeletedHeaders(result.auth.headers),
				env: result.env,
			};
		}

		const isOAuth = this._modelRuntime.isUsingOAuth(model.provider);
		if (isOAuth) {
			throw new Error(
				`Authentication failed for "${model.provider}". ` +
					`Credentials may have expired or network is unavailable. ` +

View on GitHub (pinned to 4af9d21d3b)