Skip to content

feat: LiteLLM endpoint toggle in settings - #46

Merged
aterrylu merged 2 commits into
mainfrom
terry/litellm-toggle
Mar 23, 2026
Merged

feat: LiteLLM endpoint toggle in settings#46
aterrylu merged 2 commits into
mainfrom
terry/litellm-toggle

Conversation

@aterrylu

Copy link
Copy Markdown
Owner

Summary

Add an enable/disable toggle for the Anthropic API override in the settings panel. Lets you quickly switch between LiteLLM proxy and direct Anthropic API when LiteLLM has downtime.

How it works

  • Toggle on (default): ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are injected into new sessions from settings
  • Toggle off: env vars are NOT injected — Claude Code uses its default Anthropic endpoint
  • Values are preserved when toggled off (dimmed but not deleted)
  • Toggle saves immediately (no need to click Save separately)
  • Restart All Sessions to apply the change to running sessions

Test plan

  • Open settings — toggle is visible next to "Anthropic API Override"
  • Toggle off — URL/token fields dim, values preserved
  • Restart sessions — new sessions use direct Anthropic API
  • Toggle on — fields re-enable
  • Restart sessions — new sessions use LiteLLM proxy
  • Fresh install (no settings.json) — toggle defaults to enabled

🤖 Generated with Claude Code

aterrylu and others added 2 commits March 23, 2026 16:44
Add an enable/disable toggle for the Anthropic API override in the
settings panel. When disabled, new sessions use the default Anthropic
endpoint instead of the custom LiteLLM proxy URL.

- Server: `anthropicOverrideEnabled` flag in AppSettings — buildEnv()
  only injects ANTHROPIC_BASE_URL/AUTH_TOKEN when flag is not false
  (defaults to true for backward compat)
- API: GET/PUT /api/settings now includes the toggle state
- Dashboard: Toggle switch in settings panel header — immediately saves
  on click. URL/token fields dim when override is disabled but values
  are preserved for easy re-enable.

Workflow: toggle off → restart all sessions → Claude uses direct API.
Toggle on → restart → uses LiteLLM again.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aterrylu
aterrylu merged commit 5d4ab05 into main Mar 23, 2026
1 check passed
@aterrylu
aterrylu deleted the terry/litellm-toggle branch March 23, 2026 23:46

@nox-0x nox-0x left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, focused implementation. The !== false default-true pattern is consistent across both maskSettings and sessions.ts, maintaining full backward compatibility for existing users who have override values already configured. Toggle saves immediately and fields stay dimmed-but-preserved on disable — exactly right. No critical issues.

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.

2 participants