can1357/oh-my-pi · error · SearchProviderError

No authentication method available.

Error message

No authentication method available.

What it means

After exhausting every available Perplexity authentication method (API key, OAuth, cookies, anonymous), none succeeded and none produced a lastError, so the provider concludes there is no usable auth method at all and throws a SearchProviderError with status 401.

Source

Thrown at packages/coding-agent/src/web/search/providers/perplexity.ts:962

					{
						provider: "perplexity",
						answer: askResult.answer || undefined,
						sources: askResult.sources,
						model: askResult.model,
						requestId: askResult.requestId,
						authMode: auth.type === "anonymous" ? "anonymous" : "oauth",
					},
					params.num_results,
				);
			} catch (error) {
				if (params.signal?.aborted) throw error;
				lastError = error;
			}
		}
	}

	if (lastError) throw lastError;
	throw new SearchProviderError("perplexity", "No authentication method available.", 401);
}

/** Search provider for Perplexity. */
export class PerplexityProvider extends SearchProvider {
	readonly id = "perplexity";
	readonly label = "Perplexity";

	/**
	 * Auto-chain admission. Requires a direct Perplexity credential
	 * (`PERPLEXITY_COOKIES`, OAuth session, or `PERPLEXITY_API_KEY`).
	 *
	 * OpenRouter auth is intentionally NOT accepted here: silently using
	 * OpenRouter's `perplexity/sonar-pro` whenever any OpenRouter key is
	 * configured surprises users (and bills them) for a path they never
	 * asked for. The auto chain skips Perplexity in that case and falls
	 * through to the next configured provider. Users who DO want the
	 * OpenRouter-backed Perplexity path can still opt in by setting
	 * `webSearch: perplexity` explicitly — see {@link isExplicitlyAvailable}.

View on GitHub (pinned to 9690622007)

Solutions

  1. Set PERPLEXITY_API_KEY in the environment or settings
  2. Complete Perplexity OAuth login to store a session
  3. Verify the env vars are visible to the process (shell profile, CI secrets)
  4. Fall back to a credential-free provider (e.g. the public aggregate)

Example fix

// before
export PATH=...
// after
export PERPLEXITY_API_KEY=pplx-xxxxxxxxxxxxxxxx
Defensive patterns

Strategy: validation

Validate before calling

const hasAuth = Boolean(process.env.PERPLEXITY_API_KEY) || hasStoredOAuthSession("perplexity");
if (!hasAuth) {
  // configure credentials or route to a credential-free provider
}

Try / catch

try {
  return await perplexitySearch(params);
} catch (err) {
  if (err instanceof SearchProviderError && err.statusCode === 401 && err.message.includes("No authentication")) {
    return publicWebSearch(params); // credential-free fallback
  }
  throw err;
}

Prevention

When it happens

Trigger: getAvailableAuthMethods returns an empty list (no PERPLEXITY_API_KEY, no stored OAuth session, no cookies, and anonymous access unavailable/disabled) when search attempts to authenticate.

Common situations: Fresh install with no Perplexity credentials configured, environment variables not exported in the runtime environment, OAuth session expired and was pruned, running in CI without secrets.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/3305d3f5f6d86d5f. Report an issue: GitHub.