PraisonAI reads Claude Code credentials in read-only mode. Token refresh is handled by the Claude CLI, not PraisonAI — this avoids rotating the shared refresh token and breaking
claude (or any other tool on the same subscription). If your token has expired, run claude /login to re-authenticate; PraisonAI will not refresh it for you.Quick Start
1
Login to CLI
claude /login (Claude Pro) — or qwen login2
Use in Agent
How It Works
Subscription Auth enables agents to use your existing subscriptions without requiring separate API keys.Supported Providers
Which subscription auth provider should you use?Common Patterns
Choose your refresh path
When aclaude-code token expires, pick the action that matches your setup — PraisonAI never rotates it for you.
Telegram bot using your Claude subscription
Switching between API key and subscription
Custom provider (advanced)
Configuration Options
SubscriptionCredentials API Reference
Configuration options and types for subscription credentials
Best Practices
Token Security
Token Security
Tokens are read locally from your CLI tools and never persisted by PraisonAI. They stay in memory only during agent execution. PraisonAI does not refresh or write them back — see “Read-only for claude-code” below.
Backward Compatibility
Backward Compatibility
Existing agents using API keys continue to work unchanged. Setting
auth= is completely optional and doesn’t affect agents that don’t use it.Read-only for claude-code
Read-only for claude-code
PraisonAI reads Claude Code OAuth credentials from macOS Keychain,
~/.claude/.credentials.json, or the ANTHROPIC_TOKEN / CLAUDE_CODE_OAUTH_TOKEN env vars, and uses them as-is. It never refreshes or persists tokens for auth="claude-code".This is deliberate. Anthropic rotates OAuth refresh tokens on every use. If PraisonAI refreshed in-memory without writing back to the Keychain, it would silently invalidate the shared session used by the Claude CLI and any other tool on the same machine.When your Keychain token expires, refresh it once via one of these paths — Claude CLI will keep it fresh from then on:- Run
claude /login(interactive), OR - Let the Claude CLI run in the background — its own refresh keeps the Keychain entry valid, OR
- Set
ANTHROPIC_TOKEN(orCLAUDE_CODE_OAUTH_TOKEN) to a long-lived token — env vars take precedence over Keychain/file.
provider.refresh() for claude-code raises AuthError with a message telling you exactly what to do next. This is not a bug — it’s the guard that keeps shared sessions safe.Don't commit token files
Don't commit token files
Never commit
~/.claude/.credentials.json, ~/.qwen/oauth_creds.json, or similar files to version control. These contain sensitive authentication data.Troubleshooting
”No Claude Code credentials found”
Solution: Install Claude Code CLI and runclaude /login to authenticate with your Claude Pro account.
invalid_request_error on a Claude Code request
What it means: This is a genuine client-side error (a malformed request), not a retryable auth failure. PraisonAI no longer misclassifies it as an expired-token error, so it surfaces directly instead of being silently retried.
Solution: Check the request itself — model name, message shape, or parameters. If you also see auth failures, re-authenticate the shared session:
macOS Keychain prompt every run
Solution: Grantsecurity command access to avoid repeated prompts. This is handled automatically by the system after first access.
Anthropic 500 errors
Issue: OAuth tokens require specific headers that are automatically included. What PraisonAI does: Automatically sends required headers:user-agent: claude-cli/<version> (external, cli)x-app: clianthropic-beta: interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14,claude-code-20250219
oauth-2025-04-20 is added by litellm automatically for OAuth tokens. context-1m-2025-08-07 was removed in PR #3332 because it is unsupported on many Claude Pro plans and triggered subscription API failures. If you previously relied on it, use a standard API key instead — don’t add it back yourself.Codex / Gemini raise AuthError
Expected behavior: These providers are experimental and not yet usable. They’re registered for future use but currently raise AuthError with messages about needing custom transports.
Token Detection Priority (Claude Pro)
Tokens are resolved in this exact order:ANTHROPIC_TOKENenvironment variableCLAUDE_CODE_OAUTH_TOKENenvironment variable- macOS Keychain (
Claude Code-credentials) ~/.claude/.credentials.jsonfile
Environment Variable Override
You can disable subscription auth entirely (planned):Related
Agent Configuration
Learn about agent configuration and setup
LLM Providers
Configure different LLM providers and endpoints

