Docs › Account and usage › Bring your own key
Bring your own key
Use your own Anthropic API key, on plans from Pro up, so Anthropic models run on your Anthropic account and you choose the model yourself.
On this page
By default AstraCode runs on its own provider accounts, and AstraOne chooses the model for each step. If you would rather pay a provider directly, you can add your own Anthropic API key. Requests made with it go to Anthropic on your key and are not metered against your AstraCode allowance. Your own key is available on plans from Pro up; on Free and Student the editor does not offer it. See the pricing page.
You still sign in to AstraCode. The key decides who pays the provider; your AstraCode account is still what lets the editor use chat, the agent and completions. A key on its own does not get you past the sign-in window.
Add your key
- Create an API key in your Anthropic account. It starts with
sk-ant-. - In AstraCode, open AstraCode Settings > Models and choose Use my own key. The same is under Browser & Network > Your own API key > Manage, and in the command palette as AstraCode: Use My Own API Key (optional).
- Choose Add my Anthropic key.
- Paste the key into the box titled Your Anthropic API key and press Enter. A key that does not start with
sk-ant-is refused with Anthropic keys start with "sk-ant-". - The editor shows Checking your key…. It asks Anthropic whether it accepts the key, and AstraCode whether it has a model to run on it. The key is saved only when both say yes.
- The editor says Your Anthropic key is in use. You can choose the model in Settings. Choose a model opens AstraCode Settings > Models.
If the check fails, nothing is saved and the editor says why: Anthropic did not accept this key, AstraCode has no Anthropic model it can run on your key right now, Your own key is available on Pro and above, or Could not reach AstraCode to check the key. If Anthropic cannot be reached from your machine, that alone does not stop the key being saved.
The key is kept in your operating system's keychain through the editor's secret storage. It is never written to a settings file, so it is not in your settings sync or in a repository.
What changes with a key
- A model picker appears under the composer, once the gateway has answered with the models your key can use. It reads AstraOne until you pick a model. The menu lists AstraOne (AstraCode chooses the model for each step), the models on offer with how each compares in cost with the default, Effort for models that support it, and More models. Picking a model pins it; picking AstraOne again unpins it.
- Effort. For a pinned model that offers it, an effort control appears beside the picker: higher effort thinks for longer before answering. The choice is saved per model in
astracode.models.effort. - AstraCode Settings > Models gains an In the picker group with a switch per model, to keep models you never use out of the menu (
astracode.models.hidden), and Pinned Model (astracode.model): a model, or None: AstraCode chooses. A model pinned there or in the composer is the same setting. See Models and AstraOne. - Billing. Requests on your key carry no AstraCode allowance; Anthropic bills your key for them. A model that costs much more per run than the default says so once, when you pick it.
Go back to AstraCode's key
- Run AstraCode: Use My Own API Key (optional) again.
- Choose Stop using my own key.
- The editor says Your key is removed. AstraOne is back on your plan's allowance. and the model list returns to AstraOne.
Limits
- Only Anthropic keys are accepted, and a key can only be used with that provider's models. A request that would use another provider's model with your key is refused with A personal API key can only be used with Anthropic models. Pick one of that provider's models in the picker, or stop using your key.
- If your provider account runs out of credit, requests fail with That model is out of credit. Add credit in your provider account; AstraCode cannot do it for you.
- Your key reaches only the Anthropic models AstraCode has tested for agent work; the picker lists them.
- The
ASTRACODE_API_KEYused by the CLI is a different thing: an AstraCode key for scripts and CI, not a provider key.
If something goes wrong
- No model picker after adding a key: it appears only once the gateway returns a model list for your key. Check that you are signed in, then see Chat panel problems.
- Provider errors and billing errors: Usage, billing and network errors.
← Usage and limits What AstraCode sends and keeps →
All documentation
Get started
Using the editor
- Tab completion
- Edit and ask about a selection
- Reviewing the agent's changes
- Git: commit messages, branch review and conflicts
- Dictation
- Layout, themes and the settings page
Agent
- Agent overview
- Agent, Plan, Ask and Debug
- Approvals and permissions
- Plan mode
- Debug mode
- Tools
- Browser tools
- How the agent checks its work
- Checkpoints and undo
- Running several agents at once
- Subagents and background tasks
- Remote agents in GitHub Actions
- Infrastructure as code
Context
Workspaces
Connectors
- Connectors (MCP servers)
- Connector configuration reference
- Use AstraCode from Claude, ChatGPT and other apps
Extending AstraCode
CLI
Account and usage
- Usage and limits
- Bring your own key
- What AstraCode sends and keeps
- Reporting a problem and getting help
Troubleshooting
- Troubleshooting
- Sign-in problems
- Install and update problems
- Chat panel problems
- Agent run problems
- Connector problems
- Dictation problems
- Usage, billing and network errors
- CLI problems