claude setup-token
The Anthropic CLI command that exchanges a Claude Pro or Max subscription for a long-lived OAuth token (sk-ant-oat01-…) you can use against the Anthropic API. Same endpoints as a paid API key, billed against your subscription's quota instead.
The four steps
- Install the Claude CLI.
npm i -g @anthropic-ai/claude-code. Requires Node 18+. macOS, Linux, and Windows (WSL) all work. - Run
claude setup-token. The CLI prints a URL and waits. - Authorize in the browser. Open the URL, sign in to your Claude Pro or Max account at claude.ai, approve the access request. Claude shows you a short code.
- Paste the code back into the CLI. The token (starting
sk-ant-oat01-) is stored at~/.claude/config.json. Done.
oat01 vs api03 — which token type is this?
Anthropic issues two kinds of Bearer tokens against api.anthropic.com. Both hit the same endpoints. They differ in where the cost lands:
| Aspect | sk-ant-oat01- | sk-ant-api03- |
|---|---|---|
| How you generate it | claude setup-token CLI | console.anthropic.com → API Keys |
| What backs it | Claude Pro ($20/mo) or Max ($100/$200/mo) subscription | Anthropic API credit balance |
| Billing model | Quota — flat monthly fee, throttles at a daily ceiling | Per-token — pay for what you use, no ceiling |
| Best for | Heavy interactive use, predictable monthly cost | Production traffic, automation, multi-user services |
| Lifetime | ~1 year, refreshes silently | Lives until you revoke it |
| Token length | ~108 chars | ~108 chars |
Same wire format, same headers (x-api-key: $TOKEN), same JSON request body. A naive HTTP client can't tell them apart — only Anthropic's billing layer can. Most third-party AI tools only document the api03 path; tools that explicitly call out oat01 support (VibeKit, Claude Code itself, a few others) let subscribers route their Pro/Max quota through them.
What does the token actually look like?
sk-ant-oat01-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
sk = secret key. ant = Anthropic. oat01 = OAuth access token, version 01. The remaining ~95 characters are a random base64url body, no checksum. (For a deeper breakdown of the format and how it compares to api03 keys, see Anthropic API key format.)
Using the token
Anything that accepts an Anthropic Bearer token accepts this one. The Claude CLI itself uses it automatically once stored. To send a manual request:
curl -s https://api.anthropic.com/v1/messages \
-H "x-api-key: $TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-6","max_tokens":50,"messages":[{"role":"user","content":"hi"}]}'
A 200 with a completion confirms the token works. A 401 means it's expired or revoked — re-run claude setup-token. A 429 with a "subscription quota exceeded" message means you've hit Pro or Max's daily ceiling; wait or upgrade. A standard 429 without that note is just a per-minute rate-limit and clears in seconds.
Common pitfalls
- Free Claude account. The OAuth flow completes and issues a token, but every request returns "subscription required." You need an active Pro or Max subscription on the account.
- Wrong account. If you have multiple Claude accounts (work + personal), the browser auth picks whichever you're currently signed in to. Sign out first, then run
claude setup-token, to make sure the right subscription backs the token. - Tools that gate on the prefix. Some third-party hosts validate against
sk-ant-api03-only and rejectoat01on the assumption it's the wrong kind of key. Look for explicit "subscription token" or "OAuth token" support in their docs. - Stale token after password change. Rotating your Claude.ai password invalidates active OAuth sessions. Re-run
setup-tokento mint a fresh one. - Token doesn't refresh under heavy load. The token's refresh mechanism is silent and rarely fails — but if you're seeing repeat
401after ~12 months of uptime, that's the cue.
Where to plug it in
Claude Code itself
Nothing to do — once stored at ~/.claude/config.json, the CLI uses it for every request. claude in a terminal just works.
VibeKit (Telegram / iOS / web)
Paste the token into Profile → AI Provider → Anthropic. The agent's next call runs through your subscription. Both Pro and Max tokens work the same way. More on BYOK →
Any other Anthropic-compatible tool
Set it as the value of whatever env var the tool uses for an Anthropic API key — usually ANTHROPIC_API_KEY. The tool doesn't need to know it's an OAuth token; the Anthropic API handles the difference server-side.
Is this allowed?
Yes. The OAuth flow is Anthropic's official mechanism for letting Pro/Max subscribers use their subscription with their own tooling. The token is rate-limited by Anthropic the same way claude.ai chat is — heavy automation can soft-cap earlier than human-paced interactive use, but using oat01 with a coding agent is well within the intended use. The terms that apply are the same Acceptable Use Policy that governs any Anthropic API access.
FAQ
What does claude setup-token do?
Runs an OAuth flow against Claude.ai and stores the resulting sk-ant-oat01- token at ~/.claude/config.json. Calls made with that token bill against your Claude Pro or Max subscription quota.
Do I need a paid Claude subscription?
Yes — the token issues for any account, but only Pro ($20/mo) and Max ($100 or $200/mo) accounts have a quota to bill against. A free account's tokens return a subscription-required error on every call.
How long does the token last?
About a year. Refreshes silently while in use. You'll only need to re-run setup-token if it sits idle, you rotate your password, or you revoke active sessions.
Can I use this token with VibeKit?
Yes. Paste it into Profile → AI Provider → Anthropic. VibeKit treats it the same as a sk-ant-api03 key for routing; Anthropic's billing layer handles the rest. Your subscription pays for the calls, not VibeKit credits.
Why does my token get 429 errors mid-agent-run?
Pro and Max have a daily message ceiling that Anthropic adjusts based on aggregate load. Heavy agent automation can hit it earlier than human chat use. A 429 with "subscription quota exceeded" is the ceiling — wait until reset, or upgrade Pro → Max. A plain 429 without that note is a per-minute rate-limit and clears in seconds.
Use your Claude Pro / Max subscription in a Telegram AI agent
Run claude setup-token, paste the sk-ant-oat01 into VibeKit on Telegram. Build apps, ship code, deploy to name.vibekit.bot — all billing against the Claude subscription you already pay for.
VibeKit
Enter App