首页 教程 Cursor & VS Code

Cursor & VS Code 配置教程
使用 YourAgent API,AI 编程助手费用省 95%+

⏱️ 预计 5 分钟 🖥️ 全平台通用 📅 更新于 2026-03-05
💡 Cursor + YourAgent = Claude Opus 4.6 低至 $4.5 / $100,无需 Cursor Pro 订阅即可使用顶级模型

📋 支持的工具

工具 API 类型 Base URL
Cursor Anthropic / OpenAI https://your-agent.cc/api
VS Code + Continue OpenAI-compatible https://your-agent.cc/api/v1
VS Code + Cline Anthropic https://your-agent.cc/api
JetBrains AI OpenAI-compatible https://your-agent.cc/api/v1

1选择你的工具

Cursor / VS Code 配置步骤

⚠️ 前提:必须先安装 Claude Code 插件!
在 Cursor / VS Code 中使用 Claude 模型,必须先安装 Claude Code 官方插件。没有插件就无法使用 Claude。

第一步:安装 Claude Code 插件

  1. 打开 Cursor 或 VS Code
  2. Ctrl+Shift+X(Mac: Cmd+Shift+X)打开扩展面板
  3. 搜索 "Claude Code""Anthropic"
  4. 点击 安装

第二步:配置 settings.json

安装后,插件会自动读取 settings.json 中的配置。编辑此文件接入 YourAgent API:

文件位置:

  • macOS / Linux:~/.claude/settings.json
  • Windows:%USERPROFILE%\.claude\settings.json

填入以下内容:

{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "sk-你的密钥",
    "ANTHROPIC_BASE_URL": "https://your-agent.cc/api"
  },
  "includeCoAuthoredBy": false,
  "model": "opus",
  "naturalLang": {
    "command": "coline",
    "type": "command"
  }
}
⚠️ 注意:
  • sk-你的密钥 替换为你从管理员获取的 API Key
  • ANTHROPIC_BASE_URL 填你的 API 路径
  • 完成之后保存,在 Cursor / VS Code 插件里打开 Claude 就可以使用了

第三步(可选):Cursor 自定义 API Key

如果你还想在 Cursor 内置的 AI 功能(非插件)中使用 YourAgent,可以额外配置:

  1. 打开 Cursor → SettingsModelsAPI Configuration
  2. 勾选 "Use custom API key"
  3. 填入:
# Anthropic API (Claude 模型)
API Base URL: https://your-agent.cc/api
API Key: sk-xxx

# OpenAI API (GPT 模型)
API Base URL: https://your-agent.cc/api/v1
API Key: sk-xxx
💡 提示:使用自定义 API Key 后,你不需要 Cursor Pro 订阅也能使用 Claude Opus 4.6 等顶级模型。实际费用仅为按量计费。了解 Cursor Pro 替代方案 →
💡 settings.json 优先级:settings.json 中的 env 配置优先级高于系统环境变量和 Cursor 内置设置。

VS Code + Continue 配置

Continue 是一个开源的 AI 编程插件。

  1. 安装 Continue 插件
  2. 打开 Continue 设置,编辑 config.json
{
  "models": [
    {
      "title": "Claude Opus 4.6 (YourAgent)",
      "provider": "anthropic",
      "model": "claude-sonnet-4-20250514",
      "apiBase": "https://your-agent.cc/api",
      "apiKey": "sk-xxx"
    }
  ]
}

VS Code + Cline 配置

Cline(原 Claude Dev)是另一个流行的 AI 编程助手。

  1. 安装 Cline 插件
  2. 在 Cline 设置中选择 Anthropic 作为 API Provider
  3. 填入:
API Base URL: https://your-agent.cc/api
API Key: sk-xxx

JetBrains AI Assistant 配置

适用于 IntelliJ IDEA、PyCharm、WebStorm 等。

  1. 安装 AI Assistant 插件(JetBrains 自带或第三方)
  2. 进入 Settings → Tools → AI Assistant
  3. 选择 Custom OpenAI-compatible API
  4. 填入:
Base URL: https://your-agent.cc/api/v1
API Key: sk-xxx
Model: claude-sonnet-4-20250514

2验证配置

配置完成后,在编辑器中测试一下 AI 功能:

3查询余额

随时访问 余额查询页面,输入你的 API Key 查看剩余额度和使用情况。

💰 价格对比

使用方式 月费 模型 限制
Cursor Pro 订阅 $20/月 有限次数 500 次快速请求/月
YourAgent + Cursor 按量 $4-14 无限使用 无请求次数限制
💡 划算计算:如果你每月使用量不到 $20 的 API 额度(大约 5000 万+ Tokens),用 YourAgent 按量计费比 Cursor Pro 订阅更省钱!

❓ 常见问题

Q: 需要 Cursor Pro 订阅吗?

不需要!使用自定义 API Key 后,免费版 Cursor 就能使用所有模型。

Q: 哪个 Base URL 用于哪个模型?

Claude 系列模型用 /api(Anthropic 格式),GPT / Codex 系列用 /api/v1(OpenAI 格式)。