开始前准备
- 基础 URL:https://toonverter.com/api
- 所有接口均使用 HTTPS + JSON
- 评估期限流宽松,如需更高吞吐请联系我们
cURL 快速开始
curl https://toonverter.com/api/convert \
-H "Content-Type: application/json" \
-d '{
"input_data": "{\"name\": \"Nova\", \"role\": \"moderator\"}",
"direction": "json_to_toon"
}'
带重试的 Python helper
import requests
from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry
session = requests.Session()
session.mount(
"https://",
HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.5)),
)
payload = {
"input_data": "{\"session\": 42, \"status\": \"active\"}",
"direction": "json_to_toon",
}
resp = session.post("https://toonverter.com/api/convert", json=payload, timeout=10)
resp.raise_for_status()
print(resp.json()["output"])
Node/Edge 函数示例
import fetch from "node-fetch";
export async function convertJsonToToon(payload) {
const response = await fetch("https://toonverter.com/api/convert", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
input_data: JSON.stringify(payload),
direction: "json_to_toon",
}),
});
if (!response.ok) {
throw new Error(`TOON API error: ${response.status}`);
}
const data = await response.json();
return data.output;
}
在 LLM 看见之前先校验
使用相同载荷调用 /api/validate,防止损坏的 JSON 或 TOON 流入下游代理。响应轻量,非常适合 guardrail 或 CI 任务。
生产部署提示
- 将 API 纳入监控(延迟 + token delta)
- 缓存转换以获得幂等响应
- 利用 UI 历史做人工抽查
- 定义故障切换(例如 API 不可用时回退 JSON)