hank9999
commited on
Commit
·
ccd089a
1
Parent(s):
ae610e9
feat: 添加多凭据格式示例及相关文档完善
Browse files- README.md +41 -2
- credentials.example.idc.json +1 -1
- credentials.example.multiple.json +16 -0
README.md
CHANGED
|
@@ -7,6 +7,9 @@
|
|
| 7 |
- **Anthropic API 兼容**: 完整支持 Anthropic Claude API 格式
|
| 8 |
- **流式响应**: 支持 SSE (Server-Sent Events) 流式输出
|
| 9 |
- **Token 自动刷新**: 自动管理和刷新 OAuth Token
|
|
|
|
|
|
|
|
|
|
| 10 |
- **Thinking 模式**: 支持 Claude 的 extended thinking 功能
|
| 11 |
- **工具调用**: 完整支持 function calling / tool use
|
| 12 |
- **多模型支持**: 支持 Sonnet、Opus、Haiku 系列模型
|
|
@@ -60,7 +63,9 @@ cargo build --release
|
|
| 60 |
```
|
| 61 |
### 3. 凭证文件
|
| 62 |
|
| 63 |
-
创建 `credentials.json` 凭证文件(从 Kiro IDE
|
|
|
|
|
|
|
| 64 |
|
| 65 |
```json
|
| 66 |
{
|
|
@@ -73,6 +78,34 @@ cargo build --release
|
|
| 73 |
"clientSecret": "如果你是 IdC 登录 需要配置这个" // 可选, 不需要请删除
|
| 74 |
}
|
| 75 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
最小启动配置(social):
|
| 77 |
```json
|
| 78 |
{
|
|
@@ -81,6 +114,7 @@ cargo build --release
|
|
| 81 |
"authMethod": "social"
|
| 82 |
}
|
| 83 |
```
|
|
|
|
| 84 |
最小启动配置(idc):
|
| 85 |
```json
|
| 86 |
{
|
|
@@ -141,6 +175,8 @@ curl http://127.0.0.1:8990/v1/messages \
|
|
| 141 |
|
| 142 |
### credentials.json
|
| 143 |
|
|
|
|
|
|
|
| 144 |
| 字段 | 类型 | 描述 |
|
| 145 |
|------|------|-------------------------|
|
| 146 |
| `accessToken` | string | OAuth 访问令牌(可选,可自动刷新) |
|
|
@@ -150,6 +186,7 @@ curl http://127.0.0.1:8990/v1/messages \
|
|
| 150 |
| `authMethod` | string | 认证方式(social 或 idc) |
|
| 151 |
| `clientId` | string | IdC 登录的客户端 ID(可选) |
|
| 152 |
| `clientSecret` | string | IdC 登录的客户端密钥(可选) |
|
|
|
|
| 153 |
|
| 154 |
## 模型映射
|
| 155 |
|
|
@@ -192,7 +229,9 @@ kiro-rs/
|
|
| 192 |
│ └── crc.rs # CRC 校验
|
| 193 |
├── Cargo.toml # 项目配置
|
| 194 |
├── config.example.json # 配置示例
|
| 195 |
-
|
|
|
|
|
|
|
| 196 |
```
|
| 197 |
|
| 198 |
## 技术栈
|
|
|
|
| 7 |
- **Anthropic API 兼容**: 完整支持 Anthropic Claude API 格式
|
| 8 |
- **流式响应**: 支持 SSE (Server-Sent Events) 流式输出
|
| 9 |
- **Token 自动刷新**: 自动管理和刷新 OAuth Token
|
| 10 |
+
- **多凭据支持**: 支持配置多个凭据,按优先级自动故障转移
|
| 11 |
+
- **智能重试**: 单凭据最多重试 3 次,单请求最多重试 9 次
|
| 12 |
+
- **凭据回写**: 多凭据格式下自动回写刷新后的 Token
|
| 13 |
- **Thinking 模式**: 支持 Claude 的 extended thinking 功能
|
| 14 |
- **工具调用**: 完整支持 function calling / tool use
|
| 15 |
- **多模型支持**: 支持 Sonnet、Opus、Haiku 系列模型
|
|
|
|
| 63 |
```
|
| 64 |
### 3. 凭证文件
|
| 65 |
|
| 66 |
+
创建 `credentials.json` 凭证文件(从 Kiro IDE 获取)。支持两种格式:
|
| 67 |
+
|
| 68 |
+
#### 单凭据格式(旧格式,向后兼容)
|
| 69 |
|
| 70 |
```json
|
| 71 |
{
|
|
|
|
| 78 |
"clientSecret": "如果你是 IdC 登录 需要配置这个" // 可选, 不需要请删除
|
| 79 |
}
|
| 80 |
```
|
| 81 |
+
|
| 82 |
+
#### 多凭据格式(新格式,支持故障转移和自动回写)
|
| 83 |
+
|
| 84 |
+
```json
|
| 85 |
+
[
|
| 86 |
+
{
|
| 87 |
+
"refreshToken": "第一个凭据的刷新token",
|
| 88 |
+
"expiresAt": "2025-12-31T02:32:45.144Z",
|
| 89 |
+
"authMethod": "social",
|
| 90 |
+
"priority": 0
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"refreshToken": "第二个凭据的刷新token",
|
| 94 |
+
"expiresAt": "2025-12-31T02:32:45.144Z",
|
| 95 |
+
"authMethod": "idc",
|
| 96 |
+
"clientId": "xxxxxxxxx",
|
| 97 |
+
"clientSecret": "xxxxxxxxx",
|
| 98 |
+
"priority": 1
|
| 99 |
+
}
|
| 100 |
+
]
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
> **多凭据特性说明**:
|
| 104 |
+
> - 按 `priority` 字段排序,数字越小优先级越高(默认为 0)
|
| 105 |
+
> - 单凭据最多重试 3 次,单请求最多重试 9 次
|
| 106 |
+
> - 自动故障转移到下一个可用凭据
|
| 107 |
+
> - 多凭据格式下 Token 刷新后自动回写到源文件
|
| 108 |
+
|
| 109 |
最小启动配置(social):
|
| 110 |
```json
|
| 111 |
{
|
|
|
|
| 114 |
"authMethod": "social"
|
| 115 |
}
|
| 116 |
```
|
| 117 |
+
|
| 118 |
最小启动配置(idc):
|
| 119 |
```json
|
| 120 |
{
|
|
|
|
| 175 |
|
| 176 |
### credentials.json
|
| 177 |
|
| 178 |
+
支持单对象格式(向后兼容)或数组格式(多凭据)。
|
| 179 |
+
|
| 180 |
| 字段 | 类型 | 描述 |
|
| 181 |
|------|------|-------------------------|
|
| 182 |
| `accessToken` | string | OAuth 访问令牌(可选,可自动刷新) |
|
|
|
|
| 186 |
| `authMethod` | string | 认证方式(social 或 idc) |
|
| 187 |
| `clientId` | string | IdC 登录的客户端 ID(可选) |
|
| 188 |
| `clientSecret` | string | IdC 登录的客户端密钥(可选) |
|
| 189 |
+
| `priority` | number | 凭据优先级,数字越小越优先,默认为 0(多凭据格式时有效)|
|
| 190 |
|
| 191 |
## 模型映射
|
| 192 |
|
|
|
|
| 229 |
│ └── crc.rs # CRC 校验
|
| 230 |
├── Cargo.toml # 项目配置
|
| 231 |
├── config.example.json # 配置示例
|
| 232 |
+
├── credentials.example.social.json # Social 凭证示例
|
| 233 |
+
├── credentials.example.idc.json # IdC 凭证示例
|
| 234 |
+
└── credentials.example.multiple.json # 多凭据示例
|
| 235 |
```
|
| 236 |
|
| 237 |
## 技术栈
|
credentials.example.idc.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"refreshToken": "xxxxxxxxxxxxxxxxxxxx",
|
| 3 |
"expiresAt": "2025-12-31T02:32:45.144Z",
|
| 4 |
-
"authMethod": "
|
| 5 |
"clientId": "xxxxxxxxx",
|
| 6 |
"clientSecret": "xxxxxxxxx"
|
| 7 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"refreshToken": "xxxxxxxxxxxxxxxxxxxx",
|
| 3 |
"expiresAt": "2025-12-31T02:32:45.144Z",
|
| 4 |
+
"authMethod": "idc",
|
| 5 |
"clientId": "xxxxxxxxx",
|
| 6 |
"clientSecret": "xxxxxxxxx"
|
| 7 |
}
|
credentials.example.multiple.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"refreshToken": "xxxxxxxxxxxxxxxxxxxx",
|
| 4 |
+
"expiresAt": "2025-12-31T02:32:45.144Z",
|
| 5 |
+
"authMethod": "social",
|
| 6 |
+
"priority": 0
|
| 7 |
+
},
|
| 8 |
+
{
|
| 9 |
+
"refreshToken": "yyyyyyyyyyyyyyyyyyyy",
|
| 10 |
+
"expiresAt": "2025-12-31T02:32:45.144Z",
|
| 11 |
+
"authMethod": "idc",
|
| 12 |
+
"clientId": "xxxxxxxxx",
|
| 13 |
+
"clientSecret": "xxxxxxxxx",
|
| 14 |
+
"priority": 1
|
| 15 |
+
}
|
| 16 |
+
]
|