[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-80117":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":8,"htmlUrl":8,"language":9,"languages":8,"totalLinesOfCode":8,"stars":10,"forks":11,"watchers":12,"openIssues":13,"contributorsCount":13,"subscribersCount":13,"size":13,"stars1d":13,"stars7d":14,"stars30d":15,"stars90d":13,"forks30d":13,"starsTrendScore":16,"compositeScore":17,"rankGlobal":8,"rankLanguage":8,"license":18,"archived":19,"fork":19,"defaultBranch":20,"hasWiki":19,"hasPages":19,"topics":21,"createdAt":8,"pushedAt":8,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":13,"starSnapshotCount":13,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},80117,"freebuff2api","XxxXTeam\u002Ffreebuff2api","XxxXTeam",null,"Python",71,17,1,0,7,15,4,3.77,"GNU Affero General Public License v3.0",false,"main",[],"2026-06-12 02:03:58","# freebuff2api\n\nCodebuff Freebuff 的 OpenAI-compatible API\n\n\u003Cimg width=\"480\" height=\"1032\" alt=\"image\" src=\"https:\u002F\u002Fgithub.com\u002Fuser-attachments\u002Fassets\u002F8a12f1ef-42ea-41eb-b47b-40d86550bbc9\" \u002F>\n\n\n## 接口\n\n- `GET \u002Fv1\u002Fmodels`\n- `POST \u002Fv1\u002Fchat\u002Fcompletions`\n- `GET \u002Fhealthz`\n\n## 配置\n\n### 获取 Token\n\n无需安装 Freebuff \u002F Codebuff CLI，可以直接打开公开页面自动获取 token：\n\n```text\nhttps:\u002F\u002Ffreebuff.071129.xyz\u002F\n```\n\n使用方式：\n\n1. 打开上面的地址\n2. 选择 Freebuff\n3. 点击“开始认证”，在跳转页面完成授权\n4. 回到页面复制展示的 token\n5. 将复制结果写入本项目 `.env`\n\n示例：\n\n```dotenv\nFREEBUFF_TOKEN=你的 Freebuff Bearer token\n```\n\n多账号可用英文逗号分隔；并发请求会优先分配到空闲账号，避免单个\nFreebuff 账号的全局 active free session 被并发切模型请求互相覆盖：\n\n```dotenv\nFREEBUFF_TOKEN=token-a,token-b,token-c\n```\n\n复制 `.env.example` 为 `.env`，然后填写上游 token：\n\n```powershell\nCopy-Item .env.example .env\n```\n\n`.env` 示例：\n\n```dotenv\nFREEBUFF_TOKEN=你的 Freebuff Bearer token\nFREEBUFF_API_KEY=本地 OpenAI API key，可留空\nFREEBUFF_AD_PROVIDERS=gravity,zeroclick\nFREEBUFF_PROXY_ENABLED=false\nFREEBUFF_PROXY_URL=\nFREEBUFF_DEBUG=false\nFREEBUFF_LOG_LEVEL=INFO\nFREEBUFF_LOG_BODY_CHARS=2000\nFREEBUFF_LOG_COLOR=true\nFREEBUFF_HOST=0.0.0.0\nFREEBUFF_PORT=8000\n```\n\n默认不启用代理，所有上游请求直连，且不会读取系统 `HTTP_PROXY` \u002F `HTTPS_PROXY`。\n\n需要让所有上游请求经过代理时，在 `.env` 中开启：\n\n```dotenv\nFREEBUFF_PROXY_ENABLED=true\nFREEBUFF_PROXY_URL=http:\u002F\u002F127.0.0.1:7890\n```\n\n支持 HTTP 和 SOCKS 代理，例如：\n\n```dotenv\nFREEBUFF_PROXY_URL=http:\u002F\u002F127.0.0.1:7890\nFREEBUFF_PROXY_URL=socks5:\u002F\u002F127.0.0.1:1080\nFREEBUFF_PROXY_URL=socks5h:\u002F\u002F127.0.0.1:1080\n```\n\n当前内置 Freebuff 模型：\n\n- `deepseek\u002Fdeepseek-v4-flash`\n- `deepseek\u002Fdeepseek-v4-pro`\n- `moonshotai\u002Fkimi-k2.6`\n- `minimax\u002Fminimax-m2.7`\n\n当前内置 Gemini free agent 组合：\n\n- `google\u002Fgemini-2.5-flash-lite` -> `base2-free-deepseek-flash` 父 agent + `file-picker` 子 agent\n- `google\u002Fgemini-3.1-flash-lite-preview` -> `base2-free-deepseek-flash` 父 agent + `file-picker-max` 子 agent\n- `google\u002Fgemini-3.1-pro-preview` -> `base2-free-kimi` 父 agent + `thinker-with-files-gemini` 子 agent\n\n调用 Gemini 时无需手动传 agent。项目会把 OpenAI 请求中的 `model`\n解析为上游允许的 `agentId + model` 组合，并继续在\n`codebuff_metadata.cost_mode=free` 下请求。Gemini free agents 会自动作为\nactive Freebuff session root 的子 agent 运行；未知模型不会自动兜底到 Gemini。\n\n调试空返回或上游异常时：\n\n```dotenv\nFREEBUFF_DEBUG=true\nFREEBUFF_LOG_LEVEL=DEBUG\nFREEBUFF_LOG_BODY_CHARS=0\n```\n\n## 运行\n\n```powershell\nuv sync\nuv run freebuff2api\n```\n\n或：\n\n```powershell\npython -m pip install -e .\npython main.py\n```\n\n## 调用示例\n\n```powershell\ncurl http:\u002F\u002F127.0.0.1:8000\u002Fv1\u002Fchat\u002Fcompletions `\n  -H \"Authorization: Bearer $env:FREEBUFF_API_KEY\" `\n  -H \"Content-Type: application\u002Fjson\" `\n  -d '{\n    \"model\": \"deepseek\u002Fdeepseek-v4-flash\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"你好\"}],\n    \"stream\": false\n  }'\n```\n\n流式：\n\n```powershell\ncurl -N http:\u002F\u002F127.0.0.1:8000\u002Fv1\u002Fchat\u002Fcompletions `\n  -H \"Authorization: Bearer $env:FREEBUFF_API_KEY\" `\n  -H \"Content-Type: application\u002Fjson\" `\n  -d '{\n    \"model\": \"deepseek\u002Fdeepseek-v4-flash\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"写一个 Python 快排\"}],\n    \"stream\": true\n  }'\n```\n\n## 感谢\n\n> [FreeBuff](https:\u002F\u002Ffreebuff.com)\n","freebuff2api 是一个与 OpenAI 兼容的 API 项目，用于通过 Codebuff Freebuff 平台调用多种 AI 模型。该项目使用 Python 编写，支持获取模型列表、聊天补全等核心功能，并提供了健康检查接口。用户可以通过简单的配置步骤获取并设置访问令牌，以启用对多个内置模型的支持，如 deepseek 和 Gemini 系列。此外，它还支持多账号管理和代理设置，确保了高并发场景下的稳定性和灵活性。适用于需要集成先进自然语言处理能力的应用开发，特别是那些希望利用 Freebuff 提供的强大 AI 模型进行文本生成或对话系统的开发者。",2,"2026-06-11 03:59:19","CREATED_QUERY"]