{"record":{"id":"1933a627414d9938","repo":"earendil-works/pi","slug":"no-api-key-found-for-provider-use-login-to-l","errorCode":null,"errorMessage":"No API key found for ${provider}.\n\nUse /login to log into a provider via OAuth or API key. See:\n  ${getDocsPath()}/providers.md\n  ${getDocsPath()}/models.md","messagePattern":"No API key found for (.+?)\\.\n\nUse /login to log into a provider via OAuth or API key\\. See:\n  (.+?)/providers\\.md\n  (.+?)/models\\.md","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/core/agent-session.ts","lineNumber":426,"sourceCode":"\t}\n\n\tget modelRuntime(): ModelRuntime {\n\t\treturn this._modelRuntime;\n\t}\n\n\tprivate async _getRequiredRequestAuth(model: Model<any>): Promise<{\n\t\tmodel: Model<any>;\n\t\tapiKey?: string;\n\t\theaders?: Record<string, string>;\n\t\tenv?: Record<string, string>;\n\t}> {\n\t\tlet result: AuthResult | undefined;\n\t\ttry {\n\t\t\tresult = await this._modelRuntime.getAuth(model);\n\t\t} catch (error) {\n\t\t\tconst cause = error instanceof Error ? error.cause : undefined;\n\t\t\tif (cause instanceof Error && cause.message === \"authHeader requires a resolved API key\") {\n\t\t\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t\tif (result && (result.auth.apiKey || result.auth.headers)) {\n\t\t\tconst requestModel = result.auth.baseUrl ? { ...model, baseUrl: result.auth.baseUrl } : model;\n\t\t\treturn {\n\t\t\t\tmodel: requestModel,\n\t\t\t\tapiKey: result.auth.apiKey,\n\t\t\t\theaders: withoutDeletedHeaders(result.auth.headers),\n\t\t\t\tenv: result.env,\n\t\t\t};\n\t\t}\n\n\t\tconst isOAuth = this._modelRuntime.isUsingOAuth(model.provider);\n\t\tif (isOAuth) {\n\t\t\tthrow new Error(\n\t\t\t\t`Authentication failed for \"${model.provider}\". ` +\n\t\t\t\t\t`Credentials may have expired or network is unavailable. ` +","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/core/agent-session.ts#L408-L444","documentation":"Error \"No API key found for ${provider}.\n\nUse /login to log into a provider via OAuth or API key. See:\n  ${getDocsPath()}/providers.md\n  ${getDocsPath()}/models.md\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/core/agent-session.ts:426 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}