xxxxteam/baiduchat2api — explained in plain English
Analysis updated 2026-05-18
Point an existing OpenAI-compatible chat app at Baidu's AI models without changing its code.
Rotate across multiple Baidu account cookies to keep a chat proxy running when one session expires.
Study how a browser-based AI chat service's request signing can be reverse-engineered.
| xxxxteam/baiduchat2api | bytedance-seed/cola-dlm | chris0214/mikumikuphysics | |
|---|---|---|---|
| Stars | 35 | 35 | 35 |
| Language | Python | Python | Python |
| Setup difficulty | moderate | hard | moderate |
| Complexity | 4/5 | 4/5 | 3/5 |
| Audience | developer | researcher | designer |
Figures from each repo's GitHub metadata at analysis time.
Requires manually copying browser cookies from a logged-in Baidu session into a config file, for educational use only per the README.
This project reverse-engineers Baidu's chat service at chat.baidu.com and wraps it in a local server that speaks the same API format as OpenAI. If you have tools or applications that already know how to talk to OpenAI's chat API, they can be pointed at this local server instead and will reach Baidu's AI without any code changes on your end. The setup requires copying your browser cookies from a logged-in Baidu session and pasting them into a config file. The server uses those cookies to authenticate each request, generates the security token that Baidu's API expects, and translates the response back into the OpenAI format before returning it to your client. You can supply multiple cookie sets and the server will spread requests across them, automatically switching to a backup if one session expires or fails. Three Baidu model options are available: a general smart mode, a DeepSeek integration with extended reasoning, and a DeepSeek V4 Pro variant. The server supports streaming responses, tool calls (where the AI can decide to call a function you define), and thinking output where the model's reasoning steps are returned alongside the final answer. The README, which is written in Chinese, documents the reverse-engineering process in four stages: observing network traffic, analyzing the compiled JavaScript files that ship with the Baidu site, hooking the browser's fetch function to capture live requests, and extracting the token generation algorithm from minified code. That algorithm combines a session token, an MD5 hash of the query, a timestamp, and a session ID, then encodes the result in base64. The disclaimer at the end states the project is for educational purposes only and should not be used commercially or in ways that violate Baidu's terms of service. Because Baidu can update its interface at any time, the token algorithm may need re-verification after site changes.
A local server that reverse-engineers Baidu's chat AI and exposes it through the same API format as OpenAI.
Mainly Python. The stack also includes Python.
Setup difficulty is rated moderate, with roughly 30min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Verify against the repo before relying on details.