mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
docs: 更新Droid 使用教程
This commit is contained in:
59
README.md
59
README.md
@@ -389,11 +389,20 @@ docker-compose.yml 已包含:
|
||||
|
||||
**Claude Code 设置环境变量:**
|
||||
|
||||
默认使用标准 Claude 账号池:
|
||||
|
||||
```bash
|
||||
export ANTHROPIC_BASE_URL="http://127.0.0.1:3000/api/" # 根据实际填写你服务器的ip地址或者域名
|
||||
export ANTHROPIC_AUTH_TOKEN="后台创建的API密钥"
|
||||
```
|
||||
|
||||
如果后台添加了 Droid 类型账号池,请将基础地址改为:
|
||||
|
||||
```bash
|
||||
export ANTHROPIC_BASE_URL="http://127.0.0.1:3000/droid/claude" # 根据实际情况替换域名/IP
|
||||
export ANTHROPIC_AUTH_TOKEN="后台创建的API密钥"
|
||||
```
|
||||
|
||||
**VSCode Claude 插件配置:**
|
||||
|
||||
如果使用 VSCode 的 Claude 插件,需要在 `~/.claude/config.json` 文件中配置:
|
||||
@@ -445,6 +454,8 @@ requires_openai_auth = true
|
||||
env_key = "CRS_OAI_KEY"
|
||||
```
|
||||
|
||||
如需通过 Droid 类型账号池访问 Codex CLI,只需将 `base_url` 改为 `http://127.0.0.1:3000/droid/openai`(其余配置保持不变)。
|
||||
|
||||
在 `~/.codex/auth.json` 文件中配置API密钥为 null:
|
||||
|
||||
```json
|
||||
@@ -461,6 +472,35 @@ export CRS_OAI_KEY="后台创建的API密钥"
|
||||
|
||||
> ⚠️ 在通过 Nginx 反向代理 CRS 服务并使用 Codex CLI 时,需要在 http 块中添加 underscores_in_headers on;。因为 Nginx 默认会移除带下划线的请求头(如 session_id),一旦该头被丢弃,多账号环境下的粘性会话功能将失效。
|
||||
|
||||
**Droid CLI 配置:**
|
||||
|
||||
Droid CLI 读取 `~/.factory/config.json`。可以在该文件中添加自定义模型以指向本服务的新端点:
|
||||
|
||||
```json
|
||||
{
|
||||
"custom_models": [
|
||||
{
|
||||
"model_display_name": "Sonnet 4.5 [Custom]",
|
||||
"model": "claude-sonnet-4-5-20250929",
|
||||
"base_url": "http://127.0.0.1:3000/droid/claude",
|
||||
"api_key": "后台创建的API密钥",
|
||||
"provider": "anthropic",
|
||||
"max_tokens": 8192
|
||||
},
|
||||
{
|
||||
"model_display_name": "GPT5-Codex [Custom]",
|
||||
"model": "gpt-5-codex",
|
||||
"base_url": "http://127.0.0.1:3000/droid/openai",
|
||||
"api_key": "后台创建的API密钥",
|
||||
"provider": "openai",
|
||||
"max_tokens": 16384
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
> 💡 将示例中的 `http://127.0.0.1:3000` 替换为你的服务域名或公网地址,并写入后台生成的 API 密钥(cr_ 开头)。
|
||||
|
||||
### 5. 第三方工具API接入
|
||||
|
||||
本服务支持多种API端点格式,方便接入不同的第三方工具(如Cherry Studio等)。
|
||||
@@ -515,6 +555,23 @@ gpt-5 # Codex使用固定模型ID
|
||||
- API地址填入:`http://你的服务器:3000/openai`
|
||||
- API Key填入:后台创建的API密钥(cr_开头)
|
||||
- **重要**:Codex只支持Openai-Response标准
|
||||
- 💡 如果希望在 Cherry Studio 中使用 Droid 类型账号,请改填 `http://你的服务器:3000/droid/openai`,并保持其他设置不变。
|
||||
|
||||
**4. Droid账号接入:**
|
||||
|
||||
```
|
||||
# Claude Code / Droid CLI 使用的 API 地址
|
||||
http://你的服务器:3000/droid/claude
|
||||
|
||||
# Codex CLI 使用的 API 地址
|
||||
http://你的服务器:3000/droid/openai
|
||||
```
|
||||
|
||||
配置步骤:
|
||||
- 供应商类型选择"Anthropic"或"Openai-Response"(根据模型类型)
|
||||
- API地址填入:`http://你的服务器:3000/droid/claude` 或 `http://你的服务器:3000/droid/openai`
|
||||
- API Key填入:后台创建的API密钥(cr_开头)
|
||||
- 建议自定义模型名称以区分 Droid 账号池
|
||||
|
||||
**Cherry Studio 地址格式重要说明:**
|
||||
|
||||
@@ -530,8 +587,10 @@ gpt-5 # Codex使用固定模型ID
|
||||
- 所有账号类型都使用相同的API密钥(在后台统一创建)
|
||||
- 根据不同的路由前缀自动识别账号类型
|
||||
- `/claude/` - 使用Claude账号池
|
||||
- `/droid/claude/` - 使用Droid类型Claude账号池(服务于 Claude Code / Droid CLI)
|
||||
- `/gemini/` - 使用Gemini账号池
|
||||
- `/openai/` - 使用Codex账号(只支持Openai-Response格式)
|
||||
- `/droid/openai/` - 使用Droid类型OpenAI兼容账号池(服务于 Codex CLI)
|
||||
- 支持所有标准API端点(messages、models等)
|
||||
|
||||
**重要说明:**
|
||||
|
||||
@@ -296,6 +296,15 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-purple-700 dark:text-purple-300 sm:text-sm">
|
||||
🚀 如果你在后台添加了 <strong>Droid</strong> 类型账号,请将上述命令中的
|
||||
<code class="rounded bg-purple-100 px-1 dark:bg-purple-900">{{ currentBaseUrl }}</code>
|
||||
替换为
|
||||
<code class="rounded bg-purple-100 px-1 dark:bg-purple-900">{{
|
||||
droidClaudeBaseUrl
|
||||
}}</code
|
||||
>,其余配置保持不变。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- VSCode 插件配置 -->
|
||||
@@ -505,6 +514,17 @@
|
||||
{{ line }}
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-xs text-yellow-700 dark:text-yellow-300 sm:text-sm">
|
||||
🚀 如果你要使用 <strong>Droid</strong> 类型账号池,请把配置中的
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900">{{
|
||||
openaiBaseUrl
|
||||
}}</code>
|
||||
替换为
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900">{{
|
||||
droidOpenaiBaseUrl
|
||||
}}</code
|
||||
>。
|
||||
</p>
|
||||
<p class="mt-3 text-sm text-yellow-700 dark:text-yellow-300">
|
||||
在
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900"
|
||||
@@ -573,6 +593,132 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Droid CLI 配置 -->
|
||||
<div class="mt-8">
|
||||
<h5
|
||||
class="mb-2 flex items-center text-base font-semibold text-gray-800 dark:text-gray-200 sm:mb-3 sm:text-lg"
|
||||
>
|
||||
<i class="fas fa-terminal mr-2 text-blue-600" />
|
||||
配置 Droid CLI
|
||||
</h5>
|
||||
<p class="mb-3 text-sm text-gray-700 dark:text-gray-300 sm:mb-4 sm:text-base">
|
||||
Droid CLI 使用
|
||||
<code class="rounded bg-gray-100 px-1 dark:bg-gray-800">~/.factory/config.json</code>
|
||||
保存自定义模型(Windows 路径为
|
||||
<code class="rounded bg-gray-100 px-1 dark:bg-gray-800"
|
||||
>C:\Users\你的用户名\.factory\config.json</code
|
||||
>)。
|
||||
</p>
|
||||
<div
|
||||
class="rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-500/40 dark:bg-blue-950/30 sm:p-4"
|
||||
>
|
||||
<h6 class="mb-2 text-sm font-medium text-blue-800 dark:text-blue-200 sm:text-base">
|
||||
配置文件示例
|
||||
</h6>
|
||||
<p class="mb-3 text-sm text-blue-700 dark:text-blue-200">
|
||||
将以下内容追加到配置文件中,并替换示例中的域名和 API 密钥:
|
||||
</p>
|
||||
<div
|
||||
class="overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"
|
||||
>
|
||||
<div
|
||||
v-for="(line, index) in droidCliConfigLines"
|
||||
:key="line + index"
|
||||
class="whitespace-nowrap text-gray-300"
|
||||
>
|
||||
{{ line }}
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-blue-700 dark:text-blue-200 sm:text-sm">
|
||||
💡 在 Droid CLI 中选择自定义模型即可使用新的 Droid 账号池;确保服务地址可被本地访问。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Droid CLI 配置 -->
|
||||
<div class="mt-8">
|
||||
<h5
|
||||
class="mb-2 flex items-center text-base font-semibold text-gray-800 dark:text-gray-200 sm:mb-3 sm:text-lg"
|
||||
>
|
||||
<i class="fas fa-terminal mr-2 text-blue-600" />
|
||||
配置 Droid CLI
|
||||
</h5>
|
||||
<p class="mb-3 text-sm text-gray-700 dark:text-gray-300 sm:mb-4 sm:text-base">
|
||||
Droid CLI 使用
|
||||
<code class="rounded bg-gray-100 px-1 dark:bg-gray-800">~/.factory/config.json</code>
|
||||
保存自定义模型(Windows 路径为
|
||||
<code class="rounded bg-gray-100 px-1 dark:bg-gray-800"
|
||||
>C:\Users\你的用户名\.factory\config.json</code
|
||||
>)。
|
||||
</p>
|
||||
<div
|
||||
class="rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-500/40 dark:bg-blue-950/30 sm:p-4"
|
||||
>
|
||||
<h6 class="mb-2 text-sm font-medium text-blue-800 dark:text-blue-200 sm:text-base">
|
||||
配置文件示例
|
||||
</h6>
|
||||
<p class="mb-3 text-sm text-blue-700 dark:text-blue-200">
|
||||
将以下内容追加到配置文件中,并替换示例中的域名和 API 密钥:
|
||||
</p>
|
||||
<div
|
||||
class="overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"
|
||||
>
|
||||
<div
|
||||
v-for="(line, index) in droidCliConfigLines"
|
||||
:key="line + index"
|
||||
class="whitespace-nowrap text-gray-300"
|
||||
>
|
||||
{{ line }}
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-blue-700 dark:text-blue-200 sm:text-sm">
|
||||
💡 在 Droid CLI 中选择自定义模型即可使用新的 Droid 账号池;确保服务地址可被本地访问。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Droid CLI 配置 -->
|
||||
<div class="mt-8">
|
||||
<h5
|
||||
class="mb-2 flex items-center text-base font-semibold text-gray-800 dark:text-gray-200 sm:mb-3 sm:text-lg"
|
||||
>
|
||||
<i class="fas fa-terminal mr-2 text-blue-600" />
|
||||
配置 Droid CLI
|
||||
</h5>
|
||||
<p class="mb-3 text-sm text-gray-700 dark:text-gray-300 sm:mb-4 sm:text-base">
|
||||
Droid CLI 使用
|
||||
<code class="rounded bg-gray-100 px-1 dark:bg-gray-800">~/.factory/config.json</code>
|
||||
保存自定义模型(Windows 路径为
|
||||
<code class="rounded bg-gray-100 px-1 dark:bg-gray-800"
|
||||
>C:\Users\你的用户名\.factory\config.json</code
|
||||
>)。
|
||||
</p>
|
||||
<div
|
||||
class="rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-500/40 dark:bg-blue-950/30 sm:p-4"
|
||||
>
|
||||
<h6 class="mb-2 text-sm font-medium text-blue-800 dark:text-blue-200 sm:text-base">
|
||||
配置文件示例
|
||||
</h6>
|
||||
<p class="mb-3 text-sm text-blue-700 dark:text-blue-200">
|
||||
将以下内容追加到配置文件中,并替换示例中的域名和 API 密钥:
|
||||
</p>
|
||||
<div
|
||||
class="overflow-x-auto rounded bg-gray-900 p-2 font-mono text-xs text-green-400 sm:p-3 sm:text-sm"
|
||||
>
|
||||
<div
|
||||
v-for="(line, index) in droidCliConfigLines"
|
||||
:key="line + index"
|
||||
class="whitespace-nowrap text-gray-300"
|
||||
>
|
||||
{{ line }}
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-blue-700 dark:text-blue-200 sm:text-sm">
|
||||
💡 在 Droid CLI 中选择自定义模型即可使用新的 Droid 账号池;确保服务地址可被本地访问。
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第四步:开始使用 -->
|
||||
<div class="mb-6 sm:mb-8">
|
||||
<h4
|
||||
@@ -948,6 +1094,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-orange-700 dark:text-orange-300 sm:text-sm">
|
||||
🚀 如果你创建了 <strong>Droid</strong> 类型账号,请把上述命令中的
|
||||
<code class="rounded bg-orange-100 px-1 dark:bg-orange-900">{{ currentBaseUrl }}</code>
|
||||
替换为
|
||||
<code class="rounded bg-orange-100 px-1 dark:bg-orange-900">{{
|
||||
droidClaudeBaseUrl
|
||||
}}</code
|
||||
>,其余配置保持不变。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- VSCode 插件配置 (macOS) -->
|
||||
@@ -1115,6 +1270,17 @@
|
||||
{{ line }}
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-xs text-yellow-700 dark:text-yellow-300 sm:text-sm">
|
||||
🚀 如果你要使用 <strong>Droid</strong> 类型账号池,请把配置中的
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900">{{
|
||||
openaiBaseUrl
|
||||
}}</code>
|
||||
替换为
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900">{{
|
||||
droidOpenaiBaseUrl
|
||||
}}</code
|
||||
>。
|
||||
</p>
|
||||
<p class="mt-3 text-sm text-yellow-700 dark:text-yellow-300">
|
||||
在
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900"
|
||||
@@ -1550,6 +1716,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-3 text-xs text-orange-700 dark:text-orange-300 sm:text-sm">
|
||||
🚀 如果你创建了 <strong>Droid</strong> 类型账号,请把上述命令中的
|
||||
<code class="rounded bg-orange-100 px-1 dark:bg-orange-900">{{ currentBaseUrl }}</code>
|
||||
替换为
|
||||
<code class="rounded bg-orange-100 px-1 dark:bg-orange-900">{{
|
||||
droidClaudeBaseUrl
|
||||
}}</code
|
||||
>,其余配置保持不变。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Gemini CLI 环境变量设置 -->
|
||||
@@ -1685,6 +1860,17 @@
|
||||
{{ line }}
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 text-xs text-yellow-700 dark:text-yellow-300 sm:text-sm">
|
||||
🚀 如果你要使用 <strong>Droid</strong> 类型账号池,请把配置中的
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900">{{
|
||||
openaiBaseUrl
|
||||
}}</code>
|
||||
替换为
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900">{{
|
||||
droidOpenaiBaseUrl
|
||||
}}</code
|
||||
>。
|
||||
</p>
|
||||
<p class="mt-3 text-sm text-yellow-700 dark:text-yellow-300">
|
||||
在
|
||||
<code class="rounded bg-yellow-100 px-1 dark:bg-yellow-900"
|
||||
@@ -2017,6 +2203,15 @@ const openaiBaseUrl = computed(() => {
|
||||
return getBaseUrlPrefix() + '/openai'
|
||||
})
|
||||
|
||||
// Droid 类型账号基础URL
|
||||
const droidClaudeBaseUrl = computed(() => {
|
||||
return getBaseUrlPrefix() + '/droid/claude'
|
||||
})
|
||||
|
||||
const droidOpenaiBaseUrl = computed(() => {
|
||||
return getBaseUrlPrefix() + '/droid/openai'
|
||||
})
|
||||
|
||||
// Codex 配置内容
|
||||
const codexConfigContent = computed(() => {
|
||||
// 根据当前激活的教程系统获取对应的环境变量设置说明
|
||||
@@ -2094,6 +2289,8 @@ const codexConfigContent = computed(() => {
|
||||
'[model_providers.crs]',
|
||||
'name = "crs"',
|
||||
`base_url = "${openaiBaseUrl.value}"`,
|
||||
'# 若使用 Droid 类型账号,请改为以下地址',
|
||||
`# base_url = "${droidOpenaiBaseUrl.value}"`,
|
||||
'wire_api = "responses"',
|
||||
'requires_openai_auth = true',
|
||||
'env_key = "CRS_OAI_KEY"'
|
||||
@@ -2102,6 +2299,30 @@ const codexConfigContent = computed(() => {
|
||||
authInstructions: getCurrentPlatformAuthInstructions()
|
||||
}
|
||||
})
|
||||
|
||||
// Droid CLI 配置示例
|
||||
const droidCliConfigLines = computed(() => [
|
||||
'{',
|
||||
' "custom_models": [',
|
||||
' {',
|
||||
' "model_display_name": "Sonnet 4.5 [Custom]",',
|
||||
' "model": "claude-sonnet-4-5-20250929",',
|
||||
` "base_url": "${droidClaudeBaseUrl.value}",`,
|
||||
' "api_key": "你的API密钥",',
|
||||
' "provider": "anthropic",',
|
||||
' "max_tokens": 8192',
|
||||
' },',
|
||||
' {',
|
||||
' "model_display_name": "GPT5-Codex [Custom]",',
|
||||
' "model": "gpt-5-codex",',
|
||||
` "base_url": "${droidOpenaiBaseUrl.value}",`,
|
||||
' "api_key": "你的API密钥",',
|
||||
' "provider": "openai",',
|
||||
' "max_tokens": 16384',
|
||||
' }',
|
||||
' ]',
|
||||
'}'
|
||||
])
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user