Answers
How do I connect Qwen-Agent or Kimi to Xiaohongshu and Douyin data?
Short answer
Qwen-Agent can load https://api.okdata.online/mcp as a streamable-HTTP MCP server with your key in a static Authorization header, which gives Qwen the find, describe and call tools. Kimi, GLM and other OpenAI-compatible models reach the same endpoints through function calling. A Xiaohongshu search costs $0.02, a Douyin search $0.02 and a Douyin creator profile $0.002.
A team in Hangzhou builds its research assistant on Qwen because the model reads Chinese slang well and runs close to their users. The assistant needs to look up Xiaohongshu notes and Douyin creators mid-conversation. Qwen-Agent can mount a remote MCP server, and a recent issue on its tracker confirms it supports static headers but not OAuth for remote servers. A static Bearer key is exactly what okdata uses, so the setup is one dictionary.
Qwen-Agent: mount the MCP server
import os
from qwen_agent.agents import Assistant
tools = [{
"mcpServers": {
"okdata": {
"type": "streamable-http",
"url": "https://api.okdata.online/mcp",
"headers": {"Authorization": f"Bearer {os.environ['OKDATA_API_KEY']}"},
}
}
}]
bot = Assistant(llm={"model": "qwen-max-latest", "model_server": "dashscope"}, function_list=tools)
messages = [{"role": "user", "content": "Find popular Xiaohongshu notes about 敏感肌 sunscreen and name the three most-liked authors."}]
for responses in bot.run(messages=messages):
pass
print(responses[-1]["content"])
The agent first calls find and describe, which are free, then call for Xiaohongshu note search, Douyin video search or Douyin account profile. If Qwen-Agent fails to import the streamable-HTTP client, update it; older releases broke with version 2 of the MCP Python SDK.
Kimi, GLM and other OpenAI-compatible models
Moonshot's Kimi API is OpenAI-compatible at https://api.moonshot.cn/v1, and so are most Chinese model APIs. Describe each endpoint as a function tool and run the HTTP call when the model asks; the full loop is in function calling with a social data API. Before wiring anything, test the key:
curl -s -G "https://api.okdata.online/v1/douyin/users/get" -H "Authorization: Bearer $OKDATA_API_KEY" \
--data-urlencode "url=https://www.douyin.com/user/MS4wLjABAAAA..." -d fields=name,followers,posts,likes
What a session costs
| Task | Calls | Cost |
|---|---|---|
| 2 Xiaohongshu search pages | 2 | $0.04 |
| 2 Douyin search pages | 2 | $0.04 |
| 10 Douyin creator profiles | 10 | $0.02 |
| The session above | 14 | {{cost:xiaohongshu.notes.search2+douyin.videos.search2+douyin.users.get*10}} |
Gotchas
- Keep the key in the environment. Qwen-Agent configs often end up in notebooks that get shared.
- Search with Chinese keywords; that is the language of nearly every note and caption.
- Douyin creators are identified by sec_uid (the long
MS4wLjABAAAA...string in the profile link), not by the Douyin number shown in the app. The profile endpoint accepts the link directly. - Xiaohongshu hides view counts, so views stay null there.
- Results are written by platform users; the call tool's own description already tells the model to treat them as data, and your system prompt should say it too.
Other options
Kimi has a built-in web search tool, which is handy for news but does not see inside Douyin or Xiaohongshu. Alibaba Cloud's model platform offers hosted MCP servers for some services; check whether it lets you add your own remote server with a header. The MCP page lists the connection details every client needs.
Updated