Skip to content

Feature Request: Native support for Custom API Endpoints in Web UI #251

@aleksesipenko

Description

@aleksesipenko

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:

  1. Users in restricted regions (China, etc.) using z.ai as a model provider to use Claude Code
  2. 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:

  1. Expose ANTHROPIC_BASE_URL to frontend via /v1/claude/settings endpoint
  2. Update isAuthenticated check to validate against configured endpoint
  3. Add API endpoint validation before enabling web UI
  4. Fall back to official Anthropic API if custom endpoint fails

EXAMPLE WORKFLOW:
As a user:

  1. I run: catnip run -e ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic -e ANTHROPIC_API_KEY=sk-xxx
  2. I open http://localhost:6369
  3. Expected: Web UI shows "Connected to: z.ai API" and isAuthenticated: true
  4. Current: Web UI shows "Login to Claude" prompt and isAuthenticated: false

RELATED ISSUES:

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions