Feature Request: Support Multiple API Endpoints for Different Models/Agents

Resolved 💬 4 comments Opened Feb 12, 2026 by ilanoh Closed Mar 23, 2026

Summary

Add support for configuring multiple API endpoints simultaneously, allowing users to route different models or agent types to different providers (e.g., Anthropic API for main agent, alternative providers like Z.AI/GLM for teammates).

Use Case

I want to use Claude Opus (via Anthropic's API) as my main model for the primary coding work, while spawning teammates that use GLM-5 or other cost-effective models (via Z.AI's API) for parallel tasks like testing, research, or simple implementations.

Current Limitation

Currently, ~/.claude/settings.json only supports a single ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "single_api_key",
    "ANTHROPIC_BASE_URL": "single_api_endpoint"
  }
}

This means all models (main agent and all teammates) must use the same API provider.

Desired Behavior

Example Configuration:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "anthropic_api_key",
    "ANTHROPIC_BASE_URL": "https://api.anthropic.com"
  },
  "alternativeProviders": {
    "zai": {
      "baseUrl": "https://api.z.ai/api/anthropic",
      "authToken": "zai_api_key",
      "models": {
        "haiku": "glm-4.5-air",
        "sonnet": "glm-4.7"
      }
    }
  },
  "teamDefaults": {
    "provider": "zai",
    "model": "haiku"
  }
}

Usage in Teams:

// Main agent uses Opus via Anthropic API
// (default from primary config)

// Spawn teammate using GLM-4.7 via Z.AI API
Task({
  subagent_type: "general-purpose",
  prompt: "Run comprehensive tests",
  provider: "zai",  // NEW: specify alternative provider
  model: "sonnet"   // Maps to glm-4.7 on Z.AI
})

// Spawn teammate using GLM-4.5-Air for simple tasks
Task({
  subagent_type: "Explore",
  prompt: "Search for all API endpoints",
  provider: "zai",
  model: "haiku"  // Maps to glm-4.5-air (fast & cheap)
})

Benefits

  1. Cost Optimization: Use premium models (Opus) for complex main work, cost-effective models (GLM/Haiku) for teammates doing simpler tasks
  2. Performance: Route different workloads to optimal providers (e.g., GLM for high-throughput batch work, Anthropic for reasoning)
  3. Redundancy: Fallback to alternative providers if primary API has issues
  4. Flexibility: Leverage strengths of different model providers (e.g., Anthropic for reasoning, GLM for cost, local models for privacy)
  5. Team Scalability: Spawn many teammates without exhausting primary API quota

Real-World Scenario

Working on a large refactoring task:

  • Main agent (Opus): Complex architectural decisions, code design
  • 5 teammates (GLM-4.5-Air): Running tests, checking documentation, searching codebase, validating changes
  • 1 teammate (GLM-4.7): Writing comprehensive test suites

Current cost: 6 Opus sessions → Very expensive
With multi-API: 1 Opus + 5 GLM-Air + 1 GLM-4.7 → ~80% cost reduction

Proposed Implementation

Option 1: Provider-Specific Configuration

Add a providers section in settings.json with fallback logic.

Option 2: Per-Agent Model Mapping

Extend the Task tool's model parameter to accept provider-qualified model IDs:

model: "zai:glm-4.7"
model: "anthropic:claude-opus-4"

Option 3: Environment Variable Arrays

{
  "env": {
    "ANTHROPIC_PROVIDERS": "anthropic,zai",
    "ANTHROPIC_BASE_URL_ANTHROPIC": "https://api.anthropic.com",
    "ANTHROPIC_AUTH_TOKEN_ANTHROPIC": "key1",
    "ANTHROPIC_BASE_URL_ZAI": "https://api.z.ai/api/anthropic",
    "ANTHROPIC_AUTH_TOKEN_ZAI": "key2"
  }
}

Compatibility

This should be backward compatible - if no alternative providers are configured, behavior remains unchanged.

Related

This would also benefit users wanting to:

  • Use local LLM providers (Ollama, LM Studio) for teammates
  • Route to region-specific endpoints for compliance
  • A/B test different providers for quality/cost analysis
  • Use specialized models (e.g., code-specific models for implementation teammates)

---

Would love to see this feature! Happy to provide more details or help test if needed.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗