Skip to content

Add API provider customization with auth-source integration#122

Open
lewang wants to merge 3 commits intomanzaltu:mainfrom
lewang:api-provider-customization
Open

Add API provider customization with auth-source integration#122
lewang wants to merge 3 commits intomanzaltu:mainfrom
lewang:api-provider-customization

Conversation

@lewang
Copy link
Copy Markdown

@lewang lewang commented Oct 3, 2025

Summary

Enable declarative configuration of alternative Anthropic-compatible API providers through a simple customization variable.

Changes

  • Add claude-code-ide-api-provider customization variable for selecting provider
  • Add provider registry mapping hostnames to API endpoints (Anthropic, Moonshot, Z.ai)
  • Implement automatic credential retrieval from auth-source at startup
  • Inject provider environment variables (ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN) transparently
  • Log errors when provider configured but credentials missing
  • Add comprehensive test coverage (5 new tests, all passing)
  • Update documentation in README.org and file header

Usage

Users can now configure alternative providers declaratively:

;; 1. Add credentials to ~/.authinfo:
;; machine api.z.ai login anthropic password YOUR_API_KEY

;; 2. Set provider in Emacs config:
(setq claude-code-ide-api-provider "api.z.ai")

The API endpoint and credentials are automatically configured at startup with no user interaction needed.

Test plan

  • All existing tests pass (61 tests, 54 passed, 7 skipped)
  • New provider tests pass (5/5)
  • Test credential retrieval from auth-source
  • Test error handling for missing credentials
  • Test environment variable injection

Le Wang added 2 commits October 3, 2025 16:07
Enable declarative configuration of alternative Anthropic-compatible
API providers through a simple customization variable.

- Add defcustom claude-code-ide-api-provider for selecting provider
- Add provider registry mapping hostnames to API endpoints
- Implement automatic credential retrieval from auth-source at startup
- Inject provider env vars (ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN)
- Log errors when provider configured but credentials missing
- Add comprehensive test coverage (5 new tests)
- Update documentation with setup instructions

Supported providers: Anthropic, Moonshot AI, Z.ai
Add documentation for alternative API provider support:
- Add claude-code-ide-api-provider to configuration variables table
- Add API Provider Configuration section with setup examples
- Document supported providers (Anthropic, Moonshot, Z.ai)
lewang pushed a commit to lewang/claude-code-ide.el that referenced this pull request Oct 3, 2025
Combines both environment variable features:
- Additional custom env vars (PR manzaltu#121)
- Declarative API provider selection (PR manzaltu#122)

Both features are complementary and work together.
Update claude-code-ide--api-providers to support environment variables
per provider, with Z.ai configured for GLM models. Modify
claude-code-ide--get-provider-env-vars to handle new structure and include
provider-specific variables in addition to standard API configuration.
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.

1 participant