forked from su-kaka/gcli2api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.env.example
More file actions
179 lines (140 loc) · 6.2 KB
/
.env.example
File metadata and controls
179 lines (140 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# ================================================================
# GCLI2API 环境变量配置示例文件
# 复制此文件为 .env 并根据需要修改配置值
# ================================================================
# ================================================================
# 服务器配置
# ================================================================
# 服务器监听地址
# 默认: 0.0.0.0 (监听所有网络接口)
HOST=0.0.0.0
# 服务器端口
# 默认: 7861
PORT=7861
# ================================================================
# 密码配置 (支持分离密码)
# ================================================================
# 聊天API访问密码 (用于OpenAI和Gemini API端点认证)
# 默认: 继承通用密码或 pwd
API_PASSWORD=your_api_password
# 控制面板访问密码 (用于Web界面登录认证)
# 默认: 继承通用密码或 pwd
PANEL_PASSWORD=your_panel_password
# 通用访问密码 (兼容性保留)
# 设置后会覆盖上述两个专用密码,优先级最高
# 如果只想使用一个密码,设置此项即可
# 默认: pwd
PASSWORD=pwd
# ================================================================
# 存储配置
# ================================================================
# 存储后端优先级: PostgreSQL > MongoDB > 本地sqlite文件存储
# 系统会自动选择可用的最高优先级存储后端
# PostgreSQL 分布式存储模式配置 (最高优先级)
# 设置 POSTGRESQL_URI 后自动启用 PostgreSQL 模式
# 本地 PostgreSQL: postgresql://user:password@localhost:5432/gcli2api
# 带 SSL: postgresql://user:password@host:5432/gcli2api?sslmode=require
# 默认: 无 (不启用 PostgreSQL 存储)
POSTGRESQL_URI=postgresql://user:password@localhost:5432/gcli2api
# MongoDB 分布式存储模式配置 (第二优先级)
# 设置 MONGODB_URI 后自动启用 MongoDB 模式,不再使用本地文件存储
# Redis 缓存存储配置
# 设置 REDIS_URL 后自动启用 Redis 模式,性能最佳,可大幅降低 MongoDB 的读写压力
# 本地 Redis: redis://127.0.0.1:6379/0
# 带密码: redis://:password@127.0.0.1:6379/0
# 默认: 无 (不启用 Redis 缓存)
REDIS_URL=redis://127.0.0.1:6379/0
# MongoDB 连接字符串 (设置后启用 MongoDB 分布式存储模式)
# 本地 MongoDB: mongodb://localhost:27017
# 带认证: mongodb://admin:password@localhost:27017/admin
# MongoDB Atlas: mongodb+srv://username:password@cluster.mongodb.net
# 副本集: mongodb://host1:27017,host2:27017,host3:27017/gcli2api?replicaSet=rs0
# 默认: 无 (使用本地文件存储)
MONGODB_URI=mongodb://localhost:27017
# MongoDB 数据库名称 (仅在启用 MongoDB 模式时有效)
# 默认: gcli2api
MONGODB_DATABASE=gcli2api
# ================================================================
# Google API 配置
# ================================================================
# 凭证文件目录 (仅在文件存储模式下使用)
# 默认: ./creds
CREDENTIALS_DIR=./creds
# 代理配置 (可选)
# 支持 http, https, socks5 代理
# 格式: http://proxy:port, https://proxy:port, socks5://proxy:port
PROXY=http://localhost:7890
# Google API 代理 URL 配置 (可选)
# Google Code Assist API 端点
# 默认: https://cloudcode-pa.googleapis.com
CODE_ASSIST_ENDPOINT=https://cloudcode-pa.googleapis.com
# 用于Google OAuth2认证的代理URL
# 默认: https://oauth2.googleapis.com
OAUTH_PROXY_URL=https://oauth2.googleapis.com
# 用于Google APIs调用的代理URL
# 默认: https://www.googleapis.com
GOOGLEAPIS_PROXY_URL=https://www.googleapis.com
# 用于Google Cloud Resource Manager API的URL
# 默认: https://cloudresourcemanager.googleapis.com
RESOURCE_MANAGER_API_URL=https://cloudresourcemanager.googleapis.com
# 用于Google Cloud Service Usage API的URL
# 默认: https://serviceusage.googleapis.com
SERVICE_USAGE_API_URL=https://serviceusage.googleapis.com
# 用于Google Antigravity API的URL (反重力模式)
# 默认: https://daily-cloudcode-pa.sandbox.googleapis.com
ANTIGRAVITY_API_URL=https://daily-cloudcode-pa.sandbox.googleapis.com
# ================================================================
# 错误处理和重试配置
# ================================================================
# 是否启用自动封禁功能
# 当凭证返回特定错误码时自动禁用该凭证
# 默认: false
AUTO_BAN=false
# 自动封禁的错误码列表 (逗号分隔)
# 默认: 400,403
AUTO_BAN_ERROR_CODES=403
# 是否启用 429 错误重试
# 默认: true
RETRY_429_ENABLED=true
# 429 错误最大重试次数
# 默认: 5
RETRY_429_MAX_RETRIES=5
# 429 错误重试间隔 (秒)
# 默认: 1
RETRY_429_INTERVAL=1
# ================================================================
# 日志配置
# ================================================================
# 日志级别
# 可选值: debug, info, warning, error, critical
# 默认: info
LOG_LEVEL=info
# 日志文件路径
# 默认: log.txt
LOG_FILE=log.txt
# ================================================================
# 高级功能配置
# ================================================================
# 流式抗截断最大尝试次数
# 用于 "流式抗截断/" 前缀的模型
# 默认: 3
ANTI_TRUNCATION_MAX_ATTEMPTS=3
# ================================================================
# 环境变量使用说明
# ================================================================
# 1. 存储模式配置 (按优先级自动选择):
# - PostgreSQL 分布式模式 (最高优先级): 设置 POSTGRESQL_URI,数据存储在 PostgreSQL 数据库
# - Redis 缓存: 同时设置 REDIS_URI和 MONGODB_URI时,数据缓存在 Redis 数据库,持久化在MONGODB,性能最佳
# - MongoDB 分布式模式: 设置 MONGODB_URI,数据存储在 MongoDB 数据库
# - 文件存储模式 (默认): 不设置上述 URI,数据存储在本地 creds/ 目录
# - 自动切换: 系统根据可用的存储配置自动选择最高优先级的存储后端
# 2. 密码配置优先级:
# a) PASSWORD 环境变量 (最高优先级,设置后覆盖其他密码)
# b) API_PASSWORD / PANEL_PASSWORD 环境变量 (专用密码)
# c) 默认值 "pwd"
#
# 3. 通用配置优先级:
# 环境变量 > 默认值
# 4. 布尔值环境变量:
# true/1/yes/on 表示启用
# false/0/no/off 表示禁用