{"record":{"id":"202cd1e9b22bc7d6","repo":"earendil-works/pi","slug":"no-api-key-for-model-provider-model-id","errorCode":null,"errorMessage":"No API key for ${model.provider}/${model.id}","messagePattern":"No API key for (.+?)/(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/core/agent-session.ts","lineNumber":1600,"sourceCode":"\t): Promise<void> {\n\t\tif (modelsAreEqual(previousModel, nextModel)) return;\n\t\tawait this._extensionRunner.emit({\n\t\t\ttype: \"model_select\",\n\t\t\tmodel: nextModel,\n\t\t\tpreviousModel,\n\t\t\tsource,\n\t\t});\n\t}\n\n\t/**\n\t * Set model directly.\n\t * Validates that auth is configured and saves to the session transcript.\n\t * Persists to global defaults only when options.persist is true.\n\t * @throws Error if no auth is configured for the model\n\t */\n\tasync setModel(model: Model<any>, options: ModelMutationOptions = {}): Promise<void> {\n\t\tif (!(await this._modelRuntime.checkAuth(model.provider))) {\n\t\t\tthrow new Error(`No API key for ${model.provider}/${model.id}`);\n\t\t}\n\n\t\tconst previousModel = this.model;\n\t\tconst thinkingLevel = this._getThinkingLevelForModelSwitch(model);\n\t\tthis.agent.state.model = model;\n\t\tthis.sessionManager.appendModelChange(model.provider, model.id);\n\t\tif (options.persist) {\n\t\t\tthis.settingsManager.setDefaultModelAndProvider(model.provider, model.id);\n\t\t}\n\n\t\t// Apply thinking level for the new model.\n\t\t// Per-model thinking level overrides take priority over the global default.\n\t\t// Model persistence does not implicitly rewrite the global thinking default.\n\t\tthis.setThinkingLevel(thinkingLevel);\n\n\t\tawait this._emitModelSelect(model, previousModel, \"set\");\n\t}\n","sourceCodeStart":1582,"sourceCodeEnd":1618,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/coding-agent/src/core/agent-session.ts#L1582-L1618","documentation":"Error \"No API key for ${model.provider}/${model.id}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/coding-agent/src/core/agent-session.ts:1600 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"}