{"id":27948245,"url":"https://github.com/chenwr727/yuanbao-free-api","last_synced_at":"2025-05-07T14:57:08.375Z","repository":{"id":286553147,"uuid":"959029557","full_name":"chenwr727/yuanbao-free-api","owner":"chenwr727","description":"YuanBao-Free-API 是一个允许您通过 OpenAI 兼容接口访问腾讯元宝的服务。","archived":false,"fork":false,"pushed_at":"2025-04-23T01:53:29.000Z","size":170,"stargazers_count":29,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T14:57:02.052Z","etag":null,"topics":["deepseek","free-api","hunyuan","web-search","wechat","wechat-official-account","yuanbao"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chenwr727.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-02T06:43:30.000Z","updated_at":"2025-05-07T02:51:18.000Z","dependencies_parsed_at":"2025-04-07T12:00:38.378Z","dependency_job_id":null,"html_url":"https://github.com/chenwr727/yuanbao-free-api","commit_stats":null,"previous_names":["chenwr727/yuanbao-free-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenwr727%2Fyuanbao-free-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenwr727%2Fyuanbao-free-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenwr727%2Fyuanbao-free-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenwr727%2Fyuanbao-free-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenwr727","download_url":"https://codeload.github.com/chenwr727/yuanbao-free-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252902638,"owners_count":21822257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deepseek","free-api","hunyuan","web-search","wechat","wechat-official-account","yuanbao"],"created_at":"2025-05-07T14:57:07.792Z","updated_at":"2025-05-07T14:57:08.347Z","avatar_url":"https://github.com/chenwr727.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YuanBao-Free-API ✨\n\n一个允许您通过 OpenAI 兼容接口访问腾讯元宝的服务。\n\n## ✨ 核心特性\n\n✅ **完整兼容 OpenAI API 规范**  \n🚀 **支持主流元宝大模型**（DeepSeek/HunYuan系列）  \n⚡️ **流式输出 \u0026 网络搜索功能**  \n📦 **开箱即用的部署方案**（本地/Docker）  \n\n## ⚠️ 使用须知\n\n- 本项目仅限**学习研究用途**\n- 请严格遵守腾讯元宝的[使用条款](https://yuanbao.tencent.com/)\n- `hy_token` 有时效性，过期需重新获取\n\n## 🚀 快速开始\n\n### 环境准备\n```bash\ngit clone https://github.com/chenwr727/yuanbao-free-api.git\ncd yuanbao-free-api\npip install -r requirements.txt\n```\n\n## 🖥️ 服务端部署\n\n### 本地运行\n```bash\n# 服务地址：http://localhost:8000\npython app.py\n```\n\n### Docker部署\n```bash\n# 构建镜像\ndocker build -t yuanbao-free-api .\n\n# 运行容器\ndocker run -d -p 8000:8000 --name yuanbao-api yuanbao-free-api\n```\n\n## 📡 客户端调用\n\n### 认证参数获取\n#### 手动获取\n![Token获取方法](example.png)\n1. 访问[腾讯元宝](https://yuanbao.tencent.com/)\n2. 打开开发者工具（F12）\n3. 捕获对话请求获取：\n   - Cookie中的 `hy_user` 和 `hy_token`\n   - 请求体中的 `agent_id`\n\n#### 自动获取\n```bash\n# 扫码登录后自动输出认证参数\npython get_cookies.py\n```\n\n### API调用示例\n```python\nfrom openai import OpenAI\n\nclient = OpenAI(\n    base_url=\"http://localhost:8000/v1/\", # 替换为服务端地址\n    api_key=\"your_hy_token\",  # 替换为 hy_token \n)\n\nresponse = client.chat.completions.create(\n    model=\"deepseek-r1-search\",  # 支持的模型见 const.py\n    messages=[{\"role\": \"user\", \"content\": \"你是谁\"}],\n    stream=True,\n    extra_body={\n        \"hy_source\": \"web\",\n        \"hy_user\": \"your_hy_user\",  # 替换为 hy_user\n        \"agent_id\": \"your_agent_id\",  # 替换为 agent_id\n        \"chat_id\": \"your_chat_id\",  # 可选，如果不提供会自动创建\n        \"should_remove_conversation\": False,  # 是否在对话结束后删除会话\n    },\n)\n\nfor chunk in response:\n    print(chunk.choices[0].delta.content or \"\")\n```\n\n## 🧠 支持模型\n\n| 模型名称              | 特性说明                    |\n|----------------------|-----------------------------|\n| deepseek-v3          | 深度求索 V3 基础模型         |\n| deepseek-r1          | 深度求索 R1 增强模型         |\n| deepseek-v3-search   | 深度求索 V3 模型（带搜索功能）|\n| deepseek-r1-search   | 深度求索 R1 模型（带搜索功能）|\n| hunyuan              | 腾讯混元基础模型             |\n| hunyuan-t1           | 腾讯混元 T1 模型             |\n| hunyuan-search       | 腾讯混元模型（带搜索功能）    |\n| hunyuan-t1-search    | 腾讯混元 T1 模型（带搜索功能）|\n\n## 🌟 应用案例\n\n[FinVizAI](https://github.com/chenwr727/FinVizAI) 实现多步骤金融分析工作流：\n- 实时资讯搜索分析\n- 市场趋势数据集成\n- 结构化报告生成\n\n## 📜 开源协议\n\nMIT License © 2025\n\n## 🤝 参与贡献\n\n欢迎通过以下方式参与项目：\n1. 提交Issue报告问题\n2. 创建Pull Request贡献代码\n3. 分享你的集成案例","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenwr727%2Fyuanbao-free-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenwr727%2Fyuanbao-free-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenwr727%2Fyuanbao-free-api/lists"}