agentleFS
28672032962867203296/hermes-agent/skills/mcp/free-api-gateway/SKILL.md

free-api-gateway

Skill0 starsChanged 3 months agoMITView on GitHub

国产大模型网页端转 OpenAI API:即梦/DeepSeek/Kimi/豆包/通义千问/智谱/阶跃星辰。用浏览器 cookie 转 OpenAI 兼容接口,零成本接入任何智能体。

  • Pipes a download into a shell

The file

Files
SKILL.md

国产大模型 Free API 网关

概述

通过浏览器 cookie 将国产大模型网页端转成 OpenAI 兼容 API,零成本接入 Hermes 或任何智能体。

核心脚本

  • D:/Hermes/scripts/free_api_router.py — 统一网关 (OpenAI 兼容 HTTP 服务)
  • D:/Hermes/scripts/jimeng_api.py — 即梦独立脚本 (图片+视频生成)
  • D:/Hermes/scripts/jimeng_reverse_api.py — 即梦初版 (已废弃)

各服务状态

✅ 即梦 — 完全可用

  • 图生文: 4.5/3.0 等模型,支持 1k/2k 分辨率
  • 视频: Seedance 2.0 Pro/Fast/Mini
  • 认证: sessionid cookie
  • 端点: POST /mweb/v1/aigc_draft/generate
  • 积分: 每日 66 免费积分 (需在网页领取)
  • CLI: 官方 dreamina CLI (D:/Hermes/dreamina.exe) 但仅 VIP 可用

❌ DeepSeek — 认证已升级 (2026-07-04 实测)

  • 端点: POST https://chat.deepseek.com/api/v0/chat/completions(未变)
  • 认证已从 Cookie 迁移到 localStorage:DevTools 仅剩 aws-waf-token,旧 HWWAF 链全失效
  • 任何 cookie 组合调用 API 均返回 SPA HTML 而非 JSON
  • 纯 cookie 方案已不可用,需提取 localStorage token(详见 references/deepseek-web-api.md)
  • 网关 free_api_router.py 中 deepseek_chat() 待更新

⚠️ Kimi — 端点已验证 (2026-07-04)

  • 创建会话: POST https://www.kimi.com/api/chat → body: {"enter_method":"new_chat","kimiplus_id":"kimi","name":"..."}
  • 发送消息: POST /api/chat/{conv_id}/completion/stream → SSE 流, 提取 data: 行中 text 字段
  • 完成后需 DELETE /api/chat/{conv_id} 清理
  • 认证: kimi-auth JWT cookie(注意 cookie 名已从 refreshToken 变为 kimi-auth)
  • 单独 kimi-auth 不够 (401),需完整浏览器 cookie 串
  • 网关实现: free_api_router.py 中 kimi_chat() 函数

⚠️ 豆包 — 反爬复杂

  • 端点: POST /chat/completion (新版)
  • 需要: msToken + a_bogus (浏览器 JS 动态生成)
  • 旧版端点已废弃: /samantha/chat/completion

📋 待适配

  • 通义千问 (qwen) / 智谱 (glm) / 阶跃星辰 (step): 待抓包

使用方法

前置: 配置代理 (国内墙 GitHub 必做)

Clash Verge / 魔戒等代理运行后,curl 走代理需要显式 -x:

# 测试代理 (默认混合端口 7897)
curl -x http://127.0.0.1:7897 https://github.com -o /dev/null -w "%{http_code}"
# 返回 200 即通

# 所有外网请求加 -x
curl -x http://127.0.0.1:7897 ...

Python 脚本内设置:

import os
os.environ['https_proxy'] = 'http://127.0.0.1:7897'
os.environ['http_proxy'] = 'http://127.0.0.1:7897'

启动网关

# 1. 设置环境变量
set DEEPSEEK_COOKIE=HWWAFSESTIME=...;ds_session_id=...
set KIMI_COOKIE=kimi-auth=...
set JIMENG_SESSIONID=...

# 2. 启动网关
python D:/Hermes/scripts/free_api_router.py --port 8800

# 3. 任何 OpenAI 客户端用 http://localhost:8800/v1

原理

  1. 浏览器登录目标网站
  2. F12 Application Cookies 获取认证 cookie
  3. 用 Python 模拟网页端 HTTP 请求
  4. 返回格式转为 OpenAI 兼容

相关

  • jimeng_api.py — 即梦独立脚本
  • free_api_router.py — 统一网关
  • LLM-Red-Team 原项目 (已全部被 DMCA 下架)
  • Bitsea1/doubao-free-api (187⭐) — 豆包 fork
  • zhizinan1997/jimeng-free-api-all (413⭐) — 即梦 fork (含 Seedance)

避坑

  • Node.js axios 与 Python urllib 请求行为不同
  • 大厂服务端可能校验 Content-Type charset
  • WAF 频繁测试会封 IP (429 错误)
  • 豆包/DeepSeek 需要完整 cookie 链 (不只认证 token)
  • 即梦 dreamina CLI (v1.4.10, 2026-06-26) 仅 VIP 可用,普通账号提示"无使用权限"
  • 即梦官方 CLI 安装: curl -s https://jimeng.jianying.com/cli | bash,但有会员限制
  • 浏览器 cookie 提取方案详见: references/browser-cookie-extraction.md
  • 不要在不同服务之间反复切换:用户反感"这个不行换那个",一个方案坚持到底,确认真的不行再换
  • 魔戒/Clash Verge 代理:混合端口 7897,Clash Verge v2.5.1 安装包在 D:/sofeware/cache/Clash.Verge_2.5.1_x64-setup.exe

技术细节

即梦 API 签名机制

  • Sign = MD5(9e2c|{uri后7位}|{platform}|{version}|{timestamp}||11ac)
  • 必须携带 query params: aid, device_platform, region, webId
  • 必带头: Device-Time, Sign, Sign-Ver:1, Appid, Appvr, Pf
  • Cookie 格式: sessionid + sid_guard + uid_tt 等完整链

DeepSeek WAF

  • 频繁测试会触发 429 + HTML block 页面
  • 需等待 5-10 分钟自动解封
  • 头信息需包含: x-app-version, x-client-locale, x-client-platform
  • API 需有效认证 token(现为 localStorage token,cookie 已失效),否则返回网页 HTML

豆包新版 API (2026-07)

  • 端点已从 /samantha/chat/completion 迁移到 /chat/completion
  • 消息格式从数组改为 content_block 结构
  • 需要 msToken + a_bogus,由浏览器 JS 实时生成,无法纯 Python 模拟

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.