开发者/5 分钟跑通
5 分钟跑通:用 curl 调一次字流
拿到本机令牌,查目录,列出草稿,再一句话写一篇稿。用 curl 演示,换成任何语言都一样。
1. 拿令牌
打开字流桌面端
接口在你电脑本机提供(127.0.0.1),字流关着就连不上。
设置 → 更多 → AI Agent → 开发者选项
复制「本机接口地址」和「令牌」(
ziliu_local_开头)。重置令牌后旧的立刻失效,已经接好的 Agent 要重新接一次。
export ZILIU=http://127.0.0.1:17616
export ZILIU_TOKEN=ziliu_local_你的令牌2. 连上没有
curl $ZILIU/v1/health
# {"ok":true,"service":"ziliu-desktop","version":"3.1.0"}
curl -H "Authorization: Bearer $ZILIU_TOKEN" $ZILIU/v1/me
# {"ok":true,"plan":"creator","pointsRemaining":2950,"features":["publish.agent", …]}/v1/health 不要令牌,用来判断字流开没开;其余接口都要带 Authorization: Bearer <令牌>。/v1/me 里有 publish.agent 才能调 write / public 级的能力。
3. 看有哪些能力
curl -H "Authorization: Bearer $ZILIU_TOKEN" $ZILIU/v1/catalog返回全部能力:名字、分组、风险级、会不会花云点、说明、参数、示例。网页版的能力参考就是这份数据。
4. 调一个能力
curl -X POST $ZILIU/v1/call/os:content:list \
-H "Authorization: Bearer $ZILIU_TOKEN" -H "Content-Type: application/json" \
-d '{"status":"draft"}'
# {"ok":true,"result":[{"id":"content_…","title":"…","kind":"article","status":"draft", …}]}curl -X POST $ZILIU/v1/call/creation:brief \
-H "Authorization: Bearer $ZILIU_TOKEN" -H "Content-Type: application/json" \
-d '{"mode":"article","brief":"一人公司第一年,我花了多少钱在 AI 订阅上","firsthand":"一年订阅花了 1.7 万,最贵的是 Claude Max"}'
# {"ok":true,"result":{"contentId":"content_…","title":"…"}}
curl -X POST $ZILIU/v1/call/creation:generateBatch \
-H "Authorization: Bearer $ZILIU_TOKEN" -H "Content-Type: application/json" \
-d '{"content":{"id":"content_…","title":"…"},"targets":[{"platform":"wechat_mp","kind":"long_text"},{"platform":"xiaohongshu","kind":"short_text"}]}'用 Node / Python 写
const ZILIU = 'http://127.0.0.1:17616'
const headers = { Authorization: `Bearer ${process.env.ZILIU_TOKEN}`, 'Content-Type': 'application/json' }
async function call(channel, payload = {}) {
const res = await fetch(`${ZILIU}/v1/call/${channel}`, { method: 'POST', headers, body: JSON.stringify(payload) })
const body = await res.json()
if (!body.ok) throw new Error(`${res.status} ${body.error}`)
return body.result
}
const topics = await call('topics:dailyToday')
console.log(topics)import os, requests
ZILIU = 'http://127.0.0.1:17616'
H = {'Authorization': f"Bearer {os.environ['ZILIU_TOKEN']}"}
def call(channel, payload=None):
r = requests.post(f'{ZILIU}/v1/call/{channel}', json=payload or {}, headers=H)
body = r.json()
if not body.get('ok'):
raise RuntimeError(f"{r.status_code} {body.get('error')}")
return body['result']
print(call('review:byContent'))