windows使用claude code并直接使用gemini(不是MCP)

我也是这个问题,奇怪了。
curl http://localhost:8082/health 这个请求有反应
{“status”:“healthy”,“timestamp”:“2025-06-23T16:04:19.075059”,“version”:“2.5.0”,“gemini_api_configured”:true,“api_key_valid”:true,“streaming_config”:{“force_disabled”:false,“emergency_disabled”:false,“max_retries”:12}}
但是curl http://localhost:8082/test-connection
则报超时错误{“status”:“failed”,“error_type”:“Connection Error”,“message”:“Connection or timeout error. Please check your internet connection and try again.”,“timestamp”:“2025-06-23T16:07:37.814844”,“suggestions”:[“Check your internet connection”,“Verify firewall settings allow HTTPS traffic”,“Try again in a few moments”]}l

而服务器端看配置是对的
~/src/claude_code_gemini_proxy$ python server.py
:white_check_mark: Configuration loaded: API_KEY=********************…, BIG_MODEL=‘gemini-2.5-pro-preview-06-05’, SMALL_MODEL=‘gemini-2.5-pro-preview-06-05’
:magnifying_glass_tilted_left: Validating startup configuration…
:white_check_mark: Network connectivity: OK
:rocket: Enhanced Gemini-to-Claude API Proxy v2.5.0
:white_check_mark: Configuration loaded successfully
Big Model: gemini-2.5-pro-preview-06-05
Small Model: gemini-2.5-pro-preview-06-05
Available Models: 10
Max Tokens Limit: 8192
Request Timeout: 90s
Max Retries: 2
Max Streaming Retries: 12
Force Disable Streaming: False
Emergency Disable Streaming: False
HTTPS Proxy: http://proxy.xxx.com:8080/
Log Level: WARNING
Server: 0.0.0.0:8082

你是不是没在.env配置自己gemini的KEY?

你的环境是什么样的?
claude_code_gemini_proxy是在主机然后claude code是在WSL么?

@a3members @dwl
你们直接使用这个curl测试下呢

curl -X POST http://192.168.31.110:8082/v1/messages -H “Content-Type: application/json” -H “Authorization: Bearer YOUR_API_KEY” -d ‘{“model”: “gemini-1.5-flash-latest”, “max_tokens”: 100, “messages”: [{“role”: “user”, “content”: “你吃饭了吗?”}]}’

可以白嫖吗???

肯定设置了的啊。而且这个key我在cherrystudio里面都是能用的

我这个全程都是安装在virtualbox虚拟机里面,ubuntu。 其中ubuntun是独立IP,和外面windows主机IP不一样,我这个ubuntu里面其实claude code直接用anthropic的API key可以用的。就是太烧token了。不知道为什么claude proxy跑起来老是报API 错误。

我在.env开了DEBUG模式。

POST Request Sent from LiteLLM:
curl -X POST
https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=*****r-rs
-H ‘Content-Type: ap****on’
-d ‘{‘contents’: [{‘role’: ‘user’, ‘parts’: [{‘text’: ‘Hello’}]}], ‘generationConfig’: {‘max_output_tokens’: 5}}’

2025-06-24 09:41:26,148 - DEBUG -

POST Request Sent from LiteLLM:
curl -X POST
https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-latest:generateContent?key=*****r-rs
-H ‘Content-Type: ap****on’
-d ‘{‘contents’: [{‘role’: ‘user’, ‘parts’: [{‘text’: ‘Hello’}]}], ‘generationConfig’: {‘max_output_tokens’: 5}}’

感觉问题是这个请求超时了,很奇怪的是为什么我单独运行上述curl -x请求,google的API是有反馈消息的 。

佬,请问下server端必须使用gemini官方的api吗?我官方生成的api没有额度,能用第三方的吗?

好用,感谢分享