Agent 调用大模型前,先把文本算清楚:字符数、UTF-8字节数、中文字数、估算 token 数,并按"每百万 token 单价"预估这次调用的费用。解决 Agent 经济痛点2"成本不可预测"。极窄确定性 utility,支持 402/x402 按次付。
curl -X POST https://api.liuwangcun.com/api/tool/text-cost \
-H "content-type: application/json" \
-H "payment-proof: <支付宝/ x402 付款凭证>" \
-d '{ "text": "要发送的文本", "pricePerMillion": 10 }(pricePerMillion 可省略,默认10元)'
未带付款凭证时返回 HTTP 402 + Payment-Needed 头(含金额、收款方、资源路径),Agent 可直接解析并完成支付后重试。
{ "text": "要发送的文本", "pricePerMillion": 10 }(pricePerMillion 可省略,默认10元)纯确定性计算,无模型推理、无外部数据查询;不扣款、不写入、不查询任何第三方系统。返回结果含免责声明,仅供参考。