← Back to Kontasks
Claude CLI API Key Authentication Investigation
Research findings on how Claude Code CLI handles API key vs subscription authentication
Output
🔍 Claude CLI Authentication Investigation
✅ YES - API Key Authentication IS Supported
How It Works
Claude Code CLI supports two authentication methods:
| Method | How | Billing |
|---|---|---|
| Subscription (OAuth) | ~/.claude/.credentials.json |
Weekly quota + extra usage |
| API Key | ANTHROPIC_API_KEY env var |
Pay-as-you-go API rates |
💡 Key Finding
ANTHROPIC_API_KEY takes priority over subscription auth. If this env var is set, Claude CLI uses it instead of your logged-in subscription - even if you have a Max subscription active.
Your Current Setup
# ~/.claude/.credentials.json shows: subscriptionType: "max" rateLimitTier: "default_claude_max_20x" # Auth: OAuth tokens (claudeAiOauth)
You're currently using subscription OAuth, not API key.
🛠️ Switching Accounts in Konsole
Option 1: Separate credentials files (OAuth)
# Two credential sets /home/bb/.claude-max20x/.credentials.json # Primary account /home/bb/.claude-max5x/.credentials.json # Secondary account # Konsole switches by setting HOME or symlinking ln -sfn ~/.claude-max20x ~/.claude
Option 2: API keys (if you create them in Console)
# Per-spawn environment ANTHROPIC_API_KEY=sk-ant-xxx claude -p "..." # But note: API key = pay-as-you-go, NOT subscription quota!
⚠️ Critical Gotcha
API keys use pay-as-you-go pricing, not your Max subscription quota. To use your 20x/5x quotas, you MUST use subscription OAuth - not API keys.
🎯 Recommended Approach for Dual Max Accounts
Since you want to use subscription quotas (not API pay-as-you-go):
- Login to both accounts on the server (one at a time)
- Copy credentials to separate directories:
cp -r ~/.claude ~/.claude-max20x cp -r ~/.claude ~/.claude-max5x
- Konsole switches by symlinking before spawning Claude:
ln -sfn ~/.claude-max20x ~/.claude && claude -p "..."
📚 Sources
Next Steps
Choose how to proceed:
Quick Actions
Original Request
No layout configured
Details
Type
General
Status
Completed
Scope
vibetools
Tags
konsoleauthenticationarchitecture
Created
8 Jan 2026, 6:56 am
Updated
8 Jan 2026, 6:56 am
Created By
claude
Raw Data
{
"id": "c1c3a431-38f4-4cbc-bdbe-a824a73c7f35",
"type": "general",
"status": "completed",
"title": "Claude CLI API Key Authentication Investigation",
"description": "Research findings on how Claude Code CLI handles API key vs subscription authentication",
"context": {
"output": "<div style=\"background:#1e1e1e;color:#e0e0e0;padding:20px;border-radius:8px;font-family:sans-serif;\">\n<h2 style=\"color:#fff;margin:0 0 16px 0;\">🔍 Claude CLI Authentication Investigation</h2>\n\n<div style=\"background:#22c55e;color:#000;padding:12px 16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"margin:0;\">✅ YES - API Key Authentication IS Supported</h3>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#3b82f6;margin:0 0 12px 0;\">How It Works</h3>\n\n<p style=\"margin:0 0 12px 0;\">Claude Code CLI supports <strong>two authentication methods</strong>:</p>\n\n<table style=\"width:100%;border-collapse:collapse;\">\n<tr style=\"background:#1e3a5f;\">\n<th style=\"text-align:left;padding:10px;color:#fff;border:1px solid #4b5563;\">Method</th>\n<th style=\"text-align:left;padding:10px;color:#fff;border:1px solid #4b5563;\">How</th>\n<th style=\"text-align:left;padding:10px;color:#fff;border:1px solid #4b5563;\">Billing</th>\n</tr>\n<tr>\n<td style=\"padding:10px;border:1px solid #4b5563;\"><strong>Subscription (OAuth)</strong></td>\n<td style=\"padding:10px;border:1px solid #4b5563;\"><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:3px;\">~/.claude/.credentials.json</code></td>\n<td style=\"padding:10px;border:1px solid #4b5563;\">Weekly quota + extra usage</td>\n</tr>\n<tr>\n<td style=\"padding:10px;border:1px solid #4b5563;\"><strong>API Key</strong></td>\n<td style=\"padding:10px;border:1px solid #4b5563;\"><code style=\"background:#3d3d3d;padding:2px 6px;border-radius:3px;\">ANTHROPIC_API_KEY</code> env var</td>\n<td style=\"padding:10px;border:1px solid #4b5563;\">Pay-as-you-go API rates</td>\n</tr>\n</table>\n</div>\n\n<div style=\"background:#1e3a5f;padding:16px;border-radius:6px;border:1px solid #3b82f6;margin-bottom:16px;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">💡 Key Finding</h3>\n<p style=\"margin:0;line-height:1.6;\"><strong>ANTHROPIC_API_KEY takes priority over subscription auth.</strong> If this env var is set, Claude CLI uses it instead of your logged-in subscription - even if you have a Max subscription active.</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#22c55e;margin:0 0 12px 0;\">Your Current Setup</h3>\n\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;overflow-x:auto;margin:0;\"><span style=\"color:#7f848e;\"># ~/.claude/.credentials.json shows:</span>\n<span style=\"color:#e5c07b;\">subscriptionType</span>: <span style=\"color:#98c379;\">\"max\"</span>\n<span style=\"color:#e5c07b;\">rateLimitTier</span>: <span style=\"color:#98c379;\">\"default_claude_max_20x\"</span>\n<span style=\"color:#7f848e;\"># Auth: OAuth tokens (claudeAiOauth)</span></pre>\n\n<p style=\"margin:12px 0 0 0;\">You're currently using <strong>subscription OAuth</strong>, not API key.</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#8b5cf6;margin:0 0 12px 0;\">🛠️ Switching Accounts in Konsole</h3>\n\n<p style=\"margin:0 0 12px 0;\"><strong>Option 1: Separate credentials files (OAuth)</strong></p>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;overflow-x:auto;margin:0 0 12px 0;\"><span style=\"color:#7f848e;\"># Two credential sets</span>\n/home/bb/.claude-max20x/.credentials.json <span style=\"color:#7f848e;\"># Primary account</span>\n/home/bb/.claude-max5x/.credentials.json <span style=\"color:#7f848e;\"># Secondary account</span>\n\n<span style=\"color:#7f848e;\"># Konsole switches by setting HOME or symlinking</span>\n<span style=\"color:#c678dd;\">ln -sfn</span> ~/.claude-max20x ~/.claude</pre>\n\n<p style=\"margin:0 0 12px 0;\"><strong>Option 2: API keys (if you create them in Console)</strong></p>\n<pre style=\"background:#1e1e1e;padding:12px;border-radius:4px;overflow-x:auto;margin:0;\"><span style=\"color:#7f848e;\"># Per-spawn environment</span>\n<span style=\"color:#e5c07b;\">ANTHROPIC_API_KEY</span>=<span style=\"color:#98c379;\">sk-ant-xxx</span> claude -p \"...\"\n\n<span style=\"color:#7f848e;\"># But note: API key = pay-as-you-go, NOT subscription quota!</span></pre>\n</div>\n\n<div style=\"background:#ef4444;padding:12px 16px;border-radius:6px;margin-bottom:16px;color:#fff;\">\n<h3 style=\"margin:0 0 8px 0;\">⚠️ Critical Gotcha</h3>\n<p style=\"margin:0;\"><strong>API keys use pay-as-you-go pricing</strong>, not your Max subscription quota. To use your 20x/5x quotas, you MUST use subscription OAuth - not API keys.</p>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-bottom:16px;\">\n<h3 style=\"color:#f59e0b;margin:0 0 12px 0;\">🎯 Recommended Approach for Dual Max Accounts</h3>\n\n<p style=\"margin:0 0 12px 0;\">Since you want to use <strong>subscription quotas</strong> (not API pay-as-you-go):</p>\n\n<ol style=\"margin:0;padding-left:20px;line-height:1.8;\">\n<li><strong>Login to both accounts</strong> on the server (one at a time)</li>\n<li><strong>Copy credentials</strong> to separate directories:\n<pre style=\"background:#1e1e1e;padding:8px;border-radius:4px;margin:4px 0;\">cp -r ~/.claude ~/.claude-max20x\ncp -r ~/.claude ~/.claude-max5x</pre></li>\n<li><strong>Konsole switches</strong> by symlinking before spawning Claude:\n<pre style=\"background:#1e1e1e;padding:8px;border-radius:4px;margin:4px 0;\">ln -sfn ~/.claude-max20x ~/.claude && claude -p \"...\"</pre></li>\n</ol>\n</div>\n\n<div style=\"background:#1e3a5f;padding:16px;border-radius:6px;border:1px solid #3b82f6;\">\n<h3 style=\"color:#fff;margin:0 0 12px 0;\">📚 Sources</h3>\n<ul style=\"margin:0;padding-left:20px;line-height:1.8;\">\n<li><a href=\"https://support.claude.com/en/articles/12304248-managing-api-key-environment-variables-in-claude-code\" style=\"color:#60a5fa;\">Claude Help: Managing API Key Environment Variables</a></li>\n<li><a href=\"https://github.com/anthropics/claude-code/issues/1084\" style=\"color:#60a5fa;\">GitHub Issue #1084: API key configuration</a></li>\n</ul>\n</div>\n\n<div style=\"background:#2d2d2d;padding:16px;border-radius:6px;margin-top:16px;\">\n<h4 style=\"margin:0 0 8px 0;color:#fff;\">Next Steps</h4>\n<p style=\"color:#9ca3af;margin:0;\">Choose how to proceed:</p>\n</div>\n</div>",
"choices": [
{
"label": "Setup credential switching",
"value": "Help me set up the dual credential directory approach - login to both accounts and configure konsole to switch between them via symlink",
"primary": true
},
{
"label": "Test symlink approach",
"value": "Let's test the symlink switching approach with my current account first to make sure it works before adding the second account"
},
{
"label": "Explore API key option",
"value": "I want to explore using API keys instead - help me understand the pay-as-you-go pricing vs subscription quotas"
},
{
"label": "Wait for second account",
"value": "I'll set up my Max 5x account first, then come back to configure the switching mechanism"
}
],
"requestedAt": "2026-01-08T10:45:00Z",
"requestId": "4dd1b7bc-a9c5-4fd0-b7cd-f55a72118d14"
},
"createdBy": "claude",
"createdAt": "2026-01-07T20:56:36.478Z",
"updatedAt": "2026-01-07T20:56:36.726Z",
"requestId": "4dd1b7bc-a9c5-4fd0-b7cd-f55a72118d14",
"scope": "vibetools",
"tags": [
"konsole",
"authentication",
"architecture"
],
"targetUser": "claude"
}