-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Hi, I've been trying to use Catnip and hit a problem because i dont actually have a claude code subscription and use CC through external z.ai api with GLM 4.7. Here's full description of the problem i encountered written by CC. Im not a real developer, just a vibe code person, so i dont know if these implementation steps are perfectly correct, but nevertheless i added these descriptions, so you would fully understand core issue. Thank you in advance for your work!
PROBLEM:
Catnip web interface requires authentication through official Claude.ai API, ignoring ANTHROPIC_BASE_URL environment variable. This prevents users from using alternative Anthropic-compatible API providers (z.ai, OpenRouter, etc.) through the web interface.
Current behavior:
- CLI works perfectly with custom endpoints
- Web UI shows isAuthenticated: false with custom endpoints
- Forces vendor lock-in to Anthropic API only
EXPECTED BEHAVIOR:
Web UI should respect ANTHROPIC_BASE_URL environment variable and allow authentication with custom API providers, just like the CLI already does.
USE CASES:
- Users in restricted regions (China, etc.) using z.ai as a model provider to use Claude Code
- Cost optimization with alternative model providers
PROPOSED SOLUTION:
Make web UI respect existing environment variables:
catnip run -e ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic -e ANTHROPIC_API_KEY=sk-xxx
Implementation steps:
- Expose ANTHROPIC_BASE_URL to frontend via /v1/claude/settings endpoint
- Update isAuthenticated check to validate against configured endpoint
- Add API endpoint validation before enabling web UI
- Fall back to official Anthropic API if custom endpoint fails
EXAMPLE WORKFLOW:
As a user:
- I run: catnip run -e ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic -e ANTHROPIC_API_KEY=sk-xxx
- I open http://localhost:6369
- Expected: Web UI shows "Connected to: z.ai API" and isAuthenticated: true
- Current: Web UI shows "Login to Claude" prompt and isAuthenticated: false
RELATED ISSUES:
- Request: Custom Claude API Endpoint Support anthropics/claude-code#216 - Request: Custom Claude API Endpoint Support
- [BUG] Freshly installed Claude Code ignores settings.json anthropics/claude-code#13827 - Environment variables in settings.json ignored
- [FEATURE] VS Code Extension: Support for Custom API Endpoints and Authentication (settings.json parity) anthropics/claude-code#8727 - VS Code Extension: Support for Custom API Endpoints
PRIORITY: High
This blocks users from accessing web UI features when using alternative API providers. The CLI works correctly, so this is specifically about bringing the web UI to parity with CLI functionality.
ADDITIONAL CONTEXT:
Many users globally cannot access Anthropic API directly due to regional restrictions. Alternative providers like z.ai offer Anthropic-compatible endpoints, but Catnip's web UI doesn't support them despite the CLI working perfectly.
This feature would:
- Expand Catnip's user base to regions where Anthropic API is unavailable
- Reduce vendor lock-in and increase adoption
- Align with open-source philosophy of Catnip
- Compete with alternatives (Cursor, Continue.dev) that already support this
TECHNICAL DETAILS:
The web interface currently checks authentication via /v1/claude/settings which returns isAuthenticated: false. This value comes from Claude Code's internal authentication check that hardcodes the official Anthropic endpoint and doesn't respect ANTHROPIC_BASE_URL.
Files likely needing modification:
- pkg/claude/handlers.go (API settings endpoint)
- web/src/components/Settings.tsx (settings UI)
- web/src/hooks/useAuth.ts (authentication hook)
TESTING STRATEGY:
Test 1: Custom endpoint with valid key
catnip run -e ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
Expected: Web UI shows connected
Test 2: Invalid endpoint
catnip run -e ANTHROPIC_BASE_URL=https://invalid.example.com
Expected: Graceful error or fallback
Test 3: Environment variable priority
- Set ANTHROPIC_BASE_URL
- Verify web UI uses it instead of official API
- Verify CLI continues to work (no regression)