混沌提纯

DEVELOPER & USER GUIDE

接入简单,记录清楚。

从第一条分类请求,到历史查询、计费核对和工单沟通。

1. 快速开始

  1. 在首页注册独立客户账号,密码8至128字符。此账号与其他系统账号不互通。
  2. 创建API Token,立即复制保存。Token只展示一次,90天有效,每账号最多6个有效Token。
  3. 在控制台选择支付宝或微信支付并准备可用余额。每次充值需您主动确认,服务不会自动从支付账户扣款。
  4. 提交1至100条消息,取得任务编号后轮询结果。Token只用于可信后端,不要嵌入公开网页。

curl

curl https://tichun.cunxx.com/api/v1/classifications \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"request_id":"example-001","messages":[{"id":"m1","text":"需要采购服务器"}]}'

curl https://tichun.cunxx.com/api/v1/classifications/TASK_ID \
  -H 'Authorization: Bearer YOUR_TOKEN'

JavaScript(可信服务器)

const headers = {
  Authorization: `Bearer ${process.env.REFINERY_TOKEN}`,
  'Content-Type': 'application/json'
};
const response = await fetch('https://tichun.cunxx.com/api/v1/classifications', {
  method: 'POST', headers,
  body: JSON.stringify({request_id: 'example-001',
    messages: [{id: 'm1', text: '需要采购服务器'}]})
});
const task = await response.json();
if (!response.ok) throw new Error(task.error);
console.log(task.id, task.status); // 使用任务编号查询,不要重复创建请求

Python(标准库)

import json, os, urllib.request

payload = {"request_id": "example-001",
           "messages": [{"id": "m1", "text": "需要采购服务器"}]}
request = urllib.request.Request(
    "https://tichun.cunxx.com/api/v1/classifications",
    data=json.dumps(payload).encode("utf-8"),
    headers={"Authorization": "Bearer " + os.environ["REFINERY_TOKEN"],
             "Content-Type": "application/json"}, method="POST")
with urllib.request.urlopen(request, timeout=20) as response:
    task = json.load(response)
print(task["id"], task["status"])

任务结果

{
  "id": "TASK_ID", "request_id": "example-001", "status": "succeeded",
  "message_count": 1, "charged": "0.0001", "reserved": "0.0000",
  "model_version": "ML-7782-q3",
  "results": [{"id": "m1", "label": "demand"}], "error": null
}

任务状态为queued、running、succeeded、failed。首次处理中返回202;失败为CLASSIFICATION_FAILED,整批不扣费。七种分类标签见分类标签。模型用于辅助判断,可能误判,不是内容合法性或诈骗鉴定。

欢迎使用混沌提纯

登录

还没有账号?