fix(answer): update to getApiKeyAndHeaders API (pi-coding-agent 0.63+)#26
Closed
affsantos wants to merge 1 commit intomitsuhiko:mainfrom
Closed
fix(answer): update to getApiKeyAndHeaders API (pi-coding-agent 0.63+)#26affsantos wants to merge 1 commit intomitsuhiko:mainfrom
affsantos wants to merge 1 commit intomitsuhiko:mainfrom
Conversation
ModelRegistry.getApiKey() was renamed to getApiKeyAndHeaders() in pi-coding-agent v0.63.0 (pi-mono commit 7a786d88). This broke the answer extension with: Extension "command:answer" error: modelRegistry.getApiKey is not a function Changes: - Replace inline modelRegistry type with the actual ModelRegistry import - Use getApiKeyAndHeaders() which returns ResolvedRequestAuth - Pass headers alongside apiKey to complete() for proper auth - Add error handling when auth resolution fails
marvelm
approved these changes
Mar 29, 2026
marvelm
left a comment
There was a problem hiding this comment.
I'm running this patch on pi@0.63.2 - and it works correctly.
$ git -P diff HEAD
diff --git a/settings.json b/settings.json
index b160283..2aef010 100644
--- a/settings.json
+++ b/settings.json
@@ -1,5 +1,5 @@
{
- "lastChangelogVersion": "0.62.0",
+ "lastChangelogVersion": "0.63.2",
"defaultProvider": "anthropic",
"defaultModel": "claude-opus-4-6",
"defaultThinkingLevel": "medium",
@@ -8,7 +8,7 @@
],
"packages": [
{
- "source": "npm:mitsupi",
+ "source": "git:github.com/affsantos/agent-stuff@fix/answer-getApiKey-rename",
"extensions": [
"pi-extensions/answer.ts"
],
|
Thank you @mitsuhiko for making this extension. It's what convinced me to switch to Pi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
answer.tsextension crashes with:Cause
ModelRegistry.getApiKey()was renamed togetApiKeyAndHeaders()in pi-coding-agent v0.63.0 (pi-mono@7a786d88, Mar 27 2026). The new method returns aResolvedRequestAuthobject instead of a plain string, supporting both API keys and request headers.The pi-mono examples (
qna.ts) were updated in the same commit, but this extension was not — since it lives in a separate repo.Investigation trail
modelRegistry.getApiKey is not a functionpointed to theModelRegistryAPImodel-registry.tsgit history and found commit7a786d88(fix(coding-agent): resolve models.json auth per request closes #1835) which:getApiKey(model)→getApiKeyAndHeaders(model)Promise<string | undefined>toPromise<ResolvedRequestAuth>({ ok: true, apiKey?, headers? } | { ok: false, error })qna.ts(which this extension was originally based on)getApiKey), installed pi is v0.63.1 (hasgetApiKeyAndHeadersonly)Changes
modelRegistrytype with the actualModelRegistryimport from@mariozechner/pi-coding-agentgetApiKeyAndHeaders()which returns{ ok, apiKey?, headers? } | { ok: false, error }headersalongsideapiKeytocomplete()for proper auth (needed for providers with custom headers)Notes
This is honestly my favourite pi extension — the interactive Q&A TUI for answering questions inline is brilliant. Just wanted to get it working again on 0.63+ 🙏