Skip to content

Commit 593f3f6

Browse files
Merge branch 'router-for-me:main' into main
2 parents 47a83e3 + 05a3566 commit 593f3f6

44 files changed

Lines changed: 4764 additions & 694 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -8,123 +8,6 @@ All third-party provider support is maintained by community contributors; CLIPro
88

99
The Plus release stays in lockstep with the mainline features.
1010

11-
## Differences from the Mainline
12-
13-
[![z.ai](https://assets.router-for.me/english-5-0.jpg)](https://z.ai/subscribe?ic=8JVLJQFSKB)
14-
15-
## New Features (Plus Enhanced)
16-
17-
GLM CODING PLAN is a subscription service designed for AI coding, starting at just $10/month. It provides access to their flagship GLM-4.7 & (GLM-5 Only Available for Pro Users)model across 10+ popular AI coding tools (Claude Code, Cline, Roo Code, etc.), offering developers top-tier, fast, and stable coding experiences.
18-
19-
## Kiro Authentication
20-
21-
### CLI Login
22-
23-
> **Note:** Google/GitHub login is not available for third-party applications due to AWS Cognito restrictions.
24-
25-
**AWS Builder ID** (recommended):
26-
27-
```bash
28-
# Device code flow
29-
./CLIProxyAPI --kiro-aws-login
30-
31-
# Authorization code flow
32-
./CLIProxyAPI --kiro-aws-authcode
33-
```
34-
35-
**Import token from Kiro IDE:**
36-
37-
```bash
38-
./CLIProxyAPI --kiro-import
39-
```
40-
41-
To get a token from Kiro IDE:
42-
43-
1. Open Kiro IDE and login with Google (or GitHub)
44-
2. Find the token file: `~/.kiro/kiro-auth-token.json`
45-
3. Run: `./CLIProxyAPI --kiro-import`
46-
47-
**AWS IAM Identity Center (IDC):**
48-
49-
```bash
50-
./CLIProxyAPI --kiro-idc-login --kiro-idc-start-url https://d-xxxxxxxxxx.awsapps.com/start
51-
52-
# Specify region
53-
./CLIProxyAPI --kiro-idc-login --kiro-idc-start-url https://d-xxxxxxxxxx.awsapps.com/start --kiro-idc-region us-west-2
54-
```
55-
56-
**Additional flags:**
57-
58-
| Flag | Description |
59-
|------|-------------|
60-
| `--no-browser` | Don't open browser automatically, print URL instead |
61-
| `--no-incognito` | Use existing browser session (Kiro defaults to incognito). Useful for corporate SSO that requires an authenticated browser session |
62-
| `--kiro-idc-start-url` | IDC Start URL (required with `--kiro-idc-login`) |
63-
| `--kiro-idc-region` | IDC region (default: `us-east-1`) |
64-
| `--kiro-idc-flow` | IDC flow type: `authcode` (default) or `device` |
65-
66-
### Web-based OAuth Login
67-
68-
Access the Kiro OAuth web interface at:
69-
70-
```
71-
http://your-server:8080/v0/oauth/kiro
72-
```
73-
74-
This provides a browser-based OAuth flow for Kiro (AWS CodeWhisperer) authentication with:
75-
- AWS Builder ID login
76-
- AWS Identity Center (IDC) login
77-
- Token import from Kiro IDE
78-
79-
## Quick Deployment with Docker
80-
81-
### One-Command Deployment
82-
83-
```bash
84-
# Create deployment directory
85-
mkdir -p ~/cli-proxy && cd ~/cli-proxy
86-
87-
# Create docker-compose.yml
88-
cat > docker-compose.yml << 'EOF'
89-
services:
90-
cli-proxy-api:
91-
image: eceasy/cli-proxy-api-plus:latest
92-
container_name: cli-proxy-api-plus
93-
ports:
94-
- "8317:8317"
95-
volumes:
96-
- ./config.yaml:/CLIProxyAPI/config.yaml
97-
- ./auths:/root/.cli-proxy-api
98-
- ./logs:/CLIProxyAPI/logs
99-
restart: unless-stopped
100-
EOF
101-
102-
# Download example config
103-
curl -o config.yaml https://raw.githubusercontent.com/router-for-me/CLIProxyAPIPlus/main/config.example.yaml
104-
105-
# Pull and start
106-
docker compose pull && docker compose up -d
107-
```
108-
109-
### Configuration
110-
111-
Edit `config.yaml` before starting:
112-
113-
```yaml
114-
# Basic configuration example
115-
server:
116-
port: 8317
117-
118-
# Add your provider configurations here
119-
```
120-
121-
### Update to Latest Version
122-
123-
```bash
124-
cd ~/cli-proxy
125-
docker compose pull && docker compose up -d
126-
```
127-
12811
## Contributing
12912

13013
This project only accepts pull requests that relate to third-party provider support. Any pull requests unrelated to third-party provider support will be rejected.

README_CN.md

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -8,123 +8,6 @@
88

99
该 Plus 版本的主线功能与主线功能强制同步。
1010

11-
## 与主线版本版本差异
12-
13-
[![bigmodel.cn](https://assets.router-for.me/chinese-5-0.jpg)](https://www.bigmodel.cn/claude-code?ic=RRVJPB5SII)
14-
15-
## 新增功能 (Plus 增强版)
16-
17-
GLM CODING PLAN 是专为AI编码打造的订阅套餐,每月最低仅需20元,即可在十余款主流AI编码工具如 Claude Code、Cline、Roo Code 中畅享智谱旗舰模型GLM-4.7(受限于算力,目前仅限Pro用户开放),为开发者提供顶尖的编码体验。
18-
19-
智谱AI为本产品提供了特别优惠,使用以下链接购买可以享受九折优惠:https://www.bigmodel.cn/claude-code?ic=RRVJPB5SII
20-
21-
### 命令行登录
22-
23-
> **注意:** 由于 AWS Cognito 限制,Google/GitHub 登录不可用于第三方应用。
24-
25-
**AWS Builder ID**(推荐):
26-
27-
```bash
28-
# 设备码流程
29-
./CLIProxyAPI --kiro-aws-login
30-
31-
# 授权码流程
32-
./CLIProxyAPI --kiro-aws-authcode
33-
```
34-
35-
**从 Kiro IDE 导入令牌:**
36-
37-
```bash
38-
./CLIProxyAPI --kiro-import
39-
```
40-
41-
获取令牌步骤:
42-
43-
1. 打开 Kiro IDE,使用 Google(或 GitHub)登录
44-
2. 找到令牌文件:`~/.kiro/kiro-auth-token.json`
45-
3. 运行:`./CLIProxyAPI --kiro-import`
46-
47-
**AWS IAM Identity Center (IDC):**
48-
49-
```bash
50-
./CLIProxyAPI --kiro-idc-login --kiro-idc-start-url https://d-xxxxxxxxxx.awsapps.com/start
51-
52-
# 指定区域
53-
./CLIProxyAPI --kiro-idc-login --kiro-idc-start-url https://d-xxxxxxxxxx.awsapps.com/start --kiro-idc-region us-west-2
54-
```
55-
56-
**附加参数:**
57-
58-
| 参数 | 说明 |
59-
|------|------|
60-
| `--no-browser` | 不自动打开浏览器,打印 URL |
61-
| `--no-incognito` | 使用已有浏览器会话(Kiro 默认使用无痕模式),适用于需要已登录浏览器会话的企业 SSO 场景 |
62-
| `--kiro-idc-start-url` | IDC Start URL(`--kiro-idc-login` 必需) |
63-
| `--kiro-idc-region` | IDC 区域(默认:`us-east-1`|
64-
| `--kiro-idc-flow` | IDC 流程类型:`authcode`(默认)或 `device` |
65-
66-
### 网页端 OAuth 登录
67-
68-
访问 Kiro OAuth 网页认证界面:
69-
70-
```
71-
http://your-server:8080/v0/oauth/kiro
72-
```
73-
74-
提供基于浏览器的 Kiro (AWS CodeWhisperer) OAuth 认证流程,支持:
75-
- AWS Builder ID 登录
76-
- AWS Identity Center (IDC) 登录
77-
- 从 Kiro IDE 导入令牌
78-
79-
## Docker 快速部署
80-
81-
### 一键部署
82-
83-
```bash
84-
# 创建部署目录
85-
mkdir -p ~/cli-proxy && cd ~/cli-proxy
86-
87-
# 创建 docker-compose.yml
88-
cat > docker-compose.yml << 'EOF'
89-
services:
90-
cli-proxy-api:
91-
image: eceasy/cli-proxy-api-plus:latest
92-
container_name: cli-proxy-api-plus
93-
ports:
94-
- "8317:8317"
95-
volumes:
96-
- ./config.yaml:/CLIProxyAPI/config.yaml
97-
- ./auths:/root/.cli-proxy-api
98-
- ./logs:/CLIProxyAPI/logs
99-
restart: unless-stopped
100-
EOF
101-
102-
# 下载示例配置
103-
curl -o config.yaml https://raw.githubusercontent.com/router-for-me/CLIProxyAPIPlus/main/config.example.yaml
104-
105-
# 拉取并启动
106-
docker compose pull && docker compose up -d
107-
```
108-
109-
### 配置说明
110-
111-
启动前请编辑 `config.yaml`
112-
113-
```yaml
114-
# 基本配置示例
115-
server:
116-
port: 8317
117-
118-
# 在此添加你的供应商配置
119-
```
120-
121-
### 更新到最新版本
122-
123-
```bash
124-
cd ~/cli-proxy
125-
docker compose pull && docker compose up -d
126-
```
127-
12811
## 贡献
12912

13013
该项目仅接受第三方供应商支持的 Pull Request。任何非第三方供应商支持的 Pull Request 都将被拒绝。

config.example.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ nonstream-keepalive-interval: 0
219219
# models: # The models supported by the provider.
220220
# - name: "moonshotai/kimi-k2:free" # The actual model name.
221221
# alias: "kimi-k2" # The alias used in the API.
222+
# # You may repeat the same alias to build an internal model pool.
223+
# # The client still sees only one alias in the model list.
224+
# # Requests to that alias will round-robin across the upstream names below,
225+
# # and if the chosen upstream fails before producing output, the request will
226+
# # continue with the next upstream model in the same alias pool.
227+
# - name: "qwen3.5-plus"
228+
# alias: "claude-opus-4.66"
229+
# - name: "glm-5"
230+
# alias: "claude-opus-4.66"
231+
# - name: "kimi-k2.5"
232+
# alias: "claude-opus-4.66"
222233

223234
# Vertex API keys (Vertex-compatible endpoints, use API key + base URL)
224235
# vertex-api-key:

internal/api/handlers/management/auth_files.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,12 +1312,12 @@ func (h *Handler) RequestGeminiCLIToken(c *gin.Context) {
13121312
projects, errAll := onboardAllGeminiProjects(ctx, gemClient, &ts)
13131313
if errAll != nil {
13141314
log.Errorf("Failed to complete Gemini CLI onboarding: %v", errAll)
1315-
SetOAuthSessionError(state, "Failed to complete Gemini CLI onboarding")
1315+
SetOAuthSessionError(state, fmt.Sprintf("Failed to complete Gemini CLI onboarding: %v", errAll))
13161316
return
13171317
}
13181318
if errVerify := ensureGeminiProjectsEnabled(ctx, gemClient, projects); errVerify != nil {
13191319
log.Errorf("Failed to verify Cloud AI API status: %v", errVerify)
1320-
SetOAuthSessionError(state, "Failed to verify Cloud AI API status")
1320+
SetOAuthSessionError(state, fmt.Sprintf("Failed to verify Cloud AI API status: %v", errVerify))
13211321
return
13221322
}
13231323
ts.ProjectID = strings.Join(projects, ",")
@@ -1326,7 +1326,7 @@ func (h *Handler) RequestGeminiCLIToken(c *gin.Context) {
13261326
ts.Auto = false
13271327
if errSetup := performGeminiCLISetup(ctx, gemClient, &ts, ""); errSetup != nil {
13281328
log.Errorf("Google One auto-discovery failed: %v", errSetup)
1329-
SetOAuthSessionError(state, "Google One auto-discovery failed")
1329+
SetOAuthSessionError(state, fmt.Sprintf("Google One auto-discovery failed: %v", errSetup))
13301330
return
13311331
}
13321332
if strings.TrimSpace(ts.ProjectID) == "" {
@@ -1337,19 +1337,19 @@ func (h *Handler) RequestGeminiCLIToken(c *gin.Context) {
13371337
isChecked, errCheck := checkCloudAPIIsEnabled(ctx, gemClient, ts.ProjectID)
13381338
if errCheck != nil {
13391339
log.Errorf("Failed to verify Cloud AI API status: %v", errCheck)
1340-
SetOAuthSessionError(state, "Failed to verify Cloud AI API status")
1340+
SetOAuthSessionError(state, fmt.Sprintf("Failed to verify Cloud AI API status: %v", errCheck))
13411341
return
13421342
}
13431343
ts.Checked = isChecked
13441344
if !isChecked {
13451345
log.Error("Cloud AI API is not enabled for the auto-discovered project")
1346-
SetOAuthSessionError(state, "Cloud AI API not enabled")
1346+
SetOAuthSessionError(state, fmt.Sprintf("Cloud AI API not enabled for project %s", ts.ProjectID))
13471347
return
13481348
}
13491349
} else {
13501350
if errEnsure := ensureGeminiProjectAndOnboard(ctx, gemClient, &ts, requestedProjectID); errEnsure != nil {
13511351
log.Errorf("Failed to complete Gemini CLI onboarding: %v", errEnsure)
1352-
SetOAuthSessionError(state, "Failed to complete Gemini CLI onboarding")
1352+
SetOAuthSessionError(state, fmt.Sprintf("Failed to complete Gemini CLI onboarding: %v", errEnsure))
13531353
return
13541354
}
13551355

@@ -1362,13 +1362,13 @@ func (h *Handler) RequestGeminiCLIToken(c *gin.Context) {
13621362
isChecked, errCheck := checkCloudAPIIsEnabled(ctx, gemClient, ts.ProjectID)
13631363
if errCheck != nil {
13641364
log.Errorf("Failed to verify Cloud AI API status: %v", errCheck)
1365-
SetOAuthSessionError(state, "Failed to verify Cloud AI API status")
1365+
SetOAuthSessionError(state, fmt.Sprintf("Failed to verify Cloud AI API status: %v", errCheck))
13661366
return
13671367
}
13681368
ts.Checked = isChecked
13691369
if !isChecked {
13701370
log.Error("Cloud AI API is not enabled for the selected project")
1371-
SetOAuthSessionError(state, "Cloud AI API not enabled")
1371+
SetOAuthSessionError(state, fmt.Sprintf("Cloud AI API not enabled for project %s", ts.ProjectID))
13721372
return
13731373
}
13741374
}

internal/registry/model_definitions_static_data.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,21 @@ func GetGeminiModels() []*ModelInfo {
211211
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
212212
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}},
213213
},
214+
{
215+
ID: "gemini-3.1-flash-image-preview",
216+
Object: "model",
217+
Created: 1771459200,
218+
OwnedBy: "google",
219+
Type: "gemini",
220+
Name: "models/gemini-3.1-flash-image-preview",
221+
Version: "3.1",
222+
DisplayName: "Gemini 3.1 Flash Image Preview",
223+
Description: "Gemini 3.1 Flash Image Preview",
224+
InputTokenLimit: 1048576,
225+
OutputTokenLimit: 65536,
226+
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
227+
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"minimal", "high"}},
228+
},
214229
{
215230
ID: "gemini-3-flash-preview",
216231
Object: "model",
@@ -351,6 +366,17 @@ func GetGeminiVertexModels() []*ModelInfo {
351366
SupportedGenerationMethods: []string{"generateContent", "countTokens", "createCachedContent", "batchGenerateContent"},
352367
Thinking: &ThinkingSupport{Min: 128, Max: 32768, ZeroAllowed: false, DynamicAllowed: true, Levels: []string{"low", "high"}},
353368
},
369+
{
370+
ID: "gemini-3.1-flash-image-preview",
371+
Object: "model",
372+
Created: 1771459200,
373+
OwnedBy: "google",
374+
Type: "gemini",
375+
Name: "models/gemini-3.1-flash-image-preview",
376+
Version: "3.1",
377+
DisplayName: "Gemini 3.1 Flash Image Preview",
378+
Description: "Gemini 3.1 Flash Image Preview",
379+
},
354380
{
355381
ID: "gemini-3.1-flash-lite-preview",
356382
Object: "model",

0 commit comments

Comments
 (0)