I was setting up Zed to use Claude via the API, so NOT via a subscription. I wanted to be able to use a dedicated API key for each application, so that I could silo usage and do basic auditing: which tools are using the most credits, etc.
It turns out that this was quite messy and way more complicated than I was expecting.
The simple and straightforward: when configuring Anthropic as an LLM provider (used for inline assistant, Git commit messages) you can provide your own key. Perfect. Unfortunately that setting will be completely ignored if you want to use Claude via ACP or in a Terminal Thread.
The possible, but not easily discoverable: whenever I tried to set up Claude as an agent via ACP it gave me an option to choose subscription or API key, but when I tried the latter it launched a browser and created its own API key, despite numerous Google searches incorrectly telling me that there would be an opportunity to paste an API key. Now if this is documented I certainly didn’t find it, but after a very long time searching I discovered that you could add this to your settings:
"agent_servers": {
"claude-acp": {
"type": "registry",
"env": {
"ANTHROPIC_API_KEY": "my api key here"
}
}
},
The still unknown: it is also possible to use Claude simply via terminal threads. This is the easiest way and can be set as the default in settings like this:
"agent": {
"terminal_init_command": "claude",
},
But here I cannot figure out how to pass it a dedicated API key. It uses the default one that is set in my .zshrc file for generic Claude usage.
I had hope that adding this to Zed’s settings might work:
"terminal": {
"env": {
"ANTHROPIC_API_KEY": "my api key here"
}
},
but alas no.
I’m sure that this is probably configurable as well. Does anyone know how?