whatisgithub

What is baiduchat2api?

xxxxteam/baiduchat2api — explained in plain English

Analysis updated 2026-05-18

35PythonAudience · developerComplexity · 4/5Setup · moderate

In one sentence

A local server that reverse-engineers Baidu's chat AI and exposes it through the same API format as OpenAI.

Mindmap

mindmap
  root((baiduchat2api))
    What it does
      Wraps Baidu chat as an API
      Mimics OpenAI format
      Reverse-engineered auth
    Tech stack
      Python
      Cookie based auth
      Token generation logic
    Use cases
      OpenAI-compatible proxy
      Multi-cookie failover
      Reverse engineering study
    Audience
      Developers
      Researchers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Point an existing OpenAI-compatible chat app at Baidu's AI models without changing its code.

USE CASE 2

Rotate across multiple Baidu account cookies to keep a chat proxy running when one session expires.

USE CASE 3

Study how a browser-based AI chat service's request signing can be reverse-engineered.

What is it built with?

Python

How does it compare?

xxxxteam/baiduchat2apibytedance-seed/cola-dlmchris0214/mikumikuphysics
Stars353535
LanguagePythonPythonPython
Setup difficultymoderatehardmoderate
Complexity4/54/53/5
Audiencedeveloperresearcherdesigner

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires manually copying browser cookies from a logged-in Baidu session into a config file, for educational use only per the README.

So what is it?

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.

Copy-paste prompts

Prompt 1
Explain how baiduchat2api translates Baidu's chat API into the OpenAI format.
Prompt 2
Help me set up baiduchat2api with multiple Baidu account cookies for failover.
Prompt 3
Walk me through the token generation algorithm this project extracted from Baidu's site.
Prompt 4
Show me how to stream responses from baiduchat2api into an OpenAI-compatible client.

Frequently asked questions

What is baiduchat2api?

A local server that reverse-engineers Baidu's chat AI and exposes it through the same API format as OpenAI.

What language is baiduchat2api written in?

Mainly Python. The stack also includes Python.

How hard is baiduchat2api to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is baiduchat2api for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.