Important: All Xiaohongshu operations must use the exec tool to run the following commands; do not use the browser tool to open web pages.
Environment Variables
| Variable | Required | Description |
|---|---|---|
XHS_TOOLKIT_DIR |
Yes | xhs-toolkit project path (git clone https://github.com/pearl799/xhs-toolkit) |
IMAGE_API_KEY |
Yes | Image generation API Key (any OpenAI-compatible image generation service) |
IMAGE_BASE_URL |
Yes | Image generation API Base URL (e.g. https://openrouter.ai/api/v1/chat/completions) |
IMAGE_MODEL |
Yes | Image generation model name (e.g. google/gemini-3-pro-image-preview) |
OPENCLAW_GATEWAY_TOKEN |
No | OpenClaw Gateway token (for copy generation, if gateway has auth enabled) |
XHS_DATA_DIR |
No | Data directory, default ~/.openclaw/skills/xhs/data |
Commands
Check login status:
uv run --project $XHS_TOOLKIT_DIR {baseDir}/scripts/xhs_status.py
Log in to Xiaohongshu (when the user says "登录小红书"/"xhs login"):
uv run --project $XHS_TOOLKIT_DIR {baseDir}/scripts/xhs_auth.py
Will open Chrome on the Mac desktop; tell the user to scan the QR code.
Publish a note (when the user says "发小红书"/"发布笔记"):
uv run --project $XHS_TOOLKIT_DIR {baseDir}/scripts/xhs_publish.py --title "标题" --content "正文" --images "/path/1.png,/path/2.png" --topics "话题1,话题2"
Before publishing, first use xhs_status.py to check login. --images must be local file paths, 1-9 images. --dry-run can validate without publishing.
Scrape trending topics (when the user says "小红书热点"/"trending"/"今天什么热门"):
uv run --project $XHS_TOOLKIT_DIR {baseDir}/scripts/xhs_trending.py --category "综合" --limit 20
Supports --keyword "AI" search. Categories: General/Fashion/Food/Travel/Beauty/Tech/Fitness/Pets/Home/Education.
AI-generated content (when the user says "生成小红书"/"帮我生成"):
uv run --project $XHS_TOOLKIT_DIR {baseDir}/scripts/xhs_generate_content.py --topic "主题" --style "干货分享" --image-count 4
Generate copy + images. After generating, send to the user for preview, and after confirmation call xhs_publish.py to publish.
Fully automatic pipeline (when the user says "自动发布"/"全自动"):
uv run --project $XHS_TOOLKIT_DIR {baseDir}/scripts/xhs_auto_pipeline.py --mode preview
Trending → topic selection → generate → preview/publish. --mode auto publishes directly.
All scripts output JSON; parse the status field to determine the result. The MEDIA: line indicates attached images.
Notes
- Each command only needs to be called once; just wait for the result and do not execute it repeatedly
- The JSON output by the script is for you to parse; just relay the key information to the user, do not forward it as-is
- After generating content, send the title, body, and topics to the user for preview; use the path in the MEDIA line as the attachment for images
- Do not send multiple messages in one reply; combine them into one