使用 Gemini CLI 遇到一些问题,分享一下,希望能帮到大家。
结论:
Auth 方式影响模型: API Key -> Gemini 2.5 Flash ; Google 登录 -> Gemini 2.5 Pro 。
API Key 容易 429 。
问题及解决:
Google 登录失败( Workspace ):
Failed to login. Ensure your Google account is not a Workspace account...
Login with Google Workspace
登录。(参考)缺少 GOOGLE_CLOUD_PROJECT
环境变量:
GOOGLE_CLOUD_PROJECT environment variable not found.Add that to your .env and try again, no reload needed!
Gemini Cloud API
(Gemini Code Assist Standard & Enterprise)。~/.env
添加:export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"
(YOUR_PROJECT_ID 见 GCP 控制台)。断开问题:
export https_proxy=xxx
。体验:
![]() | 1 binggg 108 天前 workspace 要钱呢 |
![]() | 3 fly2never 108 天前 我用了全局模式 ,TUN , 但是还是提示 API Error: exception TypeError: fetch failed sending request |
![]() | 4 knightdf 108 天前 我用的 api key ,也是默认走了 pro 模型,导出 GEMINI_MODEL 环境变量使用 flash 后还是走 pro 模型 |
![]() | 5 miracleyin 108 天前 提示 403 怎么办呢 [API Error: [{ "error": { "code": 403, "message": "Permission denied on resource project <project_id>.", "errors": [ { "message": "Permission denied on resource project <project_id>.", "domain": "global", "reason": "forbidden" } ], "status": "PERMISSION_DENIED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "CONSUMER_INVALID", "domain": "googleapis.com", "metadata": { "containerInfo": "<project_id>", "service": "cloudaicompanion.googleapis.com", "consumer": "projects/<project_id>" } }, { "@type": "type.googleapis.com/google.rpc.LocalizedMessage", "locale": "en-US", "message": "Permission denied on resource project <project_id>." }, { "@type": "type.googleapis.com/google.rpc.Help", "links": [ { "description": "Google developers console", "url": "https://console.developers.google.com" } ] } ] } } ]] |
![]() | 6 jovix OP @binggg 你不是 workspace 用户那就直接用个人用户登录就行( Login with Google )本来目前就是个人用户免费用的。用 workspace 是因为之前我账号开过 Google Cloud 所以需要使用 workspace 登录。 |
![]() | 7 wyntalgeer 108 天前 我有一次用着发现不对劲,瞥了一眼发现不知何时她给我自动换成 flash 了……原因未知,我一直用 Google 登录的,关掉重开就又是 pro 了 给狗哥点耐心吧,issue 奔 300 去了,狗哥那边还是凌晨…… |
![]() | 10 jovix OP @wyntalgeer 我也遇到了 |
![]() | 11 jovix OP @wyntalgeer 现在大家已经开始用 gemini cli 给 gemini cli 改 bug 了,一晚上把半个月的的工作量干了 |
![]() | 12 tyqing 108 天前 我用 windows 系统,v2rayN 代理,开启了 TUN 模式解决了我的问题,否则一直卡在浏览器授权,然后 powershell 显示: Failed to login. │ │ Message: request to https://oauth2.googleapis.com/token failed, reason: connect ETIMEDOUT 并且我也设置了: set http_proxy=http://127.0.0.1:10808 set https_proxy=http://127.0.0.1:10808 |
![]() | 13 jovix OP @miracleyin 看提示是权限问题,你使用 [Login with Google] 试过吗 |
![]() | 14 wyntalgeer 108 天前 @jovix #11 哈哈,你已经是个成熟的基米奶了,应该自己给自己改 bug 了 ![]() |
15 goinghugh 108 天前 Slow response times detected. Automatically switching from gemini-2.5-pro to gemini-2.5-flash for faster responses for the remainder of this session. To avoid this you can utilize a Gemini API Key. See: https://goo.gle/gemini-cli-docs-auth#gemini-api-key You can switch authentication methods by typing /auth 登录使用 Login with Google ,刚聊了一句话,就提示了这个了,有什么办法吗 |
![]() | 16 jovix OP @tyqing 你这个问题我刚刚在 win 上也出现了,我先是在终端上 set proxy ,也是这个报错:Failed to login. │ │ Message: request to https://oauth2.googleapis.com/token failed, reason: connect ETIMEDOUT 。然后我开了 TUN ,再登录就成功了。但我用的是 clash verge |
![]() | 17 miracleyin 108 天前 @jovix 使用 Login with Google ,然后环境变量加了 project id |
18 ClaudeCode 108 天前 Slow response times detected. Automatically switching from gemini-2.5-pro to gemini-2.5-flash for faster responses for the remainder of this session. |
![]() | 19 zwzwzwzwzxt 108 天前 同样,用 API_KEY 就只能用 flash ,我强行指定 pro 会报错说 pro 模型暂时不可用。 使用账户登录虽然能用 pro 了,但有的时候会警告说检测到 pro 响应速度慢,又自动给我切到 flash 了。。 |
![]() | 21 jovix OP |
![]() | 22 Leeeeex PRO @zwzwzwzwzxt 猜测是因为 2.5 pro 的 apikey 已经是 paid only 了,白嫖的用不了,所以就只能用 flash |
23 chneqi 108 天前 @tyqing 同样的问题,不过我这里不知道为什么开 tun 会代理失效。但我找到了另一个方法,用 proxifier 指定 node.exe 走 v2 的 http 代理端口过授权,然后就不需要 proxifier 了,之后只需要 set http_proxy 那两句就可以了 |
![]() | 24 zephyru 108 天前 这些问题我也都遇到了...基本问了几句就出问题...等一个更开源可以自己指定 api 的版本,现在正式用尤其是在国内难度还是有点高... |
25 teaser 108 天前 我现在很想知道 workspace 怎么转成个人,workspace 会收费的吧。 或者后面可以支持个人帐号吗,昨天凌晨肉眼可见的 start++ 和 issue ++ |
![]() | 26 zx9481 108 天前 不管什么工具 只要不降智就行 |
![]() | 27 wynemo 108 天前 @miracleyin #5 按提示打开项目的 gmini api 的权限 |
![]() | 28 miracleyin 107 天前 @wynemo 加过了,现在报错是超过限额... 还是搞个新的没有 GCP 的账号吧.. |
29 ttzhengqian 107 天前 对话时提示:[API Error: exception TypeError: fetch failed sending request] 咋解决 |
30 ttzhengqian 107 天前 @fly2never 你那解决了吗,我也出现这问题,环境变量都配置了 |
![]() | 31 lux182 107 天前 让子弹飞一会儿 |
36 Need4more 107 天前 有人知道如何退出吗? CTRL c 不行 |
38 GetRich233 105 天前 感谢. 问题 2 简直救命 |
39 jiujiucq 96 天前 VS Code 里,用的插件。常出现回复截断,不知道是哪里问题。 |