Implement Anthropic API key flow for Assistant#3696
Conversation
📊 Performance Test ResultsComparing 19cd6da vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
|
Can we instead disable the "api key" provider entirely from Studio App and rely full on the .com provider? Alternative would be to surface the API KEY config in the app settings but I'm not sure it's necessary for a start. I think there's not much value for the moment to provide your own API KEY specially if we're still giving free access. |
@youknowriad do you mean to:
Do I understand your suggestion correctly? I think it doesn't make sense to show only 1 open to chose, like this: |
There was a problem hiding this comment.
Vova, thanks for working to add Anthropic API. I tested it and confirmed I was able to add my Anthropic API key and worked as expected.
In the testing instructions there is a small typo with the Studio home folder. The folder is hidden and requires a dot Open ~/.studio/cli.json.
| Before | After |
|---|---|
api-key-before.mp4 |
enter-anthropic-api-key.mp4 |
I agree with Riad and we can default to WPcom provider without asking the user, at least initially.
|
Yes, that was my suggestion, I'm hesitant about proposing the removal of the anthropic provider entirely from the the code command as well. (CLI). I think it's still useful for me to check whether an issue is due to our proxy or not, but other than that, I don't see it being useful to users right now. |


Related issues
How AI was used in this PR
AI was almost useless and just misleading.
I investigated it myself and came up with the approach. AI just followed my instructions and double-checked them.
Proposed Changes
The issue: In Assistant tab of Studio, when we select

API key- nothing happens.The reason: we are using
passwordfunction from '@inquirer/prompts', to request the Anthropic API key in terminal. It doesn't work for UI, since it's intended to be used only for command line.What I did: Inverted the password collection dependency by injecting a
collectPasswordcallback through the adapter interface, so each environment (terminal, Desktop UI) owns its own collection strategy instead of the provider hardcoding an interactive TTY prompt.Testing Instructions
npm run cli:buildnode apps/cli/dist/cli/main.mjs codenpm start~/.studio/cli.jsonaiProviderandanthropicApiKey, since they we added while testing terminal abovehito AssistantKnown issues - this PR doesn't cover the case when incorrect API key was provided. First of all this PR is already pretty big, I want to keep it focused on the specific initial issue. And handling incorrect APi key deserves own PR, as I have no idea why errors are printed in Assistant and disappear almost immediatelly from UI. I will create separate Linear issue for it.
Also, I will think more about it, but maybe the best way is introducing /api-key, so that we have aligned way with
studio codein the terminal.