OpenAI-compatible local API proxy for Kimi Web (kimi.ai & kimi.moonshot.cn).
Allows you to use Kimi (Kimi Chat with native thinking/reasoning and search toggles) with OpenCode or any OpenAI-compatible client.
This project is for educational and research purposes only. It is not affiliated with or endorsed by Moonshot AI or Kimi.
- OpenAI API Compatibility: Exposes
http://127.0.0.1:1340/v1/chat/completionsand/v1/models. - Connect-RPC Streaming: Native handling of Kimi's
application/connect+jsonbinary framing protocol, unpacking 5-byte envelope frames directly into live text & reasoning tokens. - Thinking / Reasoning: Streams thinking / reasoning process into
reasoning_contentdelta chunks in real-time. - UI Setting Respect: Uses
kimi-chat, which automatically respects whatever you toggle in the Kimi Web UI (Thinking mode, Web Search). - Tool Calling: Translates tool schemas and parses
<tool_call>outputs into OpenAI function call structures for agent tools (write,edit,bash,read). - Chat Management: Send
/clear,/reset, or/newin chat to start a clean conversation session. - Lightweight: Pure Python (
aiohttp) + Tampermonkey script with no heavy automation frameworks.
pip install -r requirements.txt- Install Tampermonkey or Violentmonkey in your browser.
- Create a new userscript and paste the contents of
kimi-bridge.user.js. - Open kimi.ai (or kimi.moonshot.cn) and log in.
- You will see a badge at the bottom-right: Kimi Bridge: Connected (Ready) once the proxy is running.
python kimi-proxy.pyOptions:
--host 127.0.0.1: Listening host (default:127.0.0.1).--port 1340: Listening port (default:1340).
Add this provider to your OpenCode config (opencode.jsonc):
{
"provider": {
"kimi-proxy": {
"api": "openai",
"name": "Kimi Web Proxy",
"options": {
"baseURL": "http://127.0.0.1:1340/v1",
"apiKey": "nah",
"timeout": 3600000,
"chunkTimeout": 3600000
},
"models": {
"kimi-chat": {
"id": "kimi-chat",
"name": "Kimi Chat (Web Proxy)",
"tool_call": true,
"reasoning": true,
"temperature": true
}
}
}
}
}- Base URL:
http://127.0.0.1:1340/v1 - API Key:
nah - Models:
kimi-chat: Recommended default (respects active toggles in Web UI)kimi-thinking: Forces thinking / reasoning mode via API
from openai import OpenAI
client = OpenAI(
base_url="http://127.0.0.1:1340/v1",
api_key="nah",
)
response = client.chat.completions.create(
model="kimi-chat",
messages=[{"role": "user", "content": "Hello Kimi"}],
stream=True,
)
for chunk in response:
reasoning = getattr(chunk.choices[0].delta, "reasoning_content", None)
if reasoning:
print(reasoning, end="", flush=True)
content = chunk.choices[0].delta.content or ""
print(content, end="", flush=True)- Keep the browser tab open while using the proxy.
- If the badge shows disconnected, click it to reconnect immediately.
- To reset manually, send
/clear,/reset, or/newdirectly from your client prompt (or runwindow.deleteCurrentChat()in the browser console).
MIT