Download .env.example from zlcy/study: direct link, hf CLI and curl.
- Browser
- Download file 3.64 kB
-
https://huggingface.co/spaces/zlcy/study/resolve/main/.env.example
- Command line
-
hf download hf://spaces/zlcy/study/.env.example
-
curl -L -o .env.example https://huggingface.co/spaces/zlcy/study/resolve/main/.env.example
3.64 kB
| ============================================ | |
| ChatGPT2API 环境变量配置示例 | |
| ============================================ | |
| 认证密钥(必填) | |
| CHATGPT2API_AUTH_KEY=your_secret_key_here | |
| 基础 URL(可选,用于生成图片 URL) | |
| CHATGPT2API_BASE_URL=https://your-domain.com | |
| 持久化目录(可选) | |
| 推荐把 Hugging Face Storage Bucket 挂载到 /app/persist;默认会自动使用这个目录。 | |
| 如果你想换挂载路径,只需要改下面这个变量即可。 | |
| 不要把 Bucket 挂载到 /app/data,否则容易影响账号、卡密和运行缓存。 | |
| CHATGPT2API_PERSIST_DIR=/app/persist | |
| 日志文件安全限制:当前 logs.jsonl 超过该大小后会自动轮转。 | |
| Hugging Face Spaces 建议保持较小;设为 0 可关闭自动轮转。 | |
| CHATGPT2API_LOG_MAX_BYTES=209715200 | |
| 逐条删除日志需要重写当前日志文件,超过该大小会拒绝执行,避免线上 OOM。 | |
| CHATGPT2API_LOG_DELETE_REWRITE_MAX_BYTES=209715200 | |
| 日志页从文件尾部读取时的块大小。 | |
| CHATGPT2API_LOG_READ_CHUNK_BYTES=1048576 | |
| ============================================ | |
| 存储后端配置 | |
| ============================================ | |
| 存储后端类型(可选值: json, sqlite, postgres, git) | |
| 推荐 Hugging Face Storage Bucket 挂载到 /app/persist 后使用 sqlite。 | |
| 如果没有设置 STORAGE_BACKEND 且 /app/persist 存在,程序会自动使用 SQLite: | |
| accounts.db 只保存号池账号,users.db 保存用户、卡密、签到和额度流水。 | |
| 旧版单库会在首次启动时自动备份并拆分,无需手动迁移。 | |
| STORAGE_BACKEND=sqlite | |
| 默认开启本地 SQLite 双库隔离。只有需要回退旧版单库结构时才设置为 false。 | |
| CHATGPT2API_SPLIT_LOCAL_DATABASES=true | |
| ============================================ | |
| 数据库配置(当 STORAGE_BACKEND=sqlite/postgres 时使用) | |
| ============================================ | |
| PostgreSQL 示例 | |
| DATABASE_URL=postgresql://user:password@localhost:5432/chatgpt2api | |
| Supabase 示例 | |
| DATABASE_URL=postgresql://postgres.xxx:password@aws-1-us-west-1.pooler.supabase.com:5432/postgres | |
| SQLite 示例(不指定时自动使用持久化目录 accounts.db,并配套使用 users.db) | |
| DATABASE_URL=sqlite:////app/persist/accounts.db | |
| ============================================ | |
| Git 仓库配置(当 STORAGE_BACKEND=git 时使用) | |
| ============================================ | |
| Git 仓库地址(必填) | |
| GIT_REPO_URL=https://github.com/your-username/your-private-repo.git | |
| Git 访问令牌(必填) | |
| GitHub: ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
| GitLab: glpat-xxxxxxxxxxxxxxxxxxxx | |
| GIT_TOKEN=your_git_token_here | |
| Git 分支(可选,默认: main) | |
| GIT_BRANCH=main | |
| Git 仓库中的文件路径(可选,默认: accounts.json) | |
| GIT_FILE_PATH=accounts.json | |
| Git 本地缓存目录(可选,默认使用系统临时目录) | |
| 如果你使用 Hugging Face Storage Bucket,不要把该目录放到 Bucket 挂载路径下。 | |
| GIT_CACHE_DIR=/tmp/chatgpt2api_git_cache | |
| ============================================ | |
| Shared user/card database (optional) | |
| ============================================ | |
| Use this when multiple Spaces should share users, WeChat bindings, credits, | |
| redeem codes, and redemption history. Do NOT put this value in DATABASE_URL; | |
| DATABASE_URL still belongs to each Space's own account pool/storage. | |
| Recommended: Supabase Transaction pooler, usually port 6543. | |
| SHARED_USER_DATABASE_URL=postgresql://postgres.xxx:password@aws-1-ap-southeast-1.pooler.supabase.com:6543/postgres | |