在 Roo Code 中使用 OAIRoute
- 每个模式可以单独指定模型
- 走 OpenAI 兼容端点,不需要插件
- 一条提供方配置覆盖全部模型
第一步:获取 API Key
在 OAIRoute 控制台 创建。
Create one in the OAIRoute console.
第二步:安装并配置
在 VS Code 扩展市场搜索 Roo Code 安装。装好后打开设置,切到 Providers 页签,选 OpenAI Compatible:
填 https://api.oairoute.com/v1
你的 OAIRoute Key。
默认模型,例如 claude-sonnet-5-5。
Search for Roo Code in the VS Code marketplace and install it. Then open settings, switch to the Providers tab and pick OpenAI Compatible:
Enter https://api.oairoute.com/v1
Your OAIRoute key.
The default model, e.g. claude-sonnet-5-5.
第三步:按模式分配模型
Roo Code 的价值在于每个模式可以单独指定模型。提供方只需配一次,然后到各模式设置里填不同模型 ID:
| 模式 | 建议模型 | 理由 |
|---|---|---|
| Code | claude-sonnet-5-5 | 多文件改动最稳 |
| Architect | claude-opus-5-5 | 规划阶段推理更深 |
| Ask | deepseek-v4.1-flash | 问答量大,用便宜的 |
| Debug | gpt-4o-mini | 定位报错不需要顶配 |
所有模式共用同一个 Key 与同一个额度池。想按模式单独看成本,可以给每个模式单独建 Key。
What sets Roo Code apart is per-mode models. Configure the provider once, then give each mode its own model ID:
| Mode | Suggested model | Why |
|---|---|---|
| Code | claude-sonnet-5-5 | Most reliable on multi-file edits |
| Architect | claude-opus-5-5 | Deeper reasoning during planning |
| Ask | deepseek-v4.1-flash | High volume, keep it cheap |
| Debug | gpt-4o-mini | Locating errors does not need a top model |
All modes share one key and one balance pool. Create a separate key per mode if you want per-mode cost visibility.
第四步:验证
在 Roo Code 面板里让它做一件小事,例如「列出当前工作区的目录结构」,确认它既能对话也能调用工具读文件。
Ask Roo Code to do something small, e.g. “list the directory structure of this workspace”, and check that both chat and tool calls work.
上下文与成本
Roo Code 的每条消息都会带上完整上下文,长时间会话的输入 token 会持续增长。控制成本有三个常用手段:
- 按模式分级:Ask 与 Debug 用便宜模型,只有 Code 与 Architect 走贵的。
- 及时清空会话:换任务就新开会话,避免把无关上下文带进下一轮。
- 收紧自动批准:让它少读无关文件,输入 token 自然就下来了。
Every message in Roo Code carries the full context, so input tokens keep growing in a long session. Three practical levers:
- Tier by mode: cheap models for Ask and Debug, expensive ones only for Code and Architect.
- Start fresh per task: new session for a new task, so unrelated context does not carry over.
- Tighten auto-approve: fewer unrelated file reads means fewer input tokens.
常见问题
一直提示模型不支持工具调用
换 claude-sonnet-5-5 或 gpt-4o-mini,这两个的工具调用最稳。
某个模式改了模型不生效
模式设置里的模型会覆盖提供方默认值。确认改的是当前正在用的那个模式。
请求返回 404
多半是 Base URL 少了或多了 /v1。按 https://api.oairoute.com/v1 填。
It keeps saying the model does not support tool calls
Switch to claude-sonnet-5-5 or gpt-4o-mini; both are the most reliable with tools.
A mode ignores the model I set
The per-mode model overrides the provider default. Make sure you edited the mode you are actually using.
Requests return 404
Usually the Base URL has a missing or extra /v1. Use https://api.oairoute.com/v1.