earendil-works/pi · error · AuthCommandError

Provider " " is configured with OAuth, not an API key

Error message

Provider "${providerId}" is configured with OAuth, not an API key

What it means

Thrown when printing an API key: a specific --provider was requested, but that provider's stored credential is OAuth type, so there is no API key to print. The command and credential type are mismatched.

Solutions

  1. Use pi auth print-bearer-token for OAuth providers
  2. Configure an API key for the provider if a key is required
  3. Log in again with an API key instead of OAuth
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/coding-agent/src/cli/credential-print.ts:77 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/d5919dcc9e886367. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/cli/credential-print.ts:77

		if (kind === "api_key" && type === "oauth") continue;
		if (kind === "bearer_token" && type !== "oauth") continue;
		const authOptions = {
			...(kind === "bearer_token" ? { minOAuthValidityMs: minExpiryMs ?? DEFAULT_BEARER_TOKEN_MIN_EXPIRY_MS } : {}),
			signal,
		};
		const auth = provider.model
			? await modelRuntime.getAuth(provider.model, authOptions)
			: await modelRuntime.getAuth(provider.id, authOptions);
		const value = getAuthCredential(auth);
		if (value) credentials.push({ providerId: provider.id, value });
	}

	if (credentials.length === 1) return credentials[0].value;
	if (credentials.length === 0) {
		const providerId = providers[0]?.id;
		const type = providerId ? credentialTypes.get(providerId) : undefined;
		if (cliProvider && kind === "api_key" && type === "oauth") {
			throw new AuthCommandError(`Provider "${providerId}" is configured with OAuth, not an API key`);
		}
		if (cliProvider && kind === "bearer_token" && type !== "oauth") {
			throw new AuthCommandError(`Provider "${providerId}" is not configured with an OAuth bearer token`);
		}
		throw new AuthCommandError(`No usable ${kind === "api_key" ? "API key" : "OAuth bearer token"} is configured`);
	}
	throw new AuthCommandError(
		`Multiple configured providers matched (${credentials.map(({ providerId }) => providerId).join(", ")}). Specify --provider.`,
	);
}

View on GitHub (pinned to 4af9d21d3b)