在 Cursor 中使用 oairoute
- Cursor 支持覆盖 OpenAI 端点
- 配置后可用 OAIRoute 的模型做代码补全与对话
- 同一个 Key 同时供 Cursor 与其他工具使用
第一步:获取 API Key
在 OAIRoute 控制台 创建。
Create one in the OAIRoute console.
第二步:开启自定义 API
打开 Cursor,进入 设置 → Models,找到 OpenAI API Key 一栏。
点开 Override OpenAI Base URL,填入:
https://api.oairoute.com/v1
你的 OAIRoute Key。填在同一个页面的 API Key 输入框里。
填完后点 Verify,成功会显示一个小勾。
Open Cursor, go to Settings → Models, and find the OpenAI API Key section.
Expand Override OpenAI Base URL and enter:
https://api.oairoute.com/v1
Your OAIRoute key. Enter it in the API Key field on the same page.
Click Verify when done; success shows a small checkmark.
第三步:添加模型
在 Models 页面点 Add model,手动输入模型 ID。Cursor 不会自动从 OAIRoute 拉取列表,必须手填。
常用组合:
| 用途 | 推荐模型 |
|---|---|
| 快速补全 | gpt-4o-mini |
| 复杂重构 | claude-sonnet-5-5 |
| 长文件理解 | gemini-2.5-pro |
Cursor 的功能分两类:补全(Tab 提示)与对话(Chat、Composer)。两者走不同的模型配置,需要分别在 Models 页面指定,否则可能只有一项生效。
On the Models page click Add model and type the model ID manually. Cursor doesn't pull the list from OAIRoute automatically, so it must be entered by hand.
Common combinations:
| Use | Recommended model |
|---|---|
| Fast completion | gpt-4o-mini |
| Complex refactoring | claude-sonnet-5-5 |
| Understanding long files | gemini-2.5-pro |
Cursor's features fall into two categories: completion (Tab hints) and chat (Chat, Composer). They use different model settings, so specify both on the Models page; otherwise only one may work.
第四步:验证
打开一个代码文件,按 Cmd/Ctrl + K,输入「把这段函数改成 async」,看是否返回结果。
Open a code file, press Cmd/Ctrl + K, and type "turn this function into async" to see whether it returns a result.
常见问题
Verify 失败
Base URL 少了 /v1。Cursor 用的是完整端点风格,要带。
能对话但补全不工作
补全走的是另一套配置。到 Models 页面确认补全所用的模型也已设置,并且不是灰色禁用状态。
返回内容被截断
Cursor 会给请求加 max_tokens 上限。长文件场景换用上下文更长的模型。
提示 rate limited
团队共用同一个 Key 时容易触发。建议每人单独建 Key,额度独立,也便于排查。
Verify fails
Base URL is missing /v1. Cursor uses the full-endpoint style, so include it.
Chat works but completion doesn't
Completion uses a separate configuration. On the Models page, confirm the model used for completion is also set and isn't greyed out as disabled.
Output gets truncated
Cursor adds a max_tokens cap to requests. For long files, switch to a model with a longer context.
Rate limited
Common when a whole team shares one key. Create a separate key per person — limits are then independent and problems are easier to trace.