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
- continue
|
| 10 |
+
- copilot
|
| 11 |
+
- ai-coding
|
| 12 |
+
- vscode
|
| 13 |
+
- llm
|
| 14 |
+
language:
|
| 15 |
+
- en
|
| 16 |
+
- zh
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# 💻 Crazyrouter AI 编程工具配置指南
|
| 20 |
+
|
| 21 |
+
> 在 Cursor、Windsurf、Cline、Continue 等 AI 编程工具中使用 624+ 模型
|
| 22 |
+
|
| 23 |
+
[Crazyrouter](https://crazyrouter.com) 兼容 OpenAI API,可以作为所有主流 AI 编程工具的后端。一个 Key 搞定所有编程助手。
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
|
| 27 |
+
## Cursor
|
| 28 |
+
|
| 29 |
+
[Cursor](https://cursor.sh/) 是目前最热门的 AI 代码编辑器。
|
| 30 |
+
|
| 31 |
+
### 配置步骤
|
| 32 |
+
|
| 33 |
+
1. 打开 Cursor → Settings → Models
|
| 34 |
+
2. 找到 **OpenAI API Key** 配置
|
| 35 |
+
3. 填写:
|
| 36 |
+
- **API Key**: `sk-your-crazyrouter-key`
|
| 37 |
+
- **Override OpenAI Base URL**: `https://crazyrouter.com/v1`
|
| 38 |
+
4. 在模型列表中添加需要的模型名称
|
| 39 |
+
5. 保存
|
| 40 |
+
|
| 41 |
+
### 推荐模型
|
| 42 |
+
|
| 43 |
+
- **Tab 补全**: `gpt-4o-mini`(快速、便宜)
|
| 44 |
+
- **Chat**: `claude-sonnet-4-20250514`(代码理解最强)
|
| 45 |
+
- **Composer**: `gpt-4o` 或 `deepseek-chat`
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Windsurf (Codeium)
|
| 50 |
+
|
| 51 |
+
[Windsurf](https://codeium.com/windsurf) 是 Codeium 推出的 AI IDE。
|
| 52 |
+
|
| 53 |
+
### 配置步骤
|
| 54 |
+
|
| 55 |
+
1. 打开 Windsurf → Settings
|
| 56 |
+
2. 搜索 `openai`
|
| 57 |
+
3. 配置自定义 API:
|
| 58 |
+
- **Base URL**: `https://crazyrouter.com/v1`
|
| 59 |
+
- **API Key**: `sk-your-crazyrouter-key`
|
| 60 |
+
4. 选择模型
|
| 61 |
+
|
| 62 |
+
---
|
| 63 |
+
|
| 64 |
+
## Cline (VS Code 插件)
|
| 65 |
+
|
| 66 |
+
[Cline](https://github.com/cline/cline) 是 VS Code 上最强的 AI 编程助手插件。
|
| 67 |
+
|
| 68 |
+
### 配置步骤
|
| 69 |
+
|
| 70 |
+
1. 安装 Cline 插件(VS Code 扩展商店搜索 "Cline")
|
| 71 |
+
2. 打开 Cline 侧边栏 → 点击设置图标
|
| 72 |
+
3. 选择 **API Provider** → **OpenAI Compatible**
|
| 73 |
+
4. 填写:
|
| 74 |
+
- **Base URL**: `https://crazyrouter.com/v1`
|
| 75 |
+
- **API Key**: `sk-your-crazyrouter-key`
|
| 76 |
+
- **Model ID**: `claude-sonnet-4-20250514`(推荐)
|
| 77 |
+
5. 保存
|
| 78 |
+
|
| 79 |
+
### 推荐配置
|
| 80 |
+
|
| 81 |
+
```json
|
| 82 |
+
{
|
| 83 |
+
"cline.apiProvider": "openai-compatible",
|
| 84 |
+
"cline.openaiBaseUrl": "https://crazyrouter.com/v1",
|
| 85 |
+
"cline.openaiApiKey": "sk-your-crazyrouter-key",
|
| 86 |
+
"cline.openaiModelId": "claude-sonnet-4-20250514"
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### 模型选择建议
|
| 91 |
+
|
| 92 |
+
| 任务 | 模型 | 原因 |
|
| 93 |
+
|------|------|------|
|
| 94 |
+
| 复杂重构 | `claude-sonnet-4-20250514` | 最强代码理解 |
|
| 95 |
+
| 快速修改 | `gpt-4o-mini` | 速度快、成本低 |
|
| 96 |
+
| 算法题 | `deepseek-reasoner` | 链式推理 |
|
| 97 |
+
| 日常编码 | `deepseek-chat` | 性价比最高 |
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## Continue (VS Code / JetBrains 插件)
|
| 102 |
+
|
| 103 |
+
[Continue](https://continue.dev/) 是开源的 AI 编程助手,支持 VS Code 和 JetBrains。
|
| 104 |
+
|
| 105 |
+
### 配置步骤
|
| 106 |
+
|
| 107 |
+
编辑 `~/.continue/config.json`:
|
| 108 |
+
|
| 109 |
+
```json
|
| 110 |
+
{
|
| 111 |
+
"models": [
|
| 112 |
+
{
|
| 113 |
+
"title": "GPT-4o (Crazyrouter)",
|
| 114 |
+
"provider": "openai",
|
| 115 |
+
"model": "gpt-4o",
|
| 116 |
+
"apiBase": "https://crazyrouter.com/v1",
|
| 117 |
+
"apiKey": "sk-your-crazyrouter-key"
|
| 118 |
+
},
|
| 119 |
+
{
|
| 120 |
+
"title": "Claude Sonnet (Crazyrouter)",
|
| 121 |
+
"provider": "openai",
|
| 122 |
+
"model": "claude-sonnet-4-20250514",
|
| 123 |
+
"apiBase": "https://crazyrouter.com/v1",
|
| 124 |
+
"apiKey": "sk-your-crazyrouter-key"
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"title": "DeepSeek (Crazyrouter)",
|
| 128 |
+
"provider": "openai",
|
| 129 |
+
"model": "deepseek-chat",
|
| 130 |
+
"apiBase": "https://crazyrouter.com/v1",
|
| 131 |
+
"apiKey": "sk-your-crazyrouter-key"
|
| 132 |
+
}
|
| 133 |
+
],
|
| 134 |
+
"tabAutocompleteModel": {
|
| 135 |
+
"title": "Autocomplete",
|
| 136 |
+
"provider": "openai",
|
| 137 |
+
"model": "gpt-4o-mini",
|
| 138 |
+
"apiBase": "https://crazyrouter.com/v1",
|
| 139 |
+
"apiKey": "sk-your-crazyrouter-key"
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
### 多模型切换
|
| 145 |
+
|
| 146 |
+
Continue 支持在对话中随时切换模型,配置多个模型后在侧边栏下拉选择。
|
| 147 |
+
|
| 148 |
+
---
|
| 149 |
+
|
| 150 |
+
## Aider
|
| 151 |
+
|
| 152 |
+
[Aider](https://aider.chat/) 是一款命令行 AI 编程工具,支持 Git 集成。
|
| 153 |
+
|
| 154 |
+
### 配置步骤
|
| 155 |
+
|
| 156 |
+
```bash
|
| 157 |
+
# 安装
|
| 158 |
+
pip install aider-chat
|
| 159 |
+
|
| 160 |
+
# 设置环境变量
|
| 161 |
+
export OPENAI_API_KEY="sk-your-crazyrouter-key"
|
| 162 |
+
export OPENAI_API_BASE="https://crazyrouter.com/v1"
|
| 163 |
+
|
| 164 |
+
# 使用
|
| 165 |
+
aider --model gpt-4o
|
| 166 |
+
aider --model deepseek-chat
|
| 167 |
+
aider --model claude-sonnet-4-20250514
|
| 168 |
+
```
|
| 169 |
+
|
| 170 |
+
### 配置文件
|
| 171 |
+
|
| 172 |
+
创建 `~/.aider.conf.yml`:
|
| 173 |
+
|
| 174 |
+
```yaml
|
| 175 |
+
openai-api-key: sk-your-crazyrouter-key
|
| 176 |
+
openai-api-base: https://crazyrouter.com/v1
|
| 177 |
+
model: claude-sonnet-4-20250514
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
---
|
| 181 |
+
|
| 182 |
+
## Copilot (GitHub Copilot 替代方案)
|
| 183 |
+
|
| 184 |
+
虽然 GitHub Copilot 不支持自定义端点,但你可以用以下替代方案 + Crazyrouter:
|
| 185 |
+
|
| 186 |
+
### Tabby (开源 Copilot)
|
| 187 |
+
|
| 188 |
+
```bash
|
| 189 |
+
# 配置 Tabby 使用 Crazyrouter 作为后端
|
| 190 |
+
# 在 tabby config 中设置
|
| 191 |
+
[model.completion.http]
|
| 192 |
+
kind = "openai/completion"
|
| 193 |
+
api_endpoint = "https://crazyrouter.com/v1"
|
| 194 |
+
api_key = "sk-your-crazyrouter-key"
|
| 195 |
+
model_name = "gpt-4o-mini"
|
| 196 |
+
```
|
| 197 |
+
|
| 198 |
+
### Supermaven
|
| 199 |
+
|
| 200 |
+
Supermaven 支持自定义 API 端点,配置方式类似。
|
| 201 |
+
|
| 202 |
+
---
|
| 203 |
+
|
| 204 |
+
## JetBrains AI Assistant (自定义)
|
| 205 |
+
|
| 206 |
+
JetBrains IDE(IntelliJ、PyCharm、WebStorm 等)可以通过插件使用自定义 API。
|
| 207 |
+
|
| 208 |
+
### 使用 Continue 插件
|
| 209 |
+
|
| 210 |
+
1. 在 JetBrains 插件市场安装 **Continue**
|
| 211 |
+
2. 按上面 Continue 的配置方法设置
|
| 212 |
+
3. 在 IDE 中使用 AI 辅助编程
|
| 213 |
+
|
| 214 |
+
---
|
| 215 |
+
|
| 216 |
+
## Python API 调用示例
|
| 217 |
+
|
| 218 |
+
```python
|
| 219 |
+
from openai import OpenAI
|
| 220 |
+
|
| 221 |
+
client = OpenAI(
|
| 222 |
+
base_url="https://crazyrouter.com/v1",
|
| 223 |
+
api_key="sk-your-crazyrouter-key"
|
| 224 |
+
)
|
| 225 |
+
|
| 226 |
+
# 代码生成
|
| 227 |
+
response = client.chat.completions.create(
|
| 228 |
+
model="deepseek-chat",
|
| 229 |
+
messages=[
|
| 230 |
+
{"role": "system", "content": "You are an expert Python developer."},
|
| 231 |
+
{"role": "user", "content": "Write a FastAPI CRUD app with SQLAlchemy"}
|
| 232 |
+
]
|
| 233 |
+
)
|
| 234 |
+
print(response.choices[0].message.content)
|
| 235 |
+
```
|
| 236 |
+
|
| 237 |
+
## Node.js API 调用示例
|
| 238 |
+
|
| 239 |
+
```javascript
|
| 240 |
+
import OpenAI from "openai";
|
| 241 |
+
|
| 242 |
+
const client = new OpenAI({
|
| 243 |
+
baseURL: "https://crazyrouter.com/v1",
|
| 244 |
+
apiKey: "sk-your-crazyrouter-key",
|
| 245 |
+
});
|
| 246 |
+
|
| 247 |
+
const response = await client.chat.completions.create({
|
| 248 |
+
model: "claude-sonnet-4-20250514",
|
| 249 |
+
messages: [
|
| 250 |
+
{ role: "system", content: "You are an expert TypeScript developer." },
|
| 251 |
+
{ role: "user", content: "Create a Express.js REST API with JWT auth" },
|
| 252 |
+
],
|
| 253 |
+
});
|
| 254 |
+
console.log(response.choices[0].message.content);
|
| 255 |
+
```
|
| 256 |
+
|
| 257 |
+
## PHP API 调用示例
|
| 258 |
+
|
| 259 |
+
```php
|
| 260 |
+
<?php
|
| 261 |
+
$ch = curl_init();
|
| 262 |
+
curl_setopt_array($ch, [
|
| 263 |
+
CURLOPT_URL => 'https://crazyrouter.com/v1/chat/completions',
|
| 264 |
+
CURLOPT_RETURNTRANSFER => true,
|
| 265 |
+
CURLOPT_POST => true,
|
| 266 |
+
CURLOPT_HTTPHEADER => [
|
| 267 |
+
'Content-Type: application/json',
|
| 268 |
+
'Authorization: Bearer sk-your-crazyrouter-key',
|
| 269 |
+
],
|
| 270 |
+
CURLOPT_POSTFIELDS => json_encode([
|
| 271 |
+
'model' => 'gpt-4o-mini',
|
| 272 |
+
'messages' => [
|
| 273 |
+
['role' => 'user', 'content' => 'Write a Laravel migration for a blog'],
|
| 274 |
+
],
|
| 275 |
+
]),
|
| 276 |
+
]);
|
| 277 |
+
$response = curl_exec($ch);
|
| 278 |
+
echo json_decode($response)->choices[0]->message->content;
|
| 279 |
+
```
|
| 280 |
+
|
| 281 |
+
---
|
| 282 |
+
|
| 283 |
+
## 编程模型推荐
|
| 284 |
+
|
| 285 |
+
| 模型 | 价格 (输入/输出 $/1M) | 最适合 |
|
| 286 |
+
|------|----------------------|--------|
|
| 287 |
+
| `claude-sonnet-4-20250514` | $3 / $15 | 复杂重构、代码审查 |
|
| 288 |
+
| `gpt-4o` | $2.5 / $10 | 全能编程、多语言 |
|
| 289 |
+
| `deepseek-chat` | $0.14 / $0.28 | 日常编码、性价比之王 |
|
| 290 |
+
| `gpt-4o-mini` | $0.15 / $0.60 | Tab 补全、简单任务 |
|
| 291 |
+
| `deepseek-reasoner` | $0.55 / $2.19 | 算法、数学推理 |
|
| 292 |
+
| `gemini-2.0-flash` | $0.10 / $0.40 | 大文件分析、速度优先 |
|
| 293 |
+
|
| 294 |
+
---
|
| 295 |
+
|
| 296 |
+
## 链接
|
| 297 |
+
|
| 298 |
+
- 🌐 [Crazyrouter](https://crazyrouter.com) — 获取 API Key
|
| 299 |
+
- 🤖 [在线 Demo](https://huggingface.co/spaces/xujfcn/Crazyrouter-Demo)
|
| 300 |
+
- 📖 [快速入门](https://huggingface.co/xujfcn/Crazyrouter-Getting-Started)
|
| 301 |
+
- 🔗 [LangChain 集成](https://huggingface.co/xujfcn/Crazyrouter-LangChain-Guide)
|
| 302 |
+
- 💬 [Telegram 社区](https://t.me/crazyrouter)
|
| 303 |
+
- 🐦 [Twitter @metaviiii](https://twitter.com/metaviiii)
|