[GH-ISSUE #73] 配置 Gemini CLI 后无法在 Roo Code 中调用成功 #63

Closed
opened 2026-02-27 07:17:45 +03:00 by kerem · 9 comments
Owner

Originally created by @manzhu on GitHub (Nov 13, 2025).
Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/73

错误: Gemini 生成上下文流错误:Incomplete JSON segment at the end

请问用 docker 部署的话,“OAuth凭据文件路径” 通过 base64 提供的话,是不是就是将 oauth_creds.json的全部内容转为 base64 后贴到 web console 里?

目前是将所有oauth_creds.json的内容转成 base64 后贴到 “OAuth凭据 (Base64)”
也生成了新的 project ID 填入:项目ID

Roo Code 里:

Image

但是测试失败:

Image

刚开始接触不知道哪里可以看到比较详细的配置教程?谢谢指教

Originally created by @manzhu on GitHub (Nov 13, 2025). Original GitHub issue: https://github.com/justlovemaki/AIClient-2-API/issues/73 错误: Gemini 生成上下文流错误:Incomplete JSON segment at the end 请问用 docker 部署的话,“OAuth凭据文件路径” 通过 base64 提供的话,是不是就是将 oauth_creds.json的全部内容转为 base64 后贴到 web console 里? 目前是将所有oauth_creds.json的内容转成 base64 后贴到 “OAuth凭据 (Base64)” 也生成了新的 project ID 填入:项目ID Roo Code 里: ![Image](https://github.com/user-attachments/assets/fe2c3274-9ae9-4514-9aba-aa684fdc77c1) 但是测试失败: ![Image](https://github.com/user-attachments/assets/231423a6-2525-41a5-b084-59e24c3e04d1) 刚开始接触不知道哪里可以看到比较详细的配置教程?谢谢指教
kerem closed this issue 2026-02-27 07:17:45 +03:00
Author
Owner

@justlovemaki commented on GitHub (Nov 13, 2025):

是没有先生成授权文件吗?有启动程序的命令行里的日志吗?

<!-- gh-comment-id:3528359725 --> @justlovemaki commented on GitHub (Nov 13, 2025): 是没有先生成授权文件吗?有启动程序的命令行里的日志吗?
Author
Owner

@manzhu commented on GitHub (Nov 14, 2025):

下面是详细的步骤,如果有错误的地方多谢指教:

  1. 安装 Gemini CLI 并完成授权,确认 ~/.gemini 目录下有oauth_creds.json 文件
  2. 配置文件如下, 其中通过 GEMINI_OAUTH_CREDS_FILE_PATH 指定挂载的到 docker 内的授权文件目录:/opt/oauth_creds.json

{
"REQUIRED_API_KEY": "123456",
"SERVER_PORT": 3000,
"HOST": "0.0.0.0",
"MODEL_PROVIDER": "gemini-cli-oauth",
"OPENAI_API_KEY": "xxx",
"OPENAI_BASE_URL": "https://openai/v1",
"CLAUDE_API_KEY": "xxx",
"CLAUDE_BASE_URL": "https://anthropic/v1",
"PROJECT_ID": null,
"GEMINI_OAUTH_CREDS_BASE64": null,
"GEMINI_OAUTH_CREDS_FILE_PATH": "/opt/oauth_creds.json",
"KIRO_OAUTH_CREDS_BASE64": null,
"KIRO_OAUTH_CREDS_FILE_PATH": null,
"QWEN_OAUTH_CREDS_FILE_PATH": null,
"SYSTEM_PROMPT_FILE_PATH": "input_system_prompt.txt",
"SYSTEM_PROMPT_MODE": "overwrite",
"PROMPT_LOG_BASE_NAME": "prompt_log",
"PROMPT_LOG_MODE": "none",
"REQUEST_MAX_RETRIES": 3,
"REQUEST_BASE_DELAY": 1000,
"CRON_NEAR_MINUTES": 1,
"CRON_REFRESH_TOKEN": false,
"PROVIDER_POOLS_FILE_PATH": "provider_pools.json"
}

  1. 启动 docker:

$ docker run -d -p 3000:3000 -v /xxxx/AIClient-2-API/config/config.json:/app/config.json -v /xxx/.gemini/:/opt --name aiclient2api aiclient2api

  1. 确认 docker 镜像内已经可以看到授权文件内容:

$ docker exec -it aiclient2api /bin/sh
/app # ls -al /opt
total 20
drwxr-xr-x 8 root root 256 Nov 14 02:01 .
drwxr-xr-x 1 root root 4096 Nov 14 02:59 ..
drwxr-xr-x 2 root root 64 Nov 14 02:01 data
-rw-r--r-- 1 root root 52 Nov 13 12:12 google_accounts.json
-rw-r--r-- 1 root root 36 Nov 13 12:12 installation_id
-rw------- 1 root root 1764 Nov 14 02:12 oauth_creds.json
-rw-r--r-- 1 root root 156 Nov 14 02:21 settings.json
drwxr-xr-x 5 root root 160 Nov 14 02:12 tmp

  1. docker 启动日志如下:
[Config] Loaded configuration from config.json
[System Prompt] Specified system prompt file not found: input_system_prompt.txt
[Config Error] Failed to load provider pools from provider_pools.json: ENOENT: no such file or directory, open 'provider_pools.json'
[Initialization] No provider pools configured. Using single provider mode.
[Initialization] Initializing single service adapter for gemini-cli-oauth...
[Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined
--- Unified API Server Configuration ---
  Primary Model Provider: gemini-cli-oauth
  [gemini-cli-oauth] OAuth Creds File Path: /opt/oauth_creds.json
  System Prompt File: input_system_prompt.txt
  System Prompt Mode: overwrite
  Host: 0.0.0.0
  Port: 3000
  Required API Key: 123456
  Prompt Logging: none
------------------------------------------

Unified API Server running on http://0.0.0.0:3000
Supports multiple API formats:
  • OpenAI-compatible: /v1/chat/completions, /v1/responses, /v1/models
  • Gemini-compatible: /v1beta/models, /v1beta/models/{model}:generateContent
  • Claude-compatible: /v1/messages
  • Health check: /health
  • UI Management Console: http://0.0.0.0:3000/
[UI] Opened login page in default browser

11/14/2025, 3:00:23 AM
[Server] Received request: POST http://localhost:3000/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse
[Config] Ignoring invalid MODEL_PROVIDER in path segment: v1beta
[Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined
[Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined"

11/14/2025, 3:00:25 AM
[Server] Received request: GET http://localhost:3000/health
[Config] Ignoring invalid MODEL_PROVIDER in path segment: health
[Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined
[Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined"
<!-- gh-comment-id:3530632960 --> @manzhu commented on GitHub (Nov 14, 2025): 下面是详细的步骤,如果有错误的地方多谢指教: 1. 安装 Gemini CLI 并完成授权,确认 ~/.gemini 目录下有oauth_creds.json 文件 2. 配置文件如下, 其中通过 GEMINI_OAUTH_CREDS_FILE_PATH 指定挂载的到 docker 内的授权文件目录:/opt/oauth_creds.json { "REQUIRED_API_KEY": "123456", "SERVER_PORT": 3000, "HOST": "0.0.0.0", "MODEL_PROVIDER": "gemini-cli-oauth", "OPENAI_API_KEY": "xxx", "OPENAI_BASE_URL": "https://openai/v1", "CLAUDE_API_KEY": "xxx", "CLAUDE_BASE_URL": "https://anthropic/v1", "PROJECT_ID": null, "GEMINI_OAUTH_CREDS_BASE64": null, "GEMINI_OAUTH_CREDS_FILE_PATH": "/opt/oauth_creds.json", "KIRO_OAUTH_CREDS_BASE64": null, "KIRO_OAUTH_CREDS_FILE_PATH": null, "QWEN_OAUTH_CREDS_FILE_PATH": null, "SYSTEM_PROMPT_FILE_PATH": "input_system_prompt.txt", "SYSTEM_PROMPT_MODE": "overwrite", "PROMPT_LOG_BASE_NAME": "prompt_log", "PROMPT_LOG_MODE": "none", "REQUEST_MAX_RETRIES": 3, "REQUEST_BASE_DELAY": 1000, "CRON_NEAR_MINUTES": 1, "CRON_REFRESH_TOKEN": false, "PROVIDER_POOLS_FILE_PATH": "provider_pools.json" } 3. 启动 docker: $ docker run -d -p 3000:3000 -v /xxxx/AIClient-2-API/config/config.json:/app/config.json -v /xxx/.gemini/:/opt --name aiclient2api aiclient2api 4. 确认 docker 镜像内已经可以看到授权文件内容: $ docker exec -it aiclient2api /bin/sh /app # ls -al /opt total 20 drwxr-xr-x 8 root root 256 Nov 14 02:01 . drwxr-xr-x 1 root root 4096 Nov 14 02:59 .. drwxr-xr-x 2 root root 64 Nov 14 02:01 data -rw-r--r-- 1 root root 52 Nov 13 12:12 google_accounts.json -rw-r--r-- 1 root root 36 Nov 13 12:12 installation_id -rw------- 1 root root 1764 Nov 14 02:12 oauth_creds.json -rw-r--r-- 1 root root 156 Nov 14 02:21 settings.json drwxr-xr-x 5 root root 160 Nov 14 02:12 tmp 5. docker 启动日志如下: ``` [Config] Loaded configuration from config.json [System Prompt] Specified system prompt file not found: input_system_prompt.txt [Config Error] Failed to load provider pools from provider_pools.json: ENOENT: no such file or directory, open 'provider_pools.json' [Initialization] No provider pools configured. Using single provider mode. [Initialization] Initializing single service adapter for gemini-cli-oauth... [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined --- Unified API Server Configuration --- Primary Model Provider: gemini-cli-oauth [gemini-cli-oauth] OAuth Creds File Path: /opt/oauth_creds.json System Prompt File: input_system_prompt.txt System Prompt Mode: overwrite Host: 0.0.0.0 Port: 3000 Required API Key: 123456 Prompt Logging: none ------------------------------------------ Unified API Server running on http://0.0.0.0:3000 Supports multiple API formats: • OpenAI-compatible: /v1/chat/completions, /v1/responses, /v1/models • Gemini-compatible: /v1beta/models, /v1beta/models/{model}:generateContent • Claude-compatible: /v1/messages • Health check: /health • UI Management Console: http://0.0.0.0:3000/ [UI] Opened login page in default browser 11/14/2025, 3:00:23 AM [Server] Received request: POST http://localhost:3000/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse [Config] Ignoring invalid MODEL_PROVIDER in path segment: v1beta [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined" 11/14/2025, 3:00:25 AM [Server] Received request: GET http://localhost:3000/health [Config] Ignoring invalid MODEL_PROVIDER in path segment: health [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined" ```
Author
Owner

@manzhu commented on GitHub (Nov 14, 2025):

另外不知道为什么 docker 镜像显示为 unhealthy... ,感觉是不是配置问题?

3bdc382fbd4f aiclient2api "docker-entrypoint.s…" 28 minutes ago Up 28 minutes (unhealthy) 0.0.0.0:3000->3000/tcp aiclient2api

<!-- gh-comment-id:3530669264 --> @manzhu commented on GitHub (Nov 14, 2025): 另外不知道为什么 docker 镜像显示为 unhealthy... ,感觉是不是配置问题? 3bdc382fbd4f aiclient2api "docker-entrypoint.s…" 28 minutes ago Up 28 minutes (unhealthy) 0.0.0.0:3000->3000/tcp aiclient2api
Author
Owner

@justlovemaki commented on GitHub (Nov 14, 2025):

[Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined"
Roo Code 里面传key的header还不一样?

<!-- gh-comment-id:3531195189 --> @justlovemaki commented on GitHub (Nov 14, 2025): [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined" Roo Code 里面传key的header还不一样?
Author
Owner

@manzhu commented on GitHub (Nov 14, 2025):

[Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined" Roo Code 里面传key的header还不一样?

是不是和 Roo Code 插件有关?我上面截图里 Roo Code 如果选择 Gemini 类型的话没有什么需要配置的地方,也就指定 本地 URL, 一个 API Key, 加上模型。我可以试试看 Cline 怎么样。

大佬有知道 Cline 或者 Roo 使用成功的例子吗?

<!-- gh-comment-id:3531227059 --> @manzhu commented on GitHub (Nov 14, 2025): > [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined" Roo Code 里面传key的header还不一样? 是不是和 Roo Code 插件有关?我上面截图里 Roo Code 如果选择 Gemini 类型的话没有什么需要配置的地方,也就指定 本地 URL, 一个 API Key, 加上模型。我可以试试看 Cline 怎么样。 大佬有知道 Cline 或者 Roo 使用成功的例子吗?
Author
Owner

@justlovemaki commented on GitHub (Nov 14, 2025):

[Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined" Roo Code 里面传key的header还不一样?

是不是和 Roo Code 插件有关?我上面截图里 Roo Code 如果选择 Gemini 类型的话没有什么需要配置的地方,也就指定 本地 URL, 一个 API Key, 加上模型。我可以试试看 Cline 怎么样。

大佬有知道 Cline 或者 Roo 使用成功的例子吗?

我刚试了,可以用啊。 API Key 你在确定一下和REQUIRED_API_KEY是否一致

/health,是有点问题,已经修复了

<!-- gh-comment-id:3531229428 --> @justlovemaki commented on GitHub (Nov 14, 2025): > > [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "xxxxxx", x-api-key: "undefined" Roo Code 里面传key的header还不一样? > > 是不是和 Roo Code 插件有关?我上面截图里 Roo Code 如果选择 Gemini 类型的话没有什么需要配置的地方,也就指定 本地 URL, 一个 API Key, 加上模型。我可以试试看 Cline 怎么样。 > > 大佬有知道 Cline 或者 Roo 使用成功的例子吗? 我刚试了,可以用啊。 API Key 你在确定一下和REQUIRED_API_KEY是否一致 /health,是有点问题,已经修复了
Author
Owner

@manzhu commented on GitHub (Nov 14, 2025):

我刚试了 CLINE,可以用。虽然日志里还能看到:Unauthorized request denied

11/14/2025, 7:18:57 AM
[Server] Received request: GET http://localhost:3000/health
[Config] Ignoring invalid MODEL_PROVIDER in path segment: health
[Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined
[Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined"

11/14/2025, 7:19:27 AM
[Server] Received request: GET http://localhost:3000/health
[Config] Ignoring invalid MODEL_PROVIDER in path segment: health
[Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined
[Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined"

11/14/2025, 7:19:51 AM
[Server] Received request: POST http://localhost:3000/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse
[Config] Ignoring invalid MODEL_PROVIDER in path segment: v1beta
[Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined
[Request Convert] Request format matches backend provider. No conversion needed.
[Content Generation] Model: gemini-2.5-pro, Stream: true
[Auth Token] Time until expiry: 00h 53m 55s

但是不知道为什么 Roo Code 就是一直不行,奇怪。。。

<!-- gh-comment-id:3531267417 --> @manzhu commented on GitHub (Nov 14, 2025): 我刚试了 CLINE,可以用。虽然日志里还能看到:Unauthorized request denied 11/14/2025, 7:18:57 AM [Server] Received request: GET http://localhost:3000/health [Config] Ignoring invalid MODEL_PROVIDER in path segment: health [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined" 11/14/2025, 7:19:27 AM [Server] Received request: GET http://localhost:3000/health [Config] Ignoring invalid MODEL_PROVIDER in path segment: health [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined" 11/14/2025, 7:19:51 AM [Server] Received request: POST http://localhost:3000/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse [Config] Ignoring invalid MODEL_PROVIDER in path segment: v1beta [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Request Convert] Request format matches backend provider. No conversion needed. [Content Generation] Model: gemini-2.5-pro, Stream: true [Auth Token] Time until expiry: 00h 53m 55s 但是不知道为什么 Roo Code 就是一直不行,奇怪。。。
Author
Owner

@justlovemaki commented on GitHub (Nov 14, 2025):

我刚试了 CLINE,可以用。虽然日志里还能看到:Unauthorized request denied

11/14/2025, 7:18:57 AM [Server] Received request: GET http://localhost:3000/health [Config] Ignoring invalid MODEL_PROVIDER in path segment: health [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined"

11/14/2025, 7:19:27 AM [Server] Received request: GET http://localhost:3000/health [Config] Ignoring invalid MODEL_PROVIDER in path segment: health [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined"

11/14/2025, 7:19:51 AM [Server] Received request: POST http://localhost:3000/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse [Config] Ignoring invalid MODEL_PROVIDER in path segment: v1beta [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Request Convert] Request format matches backend provider. No conversion needed. [Content Generation] Model: gemini-2.5-pro, Stream: true [Auth Token] Time until expiry: 00h 53m 55s

但是不知道为什么 Roo Code 就是一直不行,奇怪。。。

API Key 你在确定一下和REQUIRED_API_KEY是否一致?? 我测了在Roo Code也行

Unauthorized request denied是health接口的,最新代码已经修复了

<!-- gh-comment-id:3531308760 --> @justlovemaki commented on GitHub (Nov 14, 2025): > 我刚试了 CLINE,可以用。虽然日志里还能看到:Unauthorized request denied > > 11/14/2025, 7:18:57 AM [Server] Received request: GET http://localhost:3000/health [Config] Ignoring invalid MODEL_PROVIDER in path segment: health [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined" > > 11/14/2025, 7:19:27 AM [Server] Received request: GET http://localhost:3000/health [Config] Ignoring invalid MODEL_PROVIDER in path segment: health [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Auth] Unauthorized request denied. Bearer: "N/A", Query Key: "null", x-goog-api-key: "undefined", x-api-key: "undefined" > > 11/14/2025, 7:19:51 AM [Server] Received request: POST http://localhost:3000/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse [Config] Ignoring invalid MODEL_PROVIDER in path segment: v1beta [Adapter] getServiceAdapter, provider: gemini-cli-oauth, uuid: undefined [Request Convert] Request format matches backend provider. No conversion needed. [Content Generation] Model: gemini-2.5-pro, Stream: true [Auth Token] Time until expiry: 00h 53m 55s > > 但是不知道为什么 Roo Code 就是一直不行,奇怪。。。 API Key 你在确定一下和REQUIRED_API_KEY是否一致?? 我测了在Roo Code也行 Unauthorized request denied是health接口的,最新代码已经修复了
Author
Owner

@manzhu commented on GitHub (Nov 14, 2025):

感谢大佬,我重新安装了 Roo Code 插件,现在已经可以正常运行了!非常感谢!!

<!-- gh-comment-id:3531338773 --> @manzhu commented on GitHub (Nov 14, 2025): 感谢大佬,我重新安装了 Roo Code 插件,现在已经可以正常运行了!非常感谢!!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AIClient-2-API-justlovemaki#63
No description provided.