稳定性优化方案
在生成长篇内容时,网络中断或超时可能导致流式响应中断。geminicli2api提供以下保障机制:
technical realization
- 客户端配置::
- 设置15-30秒的读超时(
timeout=(30, 300)
) - 启用自动重试机制(建议最多3次)
- 设置15-30秒的读超时(
- 服务端优化::
- utilization
nginx
反代配置keepalive_timeout 300s - Docker部署时设置
--restart=unless-stopped
- utilization
- 检查点恢复::
- 记录最后收到的chunk ID
- pass (a bill or inspection etc)
last_event_id
参数实现断点续传
best practice
对于万字以上长文,建议:
1. 分段请求(每段2000tokens)
2. 使用thinkingConfig
显示控制内存占用
3. 监控X-RateLimit-Remaining
头部避免配额耗尽
This answer comes from the articlegeminicli2api: Proxy tool to convert Gemini CLI to OpenAI-compatible APIsThe