claude-ai-switcher 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +265 -0
- package/ARCHITECTURE.md +162 -0
- package/CLAUDE.md +267 -0
- package/LICENSE +21 -0
- package/QWEN.md +429 -0
- package/README.md +833 -0
- package/dist/clients/claude-code.d.ts +92 -0
- package/dist/clients/claude-code.d.ts.map +1 -0
- package/dist/clients/claude-code.js +312 -0
- package/dist/clients/claude-code.js.map +1 -0
- package/dist/clients/opencode.d.ts +71 -0
- package/dist/clients/opencode.d.ts.map +1 -0
- package/dist/clients/opencode.js +604 -0
- package/dist/clients/opencode.js.map +1 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +122 -0
- package/dist/config.js.map +1 -0
- package/dist/display.d.ts +51 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +118 -0
- package/dist/display.js.map +1 -0
- package/dist/hooks/index.d.ts +60 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +223 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/token-tracker.js +280 -0
- package/dist/hooks/visual-enhancements.js +364 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1091 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +34 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +343 -0
- package/dist/models.js.map +1 -0
- package/dist/providers/alibaba.d.ts +25 -0
- package/dist/providers/alibaba.d.ts.map +1 -0
- package/dist/providers/alibaba.js +37 -0
- package/dist/providers/alibaba.js.map +1 -0
- package/dist/providers/anthropic.d.ts +14 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +19 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/gemini.d.ts +44 -0
- package/dist/providers/gemini.d.ts.map +1 -0
- package/dist/providers/gemini.js +156 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/glm.d.ts +25 -0
- package/dist/providers/glm.d.ts.map +1 -0
- package/dist/providers/glm.js +89 -0
- package/dist/providers/glm.js.map +1 -0
- package/dist/providers/ollama.d.ts +48 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +174 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openrouter.d.ts +24 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +36 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/verify.d.ts +24 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +262 -0
- package/dist/verify.js.map +1 -0
- package/package.json +57 -0
- package/scripts/copy-hooks.js +15 -0
- package/src/clients/claude-code.ts +340 -0
- package/src/clients/opencode.ts +618 -0
- package/src/config.ts +101 -0
- package/src/display.ts +151 -0
- package/src/hooks/index.ts +208 -0
- package/src/hooks/token-tracker.js +280 -0
- package/src/hooks/visual-enhancements.js +364 -0
- package/src/index.ts +1263 -0
- package/src/models.ts +366 -0
- package/src/providers/alibaba.ts +43 -0
- package/src/providers/anthropic.ts +23 -0
- package/src/providers/gemini.ts +136 -0
- package/src/providers/glm.ts +60 -0
- package/src/providers/ollama.ts +146 -0
- package/src/providers/openrouter.ts +42 -0
- package/src/verify.ts +258 -0
- package/tsconfig.json +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,833 @@
|
|
|
1
|
+
# Claude AI Switcher
|
|
2
|
+
|
|
3
|
+
Switch between AI providers (Anthropic, GLM, Alibaba Qwen, OpenRouter, Ollama, Gemini) for **Claude Code** with ease. Also provides helper commands to manage providers for **OpenCode**.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Quick Switching**: Switch between Anthropic, GLM/Z.AI, Alibaba Coding Plan, OpenRouter, Ollama (local), and Gemini (Google) with a single command
|
|
8
|
+
- **Model Aliases**: Automatically sets `ANTHROPIC_DEFAULT_OPUS_MODEL`, `ANTHROPIC_DEFAULT_SONNET_MODEL`, and `ANTHROPIC_DEFAULT_HAIKU_MODEL` in Claude Code's settings so you always know what model is active
|
|
9
|
+
- **Custom Tier Overrides**: Use `--opus`, `--sonnet`, `--haiku` to pin specific models per tier
|
|
10
|
+
- **API Key Verification**: Run `claude-switch status` to check current config and verify API keys are valid
|
|
11
|
+
- **Local Models**: Use Ollama for fully local, private AI with DeepSeek R1, Qwen, Llama, and more
|
|
12
|
+
- **Google Gemini**: Access Gemini 2.5 Pro/Flash models with 1M context via LiteLLM proxy
|
|
13
|
+
- **Auto Proxy Management**: Automatically starts LiteLLM translation proxy for Ollama and Gemini
|
|
14
|
+
- **Model Information**: See model capabilities, context windows, and descriptions when switching
|
|
15
|
+
- **Token Tracking**: Visual context bar with percentage usage display
|
|
16
|
+
- **Visual Enhancements**: Model card with provider info, active model display, and context usage
|
|
17
|
+
- **Secure Storage**: API keys stored locally in `~/.claude-ai-switcher/config.json`
|
|
18
|
+
- **Safe Configuration**: Backs up existing settings before any modifications
|
|
19
|
+
- **Auto Onboarding**: Automatically sets `hasCompletedOnboarding: true` to prevent connection errors
|
|
20
|
+
- **OpenCode Helper**: Add/remove provider configurations for OpenCode with simple commands
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cd claude-ai-switcher
|
|
26
|
+
npm ci # reproducible install from package-lock.json (does NOT modify it)
|
|
27
|
+
npm run build
|
|
28
|
+
npm link # Install globally
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
> **Dependency flow:** Use `npm ci` for routine installs and after every pull — it installs exactly from `package-lock.json` and never modifies it, so it can't drift the lockfile or cause pull conflicts. Use `npm install <package>` or `npm update` only when intentionally adding or upgrading a dependency, then commit the updated `package-lock.json`.
|
|
32
|
+
|
|
33
|
+
## Platform Support
|
|
34
|
+
|
|
35
|
+
| Platform | Status | Notes |
|
|
36
|
+
|----------|--------|-------|
|
|
37
|
+
| macOS | ✅ Full Support | Default development platform |
|
|
38
|
+
| Linux | ✅ Full Support | All features supported |
|
|
39
|
+
| Windows 11 | ✅ Full Support | Use Git Bash, WSL, or PowerShell for build commands |
|
|
40
|
+
|
|
41
|
+
### Windows Notes
|
|
42
|
+
|
|
43
|
+
- Build commands (`npm ci`, `npm run build`) should be run in Git Bash, WSL, or PowerShell
|
|
44
|
+
- The CLI works in any terminal after installation
|
|
45
|
+
- GLM/Z.AI provider requires `coding-helper` to be in your PATH
|
|
46
|
+
- The `clean` script uses `rimraf` for cross-platform compatibility
|
|
47
|
+
|
|
48
|
+
## Quick Start
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Run setup wizard (recommended for first-time use)
|
|
52
|
+
claude-switch setup
|
|
53
|
+
|
|
54
|
+
# Switch Claude Code to Alibaba Coding Plan
|
|
55
|
+
claude-switch alibaba
|
|
56
|
+
|
|
57
|
+
# Switch Claude Code with specific model
|
|
58
|
+
claude-switch alibaba qwen3.6-plus
|
|
59
|
+
|
|
60
|
+
# Switch Claude Code to OpenRouter (free models)
|
|
61
|
+
claude-switch openrouter
|
|
62
|
+
|
|
63
|
+
# Switch to local Ollama models (requires LiteLLM proxy)
|
|
64
|
+
claude-switch ollama
|
|
65
|
+
|
|
66
|
+
# Switch to Google Gemini (requires LiteLLM proxy)
|
|
67
|
+
claude-switch gemini
|
|
68
|
+
|
|
69
|
+
# Switch back to default Anthropic
|
|
70
|
+
claude-switch anthropic
|
|
71
|
+
|
|
72
|
+
# Add Alibaba provider to OpenCode
|
|
73
|
+
claude-switch opencode add alibaba
|
|
74
|
+
|
|
75
|
+
# Add OpenRouter provider to OpenCode
|
|
76
|
+
claude-switch opencode add openrouter
|
|
77
|
+
|
|
78
|
+
# Add Ollama, Gemini, or GLM provider to OpenCode
|
|
79
|
+
claude-switch opencode add ollama
|
|
80
|
+
claude-switch opencode add gemini
|
|
81
|
+
claude-switch opencode add glm
|
|
82
|
+
|
|
83
|
+
# Remove providers
|
|
84
|
+
claude-switch opencode remove alibaba
|
|
85
|
+
claude-switch opencode remove openrouter
|
|
86
|
+
claude-switch opencode remove ollama
|
|
87
|
+
claude-switch opencode remove gemini
|
|
88
|
+
claude-switch opencode remove glm
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Commands
|
|
92
|
+
|
|
93
|
+
### Switch Claude Code (top-level commands)
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
claude-switch anthropic
|
|
97
|
+
claude-switch alibaba
|
|
98
|
+
claude-switch alibaba qwen3.6-plus # specific model
|
|
99
|
+
claude-switch glm
|
|
100
|
+
claude-switch openrouter # default: qwen/qwen3.6-plus:free
|
|
101
|
+
claude-switch openrouter openrouter/free # specific model
|
|
102
|
+
claude-switch ollama # default: deepseek-r1:latest (starts proxy)
|
|
103
|
+
claude-switch ollama qwen2.5-coder:latest # specific model
|
|
104
|
+
claude-switch gemini # default: gemini-2.5-pro (starts proxy)
|
|
105
|
+
claude-switch gemini gemini-2.5-flash # specific model
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Switch Claude Code (explicit targeting)
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
claude-switch claude anthropic
|
|
112
|
+
claude-switch claude alibaba
|
|
113
|
+
claude-switch claude alibaba qwen3.6-plus
|
|
114
|
+
claude-switch claude glm
|
|
115
|
+
claude-switch claude openrouter
|
|
116
|
+
claude-switch claude openrouter qwen/qwen3.6-plus:free
|
|
117
|
+
claude-switch claude ollama
|
|
118
|
+
claude-switch claude ollama deepseek-r1:latest
|
|
119
|
+
claude-switch claude gemini
|
|
120
|
+
claude-switch claude gemini gemini-2.5-flash
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### OpenCode Helper Commands
|
|
124
|
+
|
|
125
|
+
Add or remove providers from OpenCode configuration:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Add providers to OpenCode
|
|
129
|
+
claude-switch opencode add alibaba
|
|
130
|
+
claude-switch opencode add openrouter
|
|
131
|
+
claude-switch opencode add ollama
|
|
132
|
+
claude-switch opencode add gemini
|
|
133
|
+
claude-switch opencode add glm
|
|
134
|
+
|
|
135
|
+
# Remove providers from OpenCode
|
|
136
|
+
claude-switch opencode remove alibaba
|
|
137
|
+
claude-switch opencode remove openrouter
|
|
138
|
+
claude-switch opencode remove ollama
|
|
139
|
+
claude-switch opencode remove gemini
|
|
140
|
+
claude-switch opencode remove glm
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Note**: OpenCode configuration is stored at `~/.config/opencode/opencode.json`. The `add` command adds the provider with all available models. The `remove` command removes only the specified provider, preserving any other providers you have configured.
|
|
144
|
+
|
|
145
|
+
### Model Aliases (Claude Code)
|
|
146
|
+
|
|
147
|
+
When switching Claude Code to a non-Anthropic provider, the tool writes model alias env vars into `~/.claude/settings.json` so Claude Code knows which model to route each tier to:
|
|
148
|
+
|
|
149
|
+
| Env Var | Default (Alibaba) | Default (GLM) | Default (OpenRouter) | Default (Ollama) | Default (Gemini) |
|
|
150
|
+
|---------|-------------------|---------------|---------------------|-----------------|-----------------|
|
|
151
|
+
| `ANTHROPIC_DEFAULT_OPUS_MODEL` | `qwen3.7-plus` | `glm-5.2[1m]` | `qwen/qwen3.6-plus:free` | `deepseek-r1:latest` | `gemini-2.5-pro` |
|
|
152
|
+
| `ANTHROPIC_DEFAULT_SONNET_MODEL` | `qwen3.6-plus` | `glm-5-turbo` | `openrouter/free` | `qwen2.5-coder:latest` | `gemini-2.5-flash` |
|
|
153
|
+
| `ANTHROPIC_DEFAULT_HAIKU_MODEL` | `kimi-k2.5` | `glm-5v-turbo` | `openrouter/free` | `llama3.1:latest` | `gemini-2.5-flash-lite` |
|
|
154
|
+
|
|
155
|
+
Override any tier at switch time:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Set all three tiers (default for Alibaba)
|
|
159
|
+
claude-switch alibaba qwen3.7-plus
|
|
160
|
+
|
|
161
|
+
# Override individual tiers
|
|
162
|
+
claude-switch alibaba --opus qwen3-max-2026-01-23 --sonnet qwen3.6-plus --haiku kimi-k2.5
|
|
163
|
+
|
|
164
|
+
# Custom configuration with specific model assignments
|
|
165
|
+
claude-switch alibaba --opus qwen3.7-plus --sonnet qwen3.6-plus --haiku kimi-k2.5
|
|
166
|
+
|
|
167
|
+
# GLM with custom haiku tier
|
|
168
|
+
claude-switch glm --haiku glm-4.7
|
|
169
|
+
|
|
170
|
+
# OpenRouter with custom tiers
|
|
171
|
+
claude-switch openrouter --sonnet qwen/qwen3.6-plus:free --haiku openrouter/free
|
|
172
|
+
|
|
173
|
+
# Ollama with custom tiers
|
|
174
|
+
claude-switch ollama --opus deepseek-r1:latest --sonnet qwen2.5-coder:latest
|
|
175
|
+
|
|
176
|
+
# Gemini with custom tiers
|
|
177
|
+
claude-switch gemini --opus gemini-2.5-pro --haiku gemini-2.5-flash-lite
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Switching back to Anthropic clears these env vars so native Claude models are used again.
|
|
181
|
+
|
|
182
|
+
### View Information
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Show current config + verify API keys (recommended)
|
|
186
|
+
claude-switch status
|
|
187
|
+
|
|
188
|
+
# Show current configuration for both clients
|
|
189
|
+
claude-switch current
|
|
190
|
+
|
|
191
|
+
# List all providers and models
|
|
192
|
+
claude-switch list
|
|
193
|
+
|
|
194
|
+
# Show models for specific provider
|
|
195
|
+
claude-switch models alibaba
|
|
196
|
+
claude-switch models glm
|
|
197
|
+
claude-switch models anthropic
|
|
198
|
+
claude-switch models openrouter
|
|
199
|
+
claude-switch models ollama
|
|
200
|
+
claude-switch models gemini
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### API Key Management
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Set API key
|
|
207
|
+
claude-switch key alibaba <your-api-key>
|
|
208
|
+
claude-switch key openrouter <your-api-key>
|
|
209
|
+
claude-switch key gemini <your-api-key>
|
|
210
|
+
|
|
211
|
+
# Check if API key is set
|
|
212
|
+
claude-switch key alibaba
|
|
213
|
+
claude-switch key openrouter
|
|
214
|
+
claude-switch key gemini
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
> **Note**: Ollama does not require an API key (runs locally). Anthropic uses the `ANTHROPIC_API_KEY` environment variable.
|
|
218
|
+
|
|
219
|
+
### Hooks - Token Tracking & Visual Enhancements
|
|
220
|
+
|
|
221
|
+
Install visual enhancements and token tracking for Claude Code:
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
# Install all hooks (token tracker + visual enhancements)
|
|
225
|
+
claude-switch hooks install
|
|
226
|
+
|
|
227
|
+
✓ Hooks installed successfully!
|
|
228
|
+
|
|
229
|
+
Installed:
|
|
230
|
+
• Token Tracker (~/.claude/token-tracker.js)
|
|
231
|
+
• Visual Enhancements (~/.claude/visual-enhancements.js)
|
|
232
|
+
|
|
233
|
+
Usage:
|
|
234
|
+
• Token usage is tracked automatically
|
|
235
|
+
• Run 'claude-switch hooks status' to see current usage
|
|
236
|
+
• Run 'claude-switch hooks reset' to reset counters
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Show current token usage and visual status
|
|
241
|
+
claude-switch hooks status
|
|
242
|
+
|
|
243
|
+
=== Hooks Status ===
|
|
244
|
+
|
|
245
|
+
Token Tracker: ✓ Installed
|
|
246
|
+
Visual Enhancements: ✓ Installed
|
|
247
|
+
|
|
248
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
249
|
+
║ 🤖 Active Model: Qwen3 6 Plus ║
|
|
250
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
251
|
+
║ 📊 Token Usage: ║
|
|
252
|
+
║ Input: 12,450 tokens ║
|
|
253
|
+
║ Output: 8,320 tokens ║
|
|
254
|
+
║ Total: 20,770 tokens ║
|
|
255
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
256
|
+
║ 📈 Context Window: ║
|
|
257
|
+
║ Used: 20,770 tokens ║
|
|
258
|
+
║ Total: 1,000,000 tokens ║
|
|
259
|
+
║ ████░░░░░░░░░░░░░░░░ 2.1% ║
|
|
260
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Reset token usage counters
|
|
265
|
+
claude-switch hooks reset
|
|
266
|
+
|
|
267
|
+
Token usage reset complete.
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# Remove all hooks
|
|
272
|
+
claude-switch hooks remove
|
|
273
|
+
|
|
274
|
+
✓ All hooks removed
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**What you get:**
|
|
278
|
+
|
|
279
|
+
| Feature | Description |
|
|
280
|
+
|---------|-------------|
|
|
281
|
+
| **Token Tracker** | Tracks input/output tokens across your session with visual percentage bar |
|
|
282
|
+
| **Model Card** | Shows active model, provider, context window, and capabilities |
|
|
283
|
+
| **Context Bar** | Visual progress bar showing context usage percentage (color-coded) |
|
|
284
|
+
| **Auto Display** | Shows model info and token usage when you start a Claude Code session |
|
|
285
|
+
|
|
286
|
+
**Context Bar Colors:**
|
|
287
|
+
|
|
288
|
+
| Color | Usage Range | Meaning |
|
|
289
|
+
|-------|-------------|---------|
|
|
290
|
+
| 🟢 Green | 0-50% | Safe usage |
|
|
291
|
+
| 🟡 Yellow | 50-75% | Moderate usage |
|
|
292
|
+
| 🔴 Red | 75-90% | High usage |
|
|
293
|
+
| 🟣 Magenta | 90-100% | Critical - approaching limit |
|
|
294
|
+
|
|
295
|
+
**Example Output:**
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
# Token tracker standalone display
|
|
299
|
+
node ~/.claude/token-tracker.js
|
|
300
|
+
|
|
301
|
+
╔══════════════════════════════════════════════════════════════╗
|
|
302
|
+
║ 🤖 Active Model: GLM 5 1 ║
|
|
303
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
304
|
+
║ 📊 Token Usage: ║
|
|
305
|
+
║ Input: 45,200 tokens ║
|
|
306
|
+
║ Output: 32,100 tokens ║
|
|
307
|
+
║ Total: 77,300 tokens ║
|
|
308
|
+
╠══════════════════════════════════════════════════════════════╣
|
|
309
|
+
║ 📈 Context Window: ║
|
|
310
|
+
║ Used: 77,300 tokens ║
|
|
311
|
+
║ Total: 200,000 tokens ║
|
|
312
|
+
║ ████████████░░░░░░░░ 38.7% ║
|
|
313
|
+
╚══════════════════════════════════════════════════════════════╝
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
# Visual enhancements standalone display
|
|
318
|
+
node ~/.claude/visual-enhancements.js
|
|
319
|
+
|
|
320
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
321
|
+
│ 🤖 Alibaba Model Studio │
|
|
322
|
+
├─────────────────────────────────────────────────────────────┤
|
|
323
|
+
│ Model: qwen3.6-plus │
|
|
324
|
+
│ Context: 1M tokens │
|
|
325
|
+
│ Capabilities: │
|
|
326
|
+
│ Text Generation • Deep Thinking • Visual Understanding │
|
|
327
|
+
─────────────────────────────────────────────────────────────┘
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Setup
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
# Interactive setup wizard
|
|
334
|
+
claude-switch setup
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Available Models
|
|
338
|
+
|
|
339
|
+
### Alibaba Coding Plan
|
|
340
|
+
|
|
341
|
+
| Model | Context | Capabilities |
|
|
342
|
+
|-------|---------|--------------|
|
|
343
|
+
| qwen3.7-plus | 1M tokens | Text Generation, Deep Thinking, Visual Understanding |
|
|
344
|
+
| qwen3.6-plus | 1M tokens | Text Generation, Deep Thinking, Visual Understanding |
|
|
345
|
+
| qwen3-max-2026-01-23 | 262K tokens | Text Generation, Deep Thinking |
|
|
346
|
+
| qwen3-coder-next | 262K tokens | Text Generation (Advanced Coding Agent) |
|
|
347
|
+
| qwen3-coder-plus | 1M tokens | Text Generation (Code, Tool Calling, Autonomous) |
|
|
348
|
+
| glm-5 | 200K tokens | Text Generation, Deep Thinking |
|
|
349
|
+
| glm-4.7 | 256K tokens | Text Generation, Deep Thinking |
|
|
350
|
+
| glm-4.7-flash | 256K tokens | Text Generation, Fast Inference |
|
|
351
|
+
| kimi-k2.5 | 200K tokens | Text Generation, Deep Thinking, Visual |
|
|
352
|
+
| MiniMax-M2.5 | 200K tokens | Text Generation, Deep Thinking |
|
|
353
|
+
|
|
354
|
+
### GLM/Z.AI (via coding-helper)
|
|
355
|
+
|
|
356
|
+
| Model | Context | Capabilities |
|
|
357
|
+
|-------|---------|--------------|
|
|
358
|
+
| glm-5.2[1m] | 1M tokens | Text Generation, Deep Thinking |
|
|
359
|
+
| glm-5v-turbo | 200K tokens | Text Generation, Deep Thinking, Visual Understanding, Visual Programming |
|
|
360
|
+
| glm-5-turbo | 200K tokens | Text Generation, Deep Thinking, Fast Responses |
|
|
361
|
+
| glm-5.1 | 200K tokens | Text Generation, Deep Thinking |
|
|
362
|
+
| glm-4.7 | 256K tokens | Text Generation, Deep Thinking |
|
|
363
|
+
|
|
364
|
+
### Anthropic (Default)
|
|
365
|
+
|
|
366
|
+
| Model | Context | Capabilities |
|
|
367
|
+
|-------|---------|--------------|
|
|
368
|
+
| claude-opus-4-6-20250205 | 200K tokens | Text, Code, Vision, Complex Reasoning |
|
|
369
|
+
| claude-opus-4-5-20251101 | 200K tokens | Text, Code, Vision, Complex Reasoning |
|
|
370
|
+
| claude-sonnet-4-6-20250219 | 200K tokens | Text, Code, Vision |
|
|
371
|
+
| claude-sonnet-4-5-20250814 | 200K tokens | Text, Code, Vision |
|
|
372
|
+
| claude-haiku-4-5-20251015 | 200K tokens | Text, Fast Responses |
|
|
373
|
+
|
|
374
|
+
### OpenRouter
|
|
375
|
+
|
|
376
|
+
| Model | Context | Capabilities |
|
|
377
|
+
|-------|---------|--------------|
|
|
378
|
+
| `qwen/qwen3.6-plus:free` | 131K tokens | Text Generation, Deep Thinking |
|
|
379
|
+
| `openrouter/free` | 131K tokens | Text Generation |
|
|
380
|
+
|
|
381
|
+
### Ollama (Local, via LiteLLM proxy)
|
|
382
|
+
|
|
383
|
+
| Model | Context | Capabilities |
|
|
384
|
+
|-------|---------|--------------|
|
|
385
|
+
| `deepseek-r1:latest` | 128K tokens | Text Generation, Deep Thinking, Reasoning |
|
|
386
|
+
| `qwen2.5-coder:latest` | 128K tokens | Text Generation, Coding, Tool Calling |
|
|
387
|
+
| `llama3.1:latest` | 128K tokens | Text Generation, Code, Vision |
|
|
388
|
+
| `codellama:latest` | 100K tokens | Text Generation, Coding |
|
|
389
|
+
|
|
390
|
+
> **Prerequisites**: [Ollama](https://ollama.com) must be installed and running on port 11434. [LiteLLM](https://github.com/BerriAI/litellm) proxy is auto-started on port 4000.
|
|
391
|
+
|
|
392
|
+
### Gemini (Google, via LiteLLM proxy)
|
|
393
|
+
|
|
394
|
+
| Model | Context | Capabilities |
|
|
395
|
+
|-------|---------|--------------|
|
|
396
|
+
| `gemini-2.5-pro` | 1M tokens | Text Generation, Deep Thinking, Code, Vision |
|
|
397
|
+
| `gemini-2.5-flash` | 1M tokens | Text Generation, Fast Responses, Code |
|
|
398
|
+
| `gemini-2.5-flash-lite` | 1M tokens | Text Generation, Cost-optimized |
|
|
399
|
+
|
|
400
|
+
> **Prerequisites**: Google API key from [AI Studio](https://aistudio.google.com/apikey). [LiteLLM](https://github.com/BerriAI/litellm) proxy is auto-started on port 4001.
|
|
401
|
+
|
|
402
|
+
## Configuration Files
|
|
403
|
+
|
|
404
|
+
| Client | Config File | Purpose |
|
|
405
|
+
|--------|-------------|---------|
|
|
406
|
+
| Claude Code | `~/.claude/settings.json` | Environment variables for provider config + model alias env vars |
|
|
407
|
+
| Claude Code | `~/.claude.json` | `hasCompletedOnboarding` flag |
|
|
408
|
+
| OpenCode | `~/.config/opencode/opencode.json` | Provider configuration (bailian-coding-plan) |
|
|
409
|
+
| API Keys | `~/.claude-ai-switcher/config.json` | Secure local API key storage |
|
|
410
|
+
|
|
411
|
+
## How It Works
|
|
412
|
+
|
|
413
|
+
### Provider Architecture
|
|
414
|
+
|
|
415
|
+
```
|
|
416
|
+
┌─────────────┐ ┌──────────────┐ ┌───────────────────┐
|
|
417
|
+
│ Claude Code │────►│ ANTHROPIC_ │────►│ Target Provider │
|
|
418
|
+
│ / OpenCode │ │ BASE_URL │ │ │
|
|
419
|
+
└─────────────┘ └──────────────┘ ├───────────────────┤
|
|
420
|
+
│ Anthropic (direct)│
|
|
421
|
+
│ Alibaba (direct)│
|
|
422
|
+
│ OpenRouter(direct)│
|
|
423
|
+
│ GLM (via helper) │
|
|
424
|
+
├───────────────────┤
|
|
425
|
+
│ LiteLLM Proxy │
|
|
426
|
+
│ ├─ Ollama :4000 │
|
|
427
|
+
│ └─ Gemini :4001 │
|
|
428
|
+
└───────────────────┘
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
Anthropic, Alibaba, OpenRouter, and GLM speak the Anthropic API format natively. Ollama and Gemini only speak OpenAI format, so a **LiteLLM proxy** translates between protocols. The proxy is auto-started when you switch to Ollama or Gemini.
|
|
432
|
+
|
|
433
|
+
### Claude Code Configuration
|
|
434
|
+
|
|
435
|
+
When you switch Claude Code to Alibaba, the tool writes these environment variables to `~/.claude/settings.json`:
|
|
436
|
+
|
|
437
|
+
```json
|
|
438
|
+
{
|
|
439
|
+
"env": {
|
|
440
|
+
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
|
|
441
|
+
"ANTHROPIC_BASE_URL": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic",
|
|
442
|
+
"ANTHROPIC_MODEL": "qwen3.7-plus",
|
|
443
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.7-plus",
|
|
444
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.6-plus",
|
|
445
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "kimi-k2.5"
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
- `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_BASE_URL`, `ANTHROPIC_MODEL` — Route Claude Code to Alibaba's endpoint
|
|
451
|
+
- `ANTHROPIC_DEFAULT_*_MODEL` — Map Claude's model tiers (opus/sonnet/haiku) to specific Alibaba models
|
|
452
|
+
|
|
453
|
+
Switching back to Anthropic clears all these env vars.
|
|
454
|
+
|
|
455
|
+
### Ollama Configuration
|
|
456
|
+
|
|
457
|
+
When you switch Claude Code to Ollama, the tool:
|
|
458
|
+
|
|
459
|
+
1. Checks that LiteLLM and Ollama are installed and Ollama is running
|
|
460
|
+
2. Starts a LiteLLM proxy on port 4000 (if not already running)
|
|
461
|
+
3. Writes these environment variables to `~/.claude/settings.json`:
|
|
462
|
+
|
|
463
|
+
```json
|
|
464
|
+
{
|
|
465
|
+
"env": {
|
|
466
|
+
"ANTHROPIC_AUTH_TOKEN": "ollama",
|
|
467
|
+
"ANTHROPIC_BASE_URL": "http://localhost:4000",
|
|
468
|
+
"ANTHROPIC_MODEL": "deepseek-r1:latest",
|
|
469
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-r1:latest",
|
|
470
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen2.5-coder:latest",
|
|
471
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "llama3.1:latest"
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### Gemini Configuration
|
|
477
|
+
|
|
478
|
+
When you switch Claude Code to Gemini, the tool:
|
|
479
|
+
|
|
480
|
+
1. Checks that LiteLLM is installed
|
|
481
|
+
2. Prompts for a Google API key (if not already saved)
|
|
482
|
+
3. Starts a LiteLLM proxy on port 4001 (if not already running)
|
|
483
|
+
4. Writes these environment variables to `~/.claude/settings.json`:
|
|
484
|
+
|
|
485
|
+
```json
|
|
486
|
+
{
|
|
487
|
+
"env": {
|
|
488
|
+
"ANTHROPIC_AUTH_TOKEN": "YOUR_GEMINI_API_KEY",
|
|
489
|
+
"ANTHROPIC_BASE_URL": "http://localhost:4001",
|
|
490
|
+
"ANTHROPIC_MODEL": "gemini-2.5-pro",
|
|
491
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "gemini-2.5-pro",
|
|
492
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "gemini-2.5-flash",
|
|
493
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemini-2.5-flash-lite"
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### OpenRouter Configuration
|
|
499
|
+
|
|
500
|
+
When you switch Claude Code to OpenRouter, the tool writes these environment variables to `~/.claude/settings.json`:
|
|
501
|
+
|
|
502
|
+
```json
|
|
503
|
+
{
|
|
504
|
+
"env": {
|
|
505
|
+
"ANTHROPIC_AUTH_TOKEN": "YOUR_OPENROUTER_API_KEY",
|
|
506
|
+
"ANTHROPIC_BASE_URL": "https://openrouter.ai/api/v1",
|
|
507
|
+
"ANTHROPIC_MODEL": "qwen/qwen3.6-plus:free",
|
|
508
|
+
"ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen/qwen3.6-plus:free",
|
|
509
|
+
"ANTHROPIC_DEFAULT_SONNET_MODEL": "openrouter/free",
|
|
510
|
+
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "openrouter/free"
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### OpenCode Configuration
|
|
516
|
+
|
|
517
|
+
When you run `claude-switch opencode add alibaba`, the tool writes the `bailian-coding-plan` provider to `~/.config/opencode/opencode.json`:
|
|
518
|
+
|
|
519
|
+
```json
|
|
520
|
+
{
|
|
521
|
+
"$schema": "https://opencode.ai/config.json",
|
|
522
|
+
"provider": {
|
|
523
|
+
"bailian-coding-plan": {
|
|
524
|
+
"npm": "@ai-sdk/anthropic",
|
|
525
|
+
"name": "Model Studio Coding Plan",
|
|
526
|
+
"options": {
|
|
527
|
+
"baseURL": "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic/v1",
|
|
528
|
+
"apiKey": "YOUR_API_KEY"
|
|
529
|
+
},
|
|
530
|
+
"models": {
|
|
531
|
+
"qwen3.6-plus": { ... },
|
|
532
|
+
"qwen3-max-2026-01-23": { ... },
|
|
533
|
+
"qwen3-coder-next": { ... },
|
|
534
|
+
"qwen3-coder-plus": { ... },
|
|
535
|
+
"MiniMax-M2.5": { ... },
|
|
536
|
+
"glm-5": { ... },
|
|
537
|
+
"glm-4.7": { ... },
|
|
538
|
+
"kimi-k2.5": { ... }
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
Running `claude-switch opencode remove alibaba` removes only the `bailian-coding-plan` provider, preserving any other providers you have configured.
|
|
546
|
+
|
|
547
|
+
### GLM/Z.AI Configuration
|
|
548
|
+
|
|
549
|
+
GLM uses the `@z_ai/coding-helper` package to manage its configuration. For Claude Code, the tool triggers `coding-helper auth reload claude` to apply GLM settings, plus sets the model tier aliases.
|
|
550
|
+
|
|
551
|
+
For OpenCode, run `claude-switch opencode add glm` to add the GLM provider. This reads the auth credentials from Claude Code's settings (set by `coding-helper auth reload claude`) and writes the GLM provider config with all models to `~/.config/opencode/opencode.json`:
|
|
552
|
+
|
|
553
|
+
```bash
|
|
554
|
+
# Set up GLM auth in Claude Code first
|
|
555
|
+
claude-switch glm
|
|
556
|
+
|
|
557
|
+
# Then add to OpenCode
|
|
558
|
+
claude-switch opencode add glm
|
|
559
|
+
|
|
560
|
+
# Remove when done
|
|
561
|
+
claude-switch opencode remove glm
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Example Output
|
|
565
|
+
|
|
566
|
+
```bash
|
|
567
|
+
$ claude-switch status
|
|
568
|
+
|
|
569
|
+
=== Claude AI Switcher Status ===
|
|
570
|
+
|
|
571
|
+
Claude Code:
|
|
572
|
+
Provider: anthropic
|
|
573
|
+
|
|
574
|
+
OpenCode:
|
|
575
|
+
Provider: anthropic
|
|
576
|
+
|
|
577
|
+
API Key Verification:
|
|
578
|
+
──────────────────────────────────────────────────
|
|
579
|
+
○ alibaba No key configured
|
|
580
|
+
○ openrouter No key configured
|
|
581
|
+
○ anthropic No key configured
|
|
582
|
+
✓ glm coding-helper installed
|
|
583
|
+
──────────────────────────────────────────────────
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
```bash
|
|
587
|
+
$ claude-switch alibaba qwen3.7-plus
|
|
588
|
+
|
|
589
|
+
✓ Switched to: Alibaba Coding Plan
|
|
590
|
+
────────────────────────────────────────────────────────────
|
|
591
|
+
Model: Qwen3.7-Plus
|
|
592
|
+
Context: 1M tokens
|
|
593
|
+
Endpoint: https://coding-intl.dashscope.aliyuncs.com/apps/anthropic
|
|
594
|
+
Capabilities: Text Generation, Deep Thinking, Visual Understanding
|
|
595
|
+
Most capable Qwen model with balanced performance, speed, and cost...
|
|
596
|
+
|
|
597
|
+
Claude model aliases:
|
|
598
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL → qwen3.7-plus
|
|
599
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL → qwen3.6-plus
|
|
600
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL → kimi-k2.5
|
|
601
|
+
```
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
$ claude-switch opencode add alibaba
|
|
605
|
+
|
|
606
|
+
✓ Added Alibaba Coding Plan provider to OpenCode
|
|
607
|
+
Config: ~/.config/opencode/opencode.json
|
|
608
|
+
Provider: bailian-coding-plan
|
|
609
|
+
Models: qwen3.7-plus, qwen3.6-plus, qwen3-max-2026-01-23, qwen3-coder-next, qwen3-coder-plus, MiniMax-M2.5, glm-5, glm-4.7, kimi-k2.5
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
```bash
|
|
613
|
+
$ claude-switch glm --opus glm-5.2[1m] --sonnet glm-5-turbo --haiku glm-5v-turbo
|
|
614
|
+
|
|
615
|
+
✓ Switched to GLM/Z.AI
|
|
616
|
+
|
|
617
|
+
Claude model aliases:
|
|
618
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL → glm-5.2[1m]
|
|
619
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL → glm-5-turbo
|
|
620
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL → glm-5v-turbo
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
```bash
|
|
624
|
+
$ claude-switch openrouter
|
|
625
|
+
|
|
626
|
+
✓ Switched to: OpenRouter
|
|
627
|
+
────────────────────────────────────────────────────────────
|
|
628
|
+
Model: Qwen3.6 Plus (Free)
|
|
629
|
+
Context: 131K tokens
|
|
630
|
+
Endpoint: https://openrouter.ai/api/v1
|
|
631
|
+
Capabilities: Text Generation, Deep Thinking
|
|
632
|
+
Free Qwen3.6 Plus model via OpenRouter with strong reasoning capabilities.
|
|
633
|
+
|
|
634
|
+
Claude model aliases:
|
|
635
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL → qwen/qwen3.6-plus:free
|
|
636
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL → openrouter/free
|
|
637
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL → openrouter/free
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
```bash
|
|
641
|
+
$ claude-switch ollama deepseek-r1:latest
|
|
642
|
+
|
|
643
|
+
✓ Switched to: Ollama (Local)
|
|
644
|
+
────────────────────────────────────────────────────────────
|
|
645
|
+
Model: DeepSeek R1
|
|
646
|
+
Context: 128K tokens
|
|
647
|
+
Endpoint: http://localhost:4000 (LiteLLM proxy)
|
|
648
|
+
Capabilities: Text Generation, Deep Thinking, Reasoning
|
|
649
|
+
DeepSeek's reasoning model with deep thinking capabilities.
|
|
650
|
+
|
|
651
|
+
Claude model aliases:
|
|
652
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL → deepseek-r1:latest
|
|
653
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL → qwen2.5-coder:latest
|
|
654
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL → llama3.1:latest
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
```bash
|
|
658
|
+
$ claude-switch gemini
|
|
659
|
+
|
|
660
|
+
✓ Switched to: Gemini (Google)
|
|
661
|
+
────────────────────────────────────────────────────────────
|
|
662
|
+
Model: Gemini 2.5 Pro
|
|
663
|
+
Context: 1M tokens
|
|
664
|
+
Endpoint: http://localhost:4001 (LiteLLM proxy)
|
|
665
|
+
Capabilities: Text Generation, Deep Thinking, Code, Vision
|
|
666
|
+
Google's most capable Gemini model with deep thinking.
|
|
667
|
+
|
|
668
|
+
Claude model aliases:
|
|
669
|
+
ANTHROPIC_DEFAULT_OPUS_MODEL → gemini-2.5-pro
|
|
670
|
+
ANTHROPIC_DEFAULT_SONNET_MODEL → gemini-2.5-flash
|
|
671
|
+
ANTHROPIC_DEFAULT_HAIKU_MODEL → gemini-2.5-flash-lite
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
## Project Documentation (Zread)
|
|
675
|
+
|
|
676
|
+
This repository includes an AI-generated project wiki in `.zread/` created with [Zread CLI](https://zread.ai/cli). It provides detailed architectural walkthroughs, module breakdowns, and implementation guides.
|
|
677
|
+
|
|
678
|
+
### Viewing the Wiki
|
|
679
|
+
|
|
680
|
+
```bash
|
|
681
|
+
# Install Zread CLI
|
|
682
|
+
npm install -g zread_cli
|
|
683
|
+
|
|
684
|
+
# Browse the wiki in your browser
|
|
685
|
+
zread browse
|
|
686
|
+
|
|
687
|
+
# Regenerate after code changes
|
|
688
|
+
zread generate
|
|
689
|
+
```
|
|
690
|
+
|
|
691
|
+
The wiki is versioned alongside the code. Contributors should prune old version snapshots before committing so the repo only contains the latest.
|
|
692
|
+
|
|
693
|
+
### Contributing to the Wiki
|
|
694
|
+
|
|
695
|
+
After making significant code changes:
|
|
696
|
+
|
|
697
|
+
1. Run `zread generate` to create an updated wiki
|
|
698
|
+
2. Delete old dated folders under `.zread/wiki/versions/`, keeping only the latest
|
|
699
|
+
3. Commit the updated `current` pointer and the new version folder
|
|
700
|
+
|
|
701
|
+
## Requirements
|
|
702
|
+
|
|
703
|
+
- Node.js >= 18.0.0
|
|
704
|
+
- Claude Code installed (for Claude Code support)
|
|
705
|
+
- OpenCode installed (for OpenCode helper commands)
|
|
706
|
+
- Alibaba API Key (for Alibaba Coding Plan)
|
|
707
|
+
- `coding-helper` package (for GLM/Z.AI support)
|
|
708
|
+
- [LiteLLM](https://github.com/BerriAI/litellm) (for Ollama and Gemini support)
|
|
709
|
+
- [Ollama](https://ollama.com) (for Ollama local models)
|
|
710
|
+
- Google API Key (for Gemini)
|
|
711
|
+
|
|
712
|
+
## LiteLLM Setup
|
|
713
|
+
|
|
714
|
+
Ollama and Gemini require [LiteLLM](https://github.com/BerriAI/litellm) to translate between Claude Code's Anthropic API format and the OpenAI-compatible format used by these providers.
|
|
715
|
+
|
|
716
|
+
```bash
|
|
717
|
+
# Install LiteLLM with proxy support
|
|
718
|
+
pip install 'litellm[proxy]'
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
The tool automatically starts the proxy when you switch to Ollama (port 4000) or Gemini (port 4001). No manual proxy management is needed.
|
|
722
|
+
|
|
723
|
+
## Getting API Keys
|
|
724
|
+
|
|
725
|
+
### Alibaba Coding Plan
|
|
726
|
+
|
|
727
|
+
1. Visit [Alibaba Cloud Model Studio](https://modelstudio.console.alibabacloud.com/)
|
|
728
|
+
2. Navigate to API Key management
|
|
729
|
+
3. Create a new API key
|
|
730
|
+
4. Run `claude-switch setup` or `claude-switch key alibaba <key>`
|
|
731
|
+
|
|
732
|
+
### GLM/Z.AI
|
|
733
|
+
|
|
734
|
+
1. Install coding-helper: `npm install -g @z_ai/coding-helper`
|
|
735
|
+
2. Run: `coding-helper auth`
|
|
736
|
+
3. Follow the interactive setup
|
|
737
|
+
|
|
738
|
+
### OpenRouter
|
|
739
|
+
|
|
740
|
+
1. Visit [OpenRouter Keys](https://openrouter.ai/settings/keys)
|
|
741
|
+
2. Create a new API key
|
|
742
|
+
3. Run `claude-switch setup` or `claude-switch key openrouter <key>`
|
|
743
|
+
|
|
744
|
+
### Gemini (Google)
|
|
745
|
+
|
|
746
|
+
1. Visit [Google AI Studio](https://aistudio.google.com/apikey)
|
|
747
|
+
2. Create a new API key
|
|
748
|
+
3. Run `claude-switch setup` or `claude-switch key gemini <key>`
|
|
749
|
+
4. Ensure LiteLLM is installed: `pip install 'litellm[proxy]'`
|
|
750
|
+
|
|
751
|
+
### Ollama (Local)
|
|
752
|
+
|
|
753
|
+
1. Install [Ollama](https://ollama.com)
|
|
754
|
+
2. Start Ollama: `ollama serve`
|
|
755
|
+
3. Pull a model: `ollama pull deepseek-r1`
|
|
756
|
+
4. Ensure LiteLLM is installed: `pip install 'litellm[proxy]'`
|
|
757
|
+
5. No API key needed — everything runs locally
|
|
758
|
+
|
|
759
|
+
## Safety Features
|
|
760
|
+
|
|
761
|
+
- Checks if config files exist before creating
|
|
762
|
+
- Backs up existing settings before modification
|
|
763
|
+
- Never overwrites without confirmation
|
|
764
|
+
- Auto-sets `hasCompletedOnboarding: true` in `~/.claude.json`
|
|
765
|
+
- Local-only storage (no cloud sync)
|
|
766
|
+
- Clears model alias env vars when switching between providers
|
|
767
|
+
- Preserves other OpenCode providers when adding/removing bailian-coding-plan
|
|
768
|
+
|
|
769
|
+
## Troubleshooting
|
|
770
|
+
|
|
771
|
+
### "coding-helper not found"
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
npm install -g @z_ai/coding-helper
|
|
775
|
+
```
|
|
776
|
+
|
|
777
|
+
### "LiteLLM is required for Ollama/Gemini support"
|
|
778
|
+
|
|
779
|
+
```bash
|
|
780
|
+
pip install 'litellm[proxy]'
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
### "Ollama is not installed"
|
|
784
|
+
|
|
785
|
+
Download and install from [ollama.com](https://ollama.com), then start it:
|
|
786
|
+
|
|
787
|
+
```bash
|
|
788
|
+
ollama serve
|
|
789
|
+
```
|
|
790
|
+
|
|
791
|
+
### "Ollama is not running"
|
|
792
|
+
|
|
793
|
+
```bash
|
|
794
|
+
ollama serve
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
### "Failed to start LiteLLM proxy"
|
|
798
|
+
|
|
799
|
+
The proxy may take a moment to start. Check that port 4000 (Ollama) or 4001 (Gemini) is not already in use:
|
|
800
|
+
|
|
801
|
+
```bash
|
|
802
|
+
# Check what's using the port
|
|
803
|
+
lsof -i :4000 # macOS/Linux
|
|
804
|
+
netstat -ano | findstr :4000 # Windows
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
### "API Key not found"
|
|
808
|
+
|
|
809
|
+
```bash
|
|
810
|
+
claude-switch setup
|
|
811
|
+
# or
|
|
812
|
+
claude-switch key alibaba <your-api-key>
|
|
813
|
+
claude-switch key gemini <your-api-key>
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
### "Unable to connect to Anthropic services"
|
|
817
|
+
|
|
818
|
+
The tool automatically sets `hasCompletedOnboarding: true` in `~/.claude.json`. Run any switch command to trigger this:
|
|
819
|
+
|
|
820
|
+
```bash
|
|
821
|
+
claude-switch anthropic
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
### Check current configuration
|
|
825
|
+
|
|
826
|
+
```bash
|
|
827
|
+
claude-switch status # Shows config + verifies API keys
|
|
828
|
+
claude-switch current # Shows config only
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
## License
|
|
832
|
+
|
|
833
|
+
MIT
|