OpenAI-compatible agent proxy for aistudio.xiaomimimo.com Cookie session Β· streaming Β· real tool calling Β· no upstream API key
π TΓΌrkΓ§e Β· Π ΡΡΡΠΊΠΈΠΉ
MiMo Studio has no public chat API. The proxy drives the same endpoints the website uses, authenticated by the cookies of a logged-in browser session. Run
python login_capture.pyonce, log in, and the cookies are stored incookies.json. When the session expires the API returns401β re-run the capture or updateMIMO_COOKIE.Requests count against your own MiMo account quotas. The proxy does not bypass limits.
Free MiMo API is a local FastAPI server that wraps Xiaomi MiMo Studio and
exposes it as a standard OpenAI REST API β chat completions, streaming,
models, and agent-style tool calling.
Point OpenCode, Cline, Roo Code, Continue, LiteLLM or the OpenAI SDK at
http://127.0.0.1:8787/v1 and use any placeholder API key.
MiMo is a chat product, not an API: it accepts one query string. The proxy
flattens the whole OpenAI transcript (system prompt, tools, assistant tool
calls, tool results) into one structured query, then parses tool calls out of
the answer and returns them in OpenAI format.
| Feature | Detail |
|---|---|
| OpenAI Chat Completions | POST /v1/chat/completions β streaming & non-streaming |
| OpenAI Responses API | POST /v1/responses β shim for newer SDKs |
| Models endpoint | GET /v1/models, GET /v1/models/{id} |
| Tool calling | Tool schemas injected into the prompt; tool_call blocks parsed back |
| Parallel tool calls | Multiple calls from one answer, indexed tool_calls deltas |
| Tool name remapping | Invented names (cat, bash, list_files) mapped to the client's real tools |
| Argument remapping | file β path, cmd β command, and similar aliases |
| Streaming tool calls | Content buffered when tools are present, then prose + tool_calls + finish_reason:"tool_calls" |
| Reasoning separation | Inline <think>...</think> split into reasoning_content |
| Stream de-duplication | Overlapping upstream deltas and snapshot replays are collapsed |
| Thinking-only answers | Promoted to content so clients never receive an empty answer |
| v2 β v3 auto fallback | If /bot/chat says βMiMo Studio updatedβ, the request is retried on /react/chat |
| Conversation lifecycle | One MiMo conversation per request, deleted after the answer |
| Transcript compaction | Long histories trimmed from the middle; recent turns preserved |
| Optional auth | Loopback binds need no key; exposed binds auto-generate one |
| Windows helper | start.bat launches the server |
git clone https://github.com/tealaxdevelopers/free-mimo-api.git
cd free-mimo-api
pip install -r requirements.txt
playwright install chromium
python login_capture.py # log in once; writes cookies.json
cp config.example.json config.json # Windows: copy config.example.json config.json
python server.pyServer:
http://127.0.0.1:8787/v1
Health check:
curl http://127.0.0.1:8787/healthOn Windows you can double-click start.bat after the first login.
python login_capture.pyA Chromium window opens on MiMo Studio. Log in with the Xiaomi account the
proxy should use. The script waits for /open-apis/user/mi/get to answer
code:0, then writes:
cookies.jsonβ full cookie exportcookies.txtβ ready-to-pasteCookie:header
The browser profile is persistent (.mimo_profile/), so later runs usually
skip the login step.
Export cookies for xiaomimimo.com as JSON ([{name,value,...}]), Netscape
cookies.txt, or a plain a=b; c=d header, then point the proxy at it:
set MIMO_COOKIE_FILE=cookies.txtRequired cookies:
| Cookie | Purpose |
|---|---|
xiaomichatbot_serviceToken |
session token |
xiaomichatbot_ph |
gray-release / user tracking (also sent as a query param) |
userId |
account id |
Surrounding quotes are stripped automatically. cookies.json is gitignored
because it contains a live session token.
When the session dies the proxy returns 401 authentication_error with the
Xiaomi login URL in the upstream message. Re-run the capture and restart the
server.
Any OpenAI-compatible client works. The API key can be any non-empty string
unless you configured api_key.
OpenCode
opencode.json:
{
"provider": {
"mimo": {
"npm": "@ai-sdk/openai-compatible",
"name": "Free MiMo",
"options": {
"baseURL": "http://127.0.0.1:8787/v1",
"apiKey": "dummy"
},
"models": {
"mimo-v2.6-flash": { "name": "MiMo V2.6 Flash" },
"mimo-v2.6-pro": { "name": "MiMo V2.6 Pro" },
"mimo-v2.6-pro-ultraspeed-studio": { "name": "MiMo V2.6 UltraSpeed" }
}
}
}
}OpenAI Python SDK
from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8787/v1", api_key="dummy")
response = client.chat.completions.create(
model="mimo-v2.6-flash",
messages=[{"role": "user", "content": "Hello"}],
stream=True,
)
for chunk in response:
print(chunk.choices[0].delta.content or "", end="", flush=True)Cline / Roo Code / Continue
- Provider: OpenAI Compatible
- Base URL:
http://127.0.0.1:8787/v1 - API key:
dummy - Model:
mimo-v2.6-flashormimo-v2.6-pro
LiteLLM
model_list:
- model_name: mimo
litellm_params:
model: openai/mimo-v2.6-flash
api_base: http://127.0.0.1:8787/v1
api_key: dummycurl β non-stream
curl http://127.0.0.1:8787/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"mimo-v2.6-flash","messages":[{"role":"user","content":"Hello"}]}'curl β stream + tools
curl -N http://127.0.0.1:8787/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "mimo-v2.6-pro",
"stream": true,
"messages": [{"role": "user", "content": "Read main.py"}],
"tools": [{
"type": "function",
"function": {
"name": "read_file",
"description": "Read a file",
"parameters": {
"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"]
}
}
}]
}'Expected tail:
data: {"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_...","type":"function","function":{"name":"read_file","arguments":"{\"path\": \"main.py\"}"}}]},"finish_reason":null}]}
data: {"choices":[{"delta":{},"finish_reason":"tool_calls"}]}
data: [DONE]
| Method | Path | Description |
|---|---|---|
GET |
/health |
health, cookie presence, model list hint |
GET |
/v1/models |
supported model ids |
GET |
/v1/models/{id} |
single model |
POST |
/v1/chat/completions |
OpenAI chat, stream & tools |
POST |
/v1/responses |
Responses API shim |
Copy config.example.json to config.json and edit. Every key also has an
environment override.
| Key | Env | Default | Description |
|---|---|---|---|
host |
HOST |
127.0.0.1 |
bind address |
port |
PORT |
8787 |
bind port |
api_key |
API_KEY |
null |
client bearer token; auto-generated on exposed binds |
cookie |
MIMO_COOKIE |
β | raw Cookie: header |
cookie_file |
MIMO_COOKIE_FILE |
cookies.json |
JSON / Netscape / raw cookie file |
default_model |
MIMO_MODEL |
mimo-v2.6-flash |
upstream model |
enable_thinking |
MIMO_ENABLE_THINKING |
true |
request MiMo thinking |
web_search_status |
MIMO_WEB_SEARCH |
0 |
0 off, 1 auto, 2 forced |
react_mode |
MIMO_REACT_MODE |
false |
force /react/chat (v3) instead of /bot/chat |
max_query_chars |
MIMO_MAX_QUERY_CHARS |
96000 |
flattened prompt cap |
max_tool_result_chars |
MIMO_MAX_TOOL_RESULT_CHARS |
24000 |
per tool-output cap |
tool_reminder |
MIMO_TOOL_REMINDER |
true |
append an agent reminder to the last turn |
cleanup_conversations |
MIMO_CLEANUP_CONVERSATIONS |
true |
delete the MiMo conversation after the answer |
auto_continue |
MIMO_AUTO_CONTINUE |
false |
continue truncated answers |
max_continuations |
MIMO_MAX_CONTINUATIONS |
2 |
continuation rounds |
include_reasoning_nonstream |
MIMO_INCLUDE_REASONING |
true |
add reasoning_content to non-stream replies |
emit_reasoning_stream |
MIMO_EMIT_REASONING_STREAM |
false |
stream reasoning_content deltas |
request_timeout |
MIMO_REQUEST_TIMEOUT |
300 |
upstream timeout, seconds |
max_retries |
MIMO_MAX_RETRIES |
2 |
retries on transport / 429 / 5xx |
proxy |
MIMO_PROXY |
null |
HTTP proxy for upstream |
{
"model": "mimo-v2.6-pro",
"reasoning_effort": "none",
"mimo": {
"enable_thinking": false,
"web_search": 1
}
}reasoning_effort: "none" | "off" | "minimal"asks MiMo to skip thinking.mimo.enable_thinking,mimo.web_searchoverride the config for one request.tool_choice: "none"removes tools; a named function filters the tool list.max_tokensis forwarded asmaxTokens(MiMo may ignore it).
mimo-v2.6-flash, mimo-v2.6-pro, mimo-v2.6-pro-ultraspeed-studio,
mimo-v2-flash, mimo-v2-flash-studio, mimo-v2-pro, mimo-v2-omni,
mimo-v2.5-pro, mimo-v2.5, mimo-v2.1-pro, mimo-v2.1-omni.
Aliases such as mimo, mimo-latest, mimo-v2.6 and xiaomi/mimo-v2.6-pro
are resolved automatically. Unknown names fall back to default_model.
- The client sends OpenAI
tools. tool_service.format_tools_system_prompt()renders the schemas plus the requiredtool_callJSON format into a system block.content_handler.process_messages_for_mimo()flattens the transcript: system messages, user turns, assistant tool calls, andtooloutputs with their call ids and arguments.- MiMo answers as normal text.
parse_all_tool_calls()scans the answer for:- fenced JSON:
```json {"tool_call":{"name":...,"arguments":{...}}} ``` - legacy:
TOOL_CALL: namefollowed by JSON - XML:
<invoke name="..."><parameter name="...">...</parameter></invoke> <tool_use><name>...</name>...</tool_use>- bare
{"name":...,"arguments":...}envelopes
- fenced JSON:
- Invented tool names are matched against intent groups (
read,write,edit,list,shell,search) and rewritten to the real client tool. Argument keys are remapped to the target schema. - Streaming: when tools are present the answer is buffered, then emitted as a
prose delta (if any), one
tool_callsdelta with every call indexed, and a final chunk withfinish_reason:"tool_calls".
If the model puts the tool call inside <think>, the proxy also parses the
reasoning buffer. If the whole answer is thinking-only, it is promoted to
content.
Client (OpenCode / Cline / SDK)
β OpenAI request
βΌ
βββββββββββββββββββββββββββββββββββββββ
β FastAPI facade β server.py
β β
β content_handler β one query β
β tool_service β prompt + parser β
β mimo_client β auth, SSE, thinkβ
β config β cookie + flags β
βββββββββββββββββββββββββββββββββββββββ
β POST /open-apis/bot/chat (v2)
β retry /open-apis/react/chat (v3)
βΌ
aistudio.xiaomimimo.com
Reverse-engineered from the MiMo Studio bundle:
| Step | Endpoint | Notes |
|---|---|---|
| Session check | GET /open-apis/user/mi/get |
code:0 = logged in |
| Create conversation | POST /open-apis/chat/conversation/save |
{conversationId,title,type:"chat"} |
| Chat v2 | POST /open-apis/bot/chat?xiaomichatbot_ph=... |
default |
| Chat v3 / react | POST /open-apis/react/chat |
reasoning/tool event layout |
| Delete conversation | POST /open-apis/chat/conversation/delete |
body is [conversationId] |
conversationIdandmsgIdaremd5(uuid + ms + random32)β 32-char hex.- The chat endpoint is not signed. The site signs only
/open-apis/user/feedbackwithX-Sign/X-Timestamp/X-Key-Epoch. - Every POST carries
?xiaomichatbot_ph=<cookie value>, matching site behavior. - SSE events:
dialogId,message,usage,finish,error,sensitive_query,sensitive_title,tip_ratio,tip_truncate,quota_alert,web_search,doc. - If v2 answers with the βMiMo Studio updated / refresh your pageβ marker, the site retries on v3. The proxy does the same automatically.
usageis upstream-reported; short prompts still show ~3.8k prompt tokens because MiMo counts its own system context.
python -m pytest -q
# 26 passedLive checks (require cookies.json):
python live_check.py "reply in one sentence"
python live_server_check.pylive_server_check.py exercises the OpenAI facade end to end: non-stream
content, streamed text, streamed tool calls and usage. Verified against a real
session:
- non-stream
2+2β"4" - stream
count to 3β1 2 3 - stream tool prompt β
read_filewith{"path":"main.py"} - responses shim β
output_text:"4" - tool result follow-up β correct answer from the tool output
Do I need a Xiaomi account? Yes. A logged-in MiMo Studio session is the entire authentication story. There is no public API key to obtain.
Cookie expired β what now?
Re-run python login_capture.py, or export fresh cookies and set
MIMO_COOKIE / MIMO_COOKIE_FILE. Restart the server so the new cookie is
loaded.
Which model should I use?
mimo-v2.6-flash is the fast default. mimo-v2.6-pro is stronger.
mimo-v2.6-pro-ultraspeed-studio is the speed variant.
Why is content empty?
It should not be: thinking-only answers are promoted to content. If you still
see empty content, the request was filtered upstream (sensitive_query) or the
model returned only a tool call, in which case tool_calls is populated.
Tool calls are not firing.
Check that the client actually sends tools, that tool_choice is not
"none", and that the tool description is clear. The parser supports JSON,
legacy TOOL_CALL:, XML invoke, and tool_use shapes; ambiguous JSON in
normal prose is deliberately ignored.
The server returns 429.
MiMo quota or rate limit reached for the account. Wait for the reset or use a
different session. quota_alert is mapped to 429.
The server returns 403.
The account is restricted (451/461 upstream). This is an account-level
state, not a proxy bug.
Does it support images or file attachments? Not yet. Text and tool output are fully supported; attachments are noted in the prompt as omitted. MiMo supports media upload, but the proxy does not upload client files.
Can I expose it to the internet?
Set api_key. On a non-loopback bind an empty key is auto-generated and saved
to .api_key; clients must send Authorization: Bearer <key>.
Why one conversation per request?
It makes the proxy stateless and keeps client transcripts authoritative. The
conversation is deleted after the answer (cleanup_conversations).
- Images, audio and files are not uploaded; only text is forwarded.
- Each request creates and deletes a MiMo conversation.
- Very long transcripts are compacted from the middle at
max_query_chars. react_modeis experimental; v2 auto-falls back to v3 when MiMo asks for it.- Site changes can rename endpoints or events;
mimo_client.pyis the single place to patch. - Responses count against the MiMo accountβs own quotas.
- Default bind is
127.0.0.1. - Exposed bind without
api_keygenerates a random key and prints it; it is also stored in.api_key. cookies.json/cookies.txtcontain a live session token and are gitignored. Do not commit or share them.- CORS is open for local tooling; the API key is the access boundary when the server is exposed.
MIT Β© 2026 Tealax