| | --- |
| | license: mit |
| | tags: |
| | - tutorial |
| | - crazyrouter |
| | - cursor |
| | - windsurf |
| | - cline |
| | - continue |
| | - copilot |
| | - ai-coding |
| | - vscode |
| | - llm |
| | language: |
| | - en |
| | - zh |
| | --- |
| | |
| | # 💻 Crazyrouter AI 编程工具配置指南 |
| |
|
| | > 在 Cursor、Windsurf、Cline、Continue 等 AI 编程工具中使用 624+ 模型 |
| |
|
| | [Crazyrouter](https://crazyrouter.com/?utm_source=huggingface&utm_medium=tutorial&utm_campaign=dev_community) 兼容 OpenAI API,可以作为所有主流 AI 编程工具的后端。一个 Key 搞定所有编程助手。 |
| |
|
| | --- |
| |
|
| | ## Cursor |
| |
|
| | [Cursor](https://cursor.sh/) 是目前最热门的 AI 代码编辑器。 |
| |
|
| | ### 配置步骤 |
| |
|
| | 1. 打开 Cursor → Settings → Models |
| | 2. 找到 **OpenAI API Key** 配置 |
| | 3. 填写: |
| | - **API Key**: `sk-your-crazyrouter-key` |
| | - **Override OpenAI Base URL**: `https://crazyrouter.com/v1` |
| | 4. 在模型列表中添加需要的模型名称 |
| | 5. 保存 |
| |
|
| | ### 推荐模型 |
| |
|
| | - **Tab 补全**: `gpt-4o-mini`(快速、便宜) |
| | - **Chat**: `claude-sonnet-4-20250514`(代码理解最强) |
| | - **Composer**: `gpt-4o` 或 `deepseek-chat` |
| |
|
| | --- |
| |
|
| | ## Windsurf (Codeium) |
| |
|
| | [Windsurf](https://codeium.com/windsurf) 是 Codeium 推出的 AI IDE。 |
| |
|
| | ### 配置步骤 |
| |
|
| | 1. 打开 Windsurf → Settings |
| | 2. 搜索 `openai` |
| | 3. 配置自定义 API: |
| | - **Base URL**: `https://crazyrouter.com/v1` |
| | - **API Key**: `sk-your-crazyrouter-key` |
| | 4. 选择模型 |
| |
|
| | --- |
| |
|
| | ## Cline (VS Code 插件) |
| |
|
| | [Cline](https://github.com/cline/cline) 是 VS Code 上最强的 AI 编程助手插件。 |
| |
|
| | ### 配置步骤 |
| |
|
| | 1. 安装 Cline 插件(VS Code 扩展商店搜索 "Cline") |
| | 2. 打开 Cline 侧边栏 → 点击设置图标 |
| | 3. 选择 **API Provider** → **OpenAI Compatible** |
| | 4. 填写: |
| | - **Base URL**: `https://crazyrouter.com/v1` |
| | - **API Key**: `sk-your-crazyrouter-key` |
| | - **Model ID**: `claude-sonnet-4-20250514`(推荐) |
| | 5. 保存 |
| |
|
| | ### 推荐配置 |
| |
|
| | ```json |
| | { |
| | "cline.apiProvider": "openai-compatible", |
| | "cline.openaiBaseUrl": "https://crazyrouter.com/v1", |
| | "cline.openaiApiKey": "sk-your-crazyrouter-key", |
| | "cline.openaiModelId": "claude-sonnet-4-20250514" |
| | } |
| | ``` |
| |
|
| | ### 模型选择建议 |
| |
|
| | | 任务 | 模型 | 原因 | |
| | |------|------|------| |
| | | 复杂重构 | `claude-sonnet-4-20250514` | 最强代码理解 | |
| | | 快速修改 | `gpt-4o-mini` | 速度快、成本低 | |
| | | 算法题 | `deepseek-reasoner` | 链式推理 | |
| | | 日常编码 | `deepseek-chat` | 性价比最高 | |
| |
|
| | --- |
| |
|
| | ## Continue (VS Code / JetBrains 插件) |
| |
|
| | [Continue](https://continue.dev/) 是开源的 AI 编程助手,支持 VS Code 和 JetBrains。 |
| |
|
| | ### 配置步骤 |
| |
|
| | 编辑 `~/.continue/config.json`: |
| |
|
| | ```json |
| | { |
| | "models": [ |
| | { |
| | "title": "GPT-4o (Crazyrouter)", |
| | "provider": "openai", |
| | "model": "gpt-4o", |
| | "apiBase": "https://crazyrouter.com/v1", |
| | "apiKey": "sk-your-crazyrouter-key" |
| | }, |
| | { |
| | "title": "Claude Sonnet (Crazyrouter)", |
| | "provider": "openai", |
| | "model": "claude-sonnet-4-20250514", |
| | "apiBase": "https://crazyrouter.com/v1", |
| | "apiKey": "sk-your-crazyrouter-key" |
| | }, |
| | { |
| | "title": "DeepSeek (Crazyrouter)", |
| | "provider": "openai", |
| | "model": "deepseek-chat", |
| | "apiBase": "https://crazyrouter.com/v1", |
| | "apiKey": "sk-your-crazyrouter-key" |
| | } |
| | ], |
| | "tabAutocompleteModel": { |
| | "title": "Autocomplete", |
| | "provider": "openai", |
| | "model": "gpt-4o-mini", |
| | "apiBase": "https://crazyrouter.com/v1", |
| | "apiKey": "sk-your-crazyrouter-key" |
| | } |
| | } |
| | ``` |
| |
|
| | ### 多模型切换 |
| |
|
| | Continue 支持在对话中随时切换模型,配置多个模型后在侧边栏下拉选择。 |
| |
|
| | --- |
| |
|
| | ## Aider |
| |
|
| | [Aider](https://aider.chat/) 是一款命令行 AI 编程工具,支持 Git 集成。 |
| |
|
| | ### 配置步骤 |
| |
|
| | ```bash |
| | # 安装 |
| | pip install aider-chat |
| | |
| | # 设置环境变量 |
| | export OPENAI_API_KEY="sk-your-crazyrouter-key" |
| | export OPENAI_API_BASE="https://crazyrouter.com/v1" |
| | |
| | # 使用 |
| | aider --model gpt-4o |
| | aider --model deepseek-chat |
| | aider --model claude-sonnet-4-20250514 |
| | ``` |
| |
|
| | ### 配置文件 |
| |
|
| | 创建 `~/.aider.conf.yml`: |
| |
|
| | ```yaml |
| | openai-api-key: sk-your-crazyrouter-key |
| | openai-api-base: https://crazyrouter.com/v1 |
| | model: claude-sonnet-4-20250514 |
| | ``` |
| |
|
| | --- |
| |
|
| | ## Copilot (GitHub Copilot 替代方案) |
| |
|
| | 虽然 GitHub Copilot 不支持自定义端点,但你可以用以下替代方案 + Crazyrouter: |
| |
|
| | ### Tabby (开源 Copilot) |
| |
|
| | ```bash |
| | # 配置 Tabby 使用 Crazyrouter 作为后端 |
| | # 在 tabby config 中设置 |
| | [model.completion.http] |
| | kind = "openai/completion" |
| | api_endpoint = "https://crazyrouter.com/v1" |
| | api_key = "sk-your-crazyrouter-key" |
| | model_name = "gpt-4o-mini" |
| | ``` |
| |
|
| | ### Supermaven |
| |
|
| | Supermaven 支持自定义 API 端点,配置方式类似。 |
| |
|
| | --- |
| |
|
| | ## JetBrains AI Assistant (自定义) |
| |
|
| | JetBrains IDE(IntelliJ、PyCharm、WebStorm 等)可以通过插件使用自定义 API。 |
| |
|
| | ### 使用 Continue 插件 |
| |
|
| | 1. 在 JetBrains 插件市场安装 **Continue** |
| | 2. 按上面 Continue 的配置方法设置 |
| | 3. 在 IDE 中使用 AI 辅助编程 |
| |
|
| | --- |
| |
|
| | ## Python API 调用示例 |
| |
|
| | ```python |
| | from openai import OpenAI |
| | |
| | client = OpenAI( |
| | base_url="https://crazyrouter.com/v1", |
| | api_key="sk-your-crazyrouter-key" |
| | ) |
| | |
| | # 代码生成 |
| | response = client.chat.completions.create( |
| | model="deepseek-chat", |
| | messages=[ |
| | {"role": "system", "content": "You are an expert Python developer."}, |
| | {"role": "user", "content": "Write a FastAPI CRUD app with SQLAlchemy"} |
| | ] |
| | ) |
| | print(response.choices[0].message.content) |
| | ``` |
| |
|
| | ## Node.js API 调用示例 |
| |
|
| | ```javascript |
| | import OpenAI from "openai"; |
| | |
| | const client = new OpenAI({ |
| | baseURL: "https://crazyrouter.com/v1", |
| | apiKey: "sk-your-crazyrouter-key", |
| | }); |
| | |
| | const response = await client.chat.completions.create({ |
| | model: "claude-sonnet-4-20250514", |
| | messages: [ |
| | { role: "system", content: "You are an expert TypeScript developer." }, |
| | { role: "user", content: "Create a Express.js REST API with JWT auth" }, |
| | ], |
| | }); |
| | console.log(response.choices[0].message.content); |
| | ``` |
| |
|
| | ## PHP API 调用示例 |
| |
|
| | ```php |
| | <?php |
| | $ch = curl_init(); |
| | curl_setopt_array($ch, [ |
| | CURLOPT_URL => 'https://crazyrouter.com/v1/chat/completions', |
| | CURLOPT_RETURNTRANSFER => true, |
| | CURLOPT_POST => true, |
| | CURLOPT_HTTPHEADER => [ |
| | 'Content-Type: application/json', |
| | 'Authorization: Bearer sk-your-crazyrouter-key', |
| | ], |
| | CURLOPT_POSTFIELDS => json_encode([ |
| | 'model' => 'gpt-4o-mini', |
| | 'messages' => [ |
| | ['role' => 'user', 'content' => 'Write a Laravel migration for a blog'], |
| | ], |
| | ]), |
| | ]); |
| | $response = curl_exec($ch); |
| | echo json_decode($response)->choices[0]->message->content; |
| | ``` |
| |
|
| | --- |
| |
|
| | ## 编程模型推荐 |
| |
|
| | | 模型 | 价格 (输入/输出 $/1M) | 最适合 | |
| | |------|----------------------|--------| |
| | | `claude-sonnet-4-20250514` | $3 / $15 | 复杂重构、代码审查 | |
| | | `gpt-4o` | $2.5 / $10 | 全能编程、多语言 | |
| | | `deepseek-chat` | $0.14 / $0.28 | 日常编码、性价比之王 | |
| | | `gpt-4o-mini` | $0.15 / $0.60 | Tab 补全、简单任务 | |
| | | `deepseek-reasoner` | $0.55 / $2.19 | 算法、数学推理 | |
| | | `gemini-2.0-flash` | $0.10 / $0.40 | 大文件分析、速度优先 | |
| |
|
| | --- |
| |
|
| | ## 链接 |
| |
|
| | - 🌐 [Crazyrouter](https://crazyrouter.com/?utm_source=huggingface&utm_medium=tutorial&utm_campaign=dev_community) — 获取 API Key |
| | - 🤖 [在线 Demo](https://huggingface.co/spaces/xujfcn/Crazyrouter-Demo) |
| | - 📖 [快速入门](https://huggingface.co/xujfcn/Crazyrouter-Getting-Started) |
| | - 🔗 [LangChain 集成](https://huggingface.co/xujfcn/Crazyrouter-LangChain-Guide) |
| | - 💬 [Telegram 社区](https://t.me/crazyrouter) |
| | - 🐦 [Twitter @metaviiii](https://twitter.com/metaviiii) |
| |
|