DOCS / CONFIGURATION
Anthropic API key
Four Birch features call the Anthropic API directly: AI code review, per-comment fix suggestions, ✨ commit-message generation, and conflict-resolution suggestions. All four need the ANTHROPIC_API_KEY environment variable — and because GUI apps don’t read your shell profile the way a terminal does, setting it visibly to Birch is the whole trick this page teaches.
What the key unlocks
Section titled “What the key unlocks”| Feature | Where you use it |
|---|---|
| AI code review | AI code review, the Automatically review new PRs toggle (Settings → AI), and birch review run |
| Comment fix suggestions | The fix-suggestion action on PR comments — currently unreachable; see the caution below |
| ✨ Commit-message generation | The ✨ button in the Changes tab’s commit box |
| Conflict suggestions | The AI suggest button in the conflict resolver |
All four run on a Claude Sonnet model chosen by the app; the model is not configurable. See AI in Birch for how these Anthropic API features relate to the agent CLI.
What it does not affect
Section titled “What it does not affect”- Agent workspaces. The agent in a workspace terminal is your own CLI (
claude,codex, …) authenticating the way it always does — typically your subscription. Workspaces work fine with noANTHROPIC_API_KEYset. - ✨ PR title generation. The sparkle button in the Create PR dialog also runs your own agent CLI, spending your subscription limits or that CLI’s own key — never this API key.
Set the variable
Section titled “Set the variable”Two steps — a shell profile alone is not enough, because apps launched from Finder or the Dock never read it.
1. Shell profile — covers the birch CLI in your terminal:
export ANTHROPIC_API_KEY="sk-ant-…"2. launchctl setenv — covers the Birch app itself:
launchctl setenv ANTHROPIC_API_KEY "sk-ant-…"Then quit and relaunch Birch. launchctl setenv lasts until you log out or reboot; to make it permanent, add a LaunchAgent that re-applies it at login:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict> <key>Label</key><string>anthropic-api-key</string> <key>ProgramArguments</key> <array> <string>/bin/launchctl</string> <string>setenv</string> <string>ANTHROPIC_API_KEY</string> <string>sk-ant-…</string> </array> <key>RunAtLoad</key><true/></dict></plist>Set a user environment variable:
- Open the Start menu, search for Edit environment variables for your account, and open it.
- Under User variables, click New…, name it
ANTHROPIC_API_KEY, and paste your key as the value.
Or from a terminal:
setx ANTHROPIC_API_KEY "sk-ant-…"Either way the variable only reaches newly started processes: quit Birch completely and relaunch it.
Verify it works
Section titled “Verify it works”-
The ✨ commit-message button appears in the Changes tab’s commit box once Birch sees the key.
-
A CLI review completes instead of erroring:
terminal birch review run <pr-id> -
Without the key, AI actions fail with:
AI provider is not configured. Set ANTHROPIC_API_KEY.If you still see that after setting the variable, Birch was started before the variable existed — quit and relaunch.
Cost expectations
Section titled “Cost expectations”Every action is a single, bounded API request billed to your Anthropic account: review reports and fix suggestions are capped at roughly 4,000 response tokens each, conflict suggestions slightly above that, and commit messages are far shorter. The one multiplier to watch is Automatically review new PRs (Settings → AI): with it on, each newly discovered PR triggers a review during background sync. It defaults to off, and it deliberately never runs on the first sync of a repository.
Security notes
Section titled “Security notes”- Birch never persists the key — it is not written to Birch’s database or settings; it lives only in your environment.
- Don’t put the key in a repository
.envfile: worktree carryover copies.env*into every new agent workspace by default, where the agent can read it. - Treat it like a password: keep it out of commits and shared dotfiles, and rotate it from your Anthropic console if it leaks.