---
title: "OpenCode 接入 rawroute：前沿模型 API 省 50%–70%"
canonical: "https://rawroute.dev/zh/integrations/opencode"
lang: "zh-Hans"
last_verified: "2026-11-28"
description: "在 OpenCode 终端代理中配置 rawroute（https://api.rawroute.dev/v1）：以官方 3–5 折私有调用 Claude 5.5、GPT-6.2、Gemini 4 与 Grok 4.7，0% 手续费。"
---

# 在 OpenCode 中接入 rawroute。

免费贡献者端点往往会记录代码用于训练且频繁触发限流。在 opencode.json 中将 rawroute 设为自定义 Provider，即可私有调用原版 Claude、GPT-6.2 与 Gemini 4，享受 3–5 折低价与自动容灾。

## 接入步骤

1. 创建或编辑 ~/.config/opencode/opencode.json（或项目根目录 opencode.json）。
2. 将 rawroute 添加为 OpenAI 兼容 Provider，地址指向 https://api.rawroute.dev/v1 并配置 RAWROUTE_API_KEY。
3. 在 OpenCode 内选择 rawroute/claude-sonnet-5-5 或 rawroute/gpt-6.2-sol 即可开始。

### opencode.json

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "rawroute": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "rawroute",
      "options": {
        "baseURL": "https://api.rawroute.dev/v1",
        "apiKey": "{env:RAWROUTE_API_KEY}"
      },
      "models": {
        "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" },
        "claude-opus-5-5": { "name": "Claude Opus 5.5" },
        "gpt-6.2-sol": { "name": "GPT-6.2 Sol" },
        "gemini-4-argon": { "name": "Gemini 4 Argon" }
      }
    }
  }
}
```

## 何时不适用 rawroute

- 若您更偏好固定月租包月额度而非按量预付费，可继续使用官方订阅计划。
