Skip to content

fix: route default launch through proxy (fixes cost tracking and auth override)#9

Draft
aattaran wants to merge 4 commits into
mainfrom
claude/reorganize-codebase-9TQvc
Draft

fix: route default launch through proxy (fixes cost tracking and auth override)#9
aattaran wants to merge 4 commits into
mainfrom
claude/reorganize-codebase-9TQvc

Conversation

@aattaran
Copy link
Copy Markdown
Owner

@aattaran aattaran commented May 4, 2026

Summary

  • deepclaude (default mode) previously set ANTHROPIC_BASE_URL directly to the upstream backend, bypassing the local proxy entirely
  • The proxy on :3200 was only ever started in --remote mode — so /_proxy/cost always showed {"backends":{}, "total_cost":0} and /switch had no effect in normal sessions
  • If the user was logged in via claude login (Claude Max/Pro subscription), the OAuth token wasn't intercepted, causing requests to fall back to Anthropic

Both deepclaude.sh and deepclaude.ps1 now start the proxy on a dynamic port and point ANTHROPIC_BASE_URL at it in all non-anthropic modes. The proxy already replaces auth headers in-flight for model calls, so subscription OAuth tokens and API keys are both handled correctly. ANTHROPIC_API_KEY is set to the backend key so Claude Code starts cleanly regardless of login state.

Closes #3

Test plan

  • deepclaude (no flags) — verify startup shows Proxy on :XXXX and Cost tracking: curl …
  • After a few turns, curl http://127.0.0.1:PORT/_proxy/cost shows non-zero tokens/cost
  • deepclaude --switch ds still works (proxy is in path)
  • deepclaude --backend anthropic still launches without proxy
  • deepclaude --remote still works unchanged

https://claude.ai/code/session_01FTqposuxzUQwueS9Zpa3ez


Generated by Claude Code

claude added 4 commits May 4, 2026 19:56
…erride

Previously `deepclaude` set ANTHROPIC_BASE_URL directly to the upstream
backend, bypassing the local proxy entirely. This meant:
- `/_proxy/cost` always showed {"backends":{}, "total_cost":0}
- `/switch` had no effect in default mode
- Claude subscription OAuth tokens weren't intercepted, causing fallback to Anthropic

Now both bash and PowerShell scripts start the proxy on a dynamic port and
point ANTHROPIC_BASE_URL at it in all non-anthropic modes. The proxy replaces
auth headers in-flight so subscription tokens and API keys are both handled.
ANTHROPIC_API_KEY is set to the backend key so Claude Code starts cleanly.

Fixes #3

https://claude.ai/code/session_01FTqposuxzUQwueS9Zpa3ez
…0x → 110x

ANTHROPIC_AUTH_TOKEN is Claude Code's OAuth subscription token, not the
API key — scripts now set ANTHROPIC_API_KEY. Cache ratio corrected:
$0.44 / $0.004 = 110x, not 120x.

https://claude.ai/code/session_01FTqposuxzUQwueS9Zpa3ez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Does not route through deepseek

2 participants