This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a bash-based CLI tool (cc) that enables switching between different AI API providers for Claude Code by setting environment variables. The tool supports Anthropic (default), GLM (Z.ai), MiniMax, and OpenRouter providers.
The entire project is a single bash script (cc) with the following structure:
load_api_key()- Reads API keys fromapikeys.jsonusing Node.js for JSON parsing- Provider functions (
provider_glm,provider_mmx,provider_dflt,provider_optr) - Each clears existing ANTHROPIC_* variables, loads the appropriate API key, sets provider-specific environment variables, and optionally launches Claude Code clear_vars()- Unsets all ANTHROPIC_* environment variables- Variable setting functions (
set_glm_vars,set_mmx_vars,set_dflt_vars,set_optr_vars) - Define provider-specific configurations (BASE_URL, model mappings, timeouts) fetch_optr_models()- Fetches tool-use compatible models from OpenRouter APIselect_optr_model()- Interactive model selection using fzf (falls back to numbered list if fzf unavailable)
Each provider exports different environment variables that Claude Code reads:
ANTHROPIC_BASE_URL- API endpointANTHROPIC_AUTH_TOKENorANTHROPIC_API_KEY- AuthenticationANTHROPIC_DEFAULT_*_MODEL- Model mappings for Haiku/Sonnet/Opus tiersAPI_TIMEOUT_MS- Request timeout (3000000ms for all providers)CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC- MiniMax-specific flagANTHROPIC_API_KEY- Must be explicitly empty ("") for OpenRouter to prevent authentication conflicts
# Copy sample API keys file
cp apikeys.json.sample apikeys.json
# Edit apikeys.json with actual keysThe dcc command runs Docker sandbox with provider-specific configurations and preset environment variables:
# Run Docker sandbox with different providers
dcc glm # Use GLM provider
dcc mmx # Use MiniMax provider
dcc dflt # Use Anthropic (default) providerWhat dcc does:
- Loads the selected provider's API key from
apikeys.json - Sets provider-specific environment variables (BASE_URL, model mappings)
- Runs:
docker sandbox run -e <preset_vars>... claude
Preset environment variables (editable in dcc script):
NODE_ENV=developmentDATABASE_URL=postgresql://localhost/myapp_devREDIS_URL=redis://localhost:6379LOG_LEVEL=debug
To customize these variables, edit the PRESET_ENV_VARS array in the dcc script.
Since this is a bash script, test changes by:
# Source the script to test functions in current shell
source ./ccm
# Test individual functions
provider_glm --no-run
provider_mmx --no-run
provider_clrTo add a new AI provider:
- Add the API key to
apikeys.json - Create a
set_<provider>_vars()function to set provider-specific environment variables - Create a
provider_<provider>()function following the existing pattern:- Call
clear_vars - Load API key with
load_api_key "<provider>" - Export
ANTHROPIC_AUTH_TOKENorANTHROPIC_API_KEY - Call the provider's vars function
- Handle
--no-runflag
- Call
- Add the provider name to the
casestatement inmain() - Update the
usage()function
Note for OpenRouter: When adding OpenRouter or similar proxies, ensure ANTHROPIC_API_KEY is explicitly set to an empty string to prevent authentication conflicts with Anthropic servers.