api-config.json 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. {
  2. "name": "test-billing",
  3. "displayName": "计费流程测试",
  4. "description": "测试技能:验证 OpenClaw 能否识别 API 错误并触发充值页面。调用即梦API但不传token,故意触发错误响应。",
  5. "category": "test",
  6. "version": "1.0.0",
  7. "endpoint": {
  8. "method": "POST",
  9. "url": "https://server.fmode.cn/api/volcengine/jimeng/getImgV4",
  10. "headers": {
  11. "Content-Type": "application/json"
  12. }
  13. },
  14. "parameters": {
  15. "type": "object",
  16. "required": ["prompt"],
  17. "properties": {
  18. "prompt": {
  19. "type": "string",
  20. "description": "图片描述文本"
  21. }
  22. }
  23. },
  24. "requestTransform": {
  25. "body": {
  26. "prompt": "{{prompt}}",
  27. "sizeDate": { "width": 512, "height": 512 },
  28. "scale": 0.6,
  29. "force_single": true
  30. }
  31. },
  32. "response": {
  33. "type": "object",
  34. "properties": {
  35. "code": { "type": "integer" },
  36. "data": { "type": "object" },
  37. "error": { "type": "object" }
  38. }
  39. },
  40. "timeout": 30000,
  41. "usageExamples": [
  42. {
  43. "name": "测试余额不足流程",
  44. "input": {
  45. "prompt": "测试"
  46. },
  47. "description": "发送任意prompt触发API调用,验证错误检测和充值弹窗"
  48. }
  49. ],
  50. "tokenConfig": {
  51. "type": "bearer",
  52. "tokenField": "token",
  53. "resolutionOrder": ["configFile"],
  54. "onMissing": {
  55. "action": "showPaymentQR",
  56. "qrCodeUrl": "https://pwa.fmode.cn/apig-pay.html?user={{user}}&apigid={{apigid}}&fun_id=HOkkX72PMF",
  57. "paymentCheckEndpoint": "https://server.fmode.cn/api/apig/getApig",
  58. "pollingIntervalMs": 3000,
  59. "pollingTimeoutMs": 300000,
  60. "onPaymentSuccess": "retrySkillWithNewToken",
  61. "title": "请扫码开通服务",
  62. "message": "请扫描下方二维码完成支付,支付成功后将自动获取 Token 并继续执行。"
  63. },
  64. "onBalanceInsufficient": {
  65. "action": "showPaymentQR",
  66. "qrCodeUrl": "https://pwa.fmode.cn/apig-pay.html?user={{user}}&apigid={{apigid}}&fun_id=HOkkX72PMF",
  67. "paymentCheckEndpoint": "https://server.fmode.cn/api/apig/getApig",
  68. "pollingIntervalMs": 3000,
  69. "pollingTimeoutMs": 300000,
  70. "onPaymentSuccess": "retrySkillWithNewToken",
  71. "title": "余额不足,请扫码充值",
  72. "message": "当前 Token 余额不足,请扫描二维码充值,支付完成后将自动继续执行。"
  73. }
  74. },
  75. "errorHandling": {
  76. "balanceInsufficient": {
  77. "conditions": [
  78. { "responseField": "code", "operator": "in", "value": [-2, -3, -10, 402, 429] },
  79. { "responseField": "msg", "operator": "contains", "value": ["余额不足", "insufficient", "balance", "quota"] },
  80. { "responseField": "message", "operator": "contains", "value": ["余额不足", "insufficient", "balance"] }
  81. ],
  82. "matchMode": "any",
  83. "trigger": "tokenConfig.onBalanceInsufficient"
  84. },
  85. "unauthorized": {
  86. "conditions": [
  87. { "responseField": "code", "operator": "in", "value": [401, 403] },
  88. { "responseField": "msg", "operator": "contains", "value": ["unauthorized", "token", "invalid", "auth"] },
  89. { "responseField": "error.message", "operator": "contains", "value": ["API_KEY", "sessionToken", "用户不存在", "权限"] }
  90. ],
  91. "matchMode": "any",
  92. "trigger": "tokenConfig.onMissing"
  93. }
  94. }
  95. }