v3-agent-charges.yaml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v3-agent-charges.yaml
  2. post:
  3. summary: 为一次提问扣费(幂等)
  4. tags:
  5. - agent-charges
  6. operationId: post_api_v3_agent_charges
  7. description: |-
  8. 一次提问开始前由 agent 服务调用。先扣今日赠送,不够再扣积分余额;合计不够返回 402
  9. (`type` 为 quota-exceeded,扩展字段 `reason`:insufficient 积分不足 / ip_cap 游客同 IP 超上限,
  10. 另带 `cost`、`free_remaining`、`earned_balance`)。
  11. 账号口径与 `POST /v3/agent-traces` 相同:Bearer 是透传的终端用户 token,
  12. 无效或缺省按游客算,此时 `device_id` 必填。按 run_id 幂等:首次 201,重复 200。
  13. 服务端出错、回答没生成时,写研究过程那一步会自动退回。
  14. 实现:`V3\AgentChargeController@store`
  15. security:
  16. - { }
  17. -
  18. bearerAuth: []
  19. requestBody:
  20. required: true
  21. content:
  22. application/json:
  23. schema:
  24. type: object
  25. properties:
  26. run_id:
  27. type: string
  28. description: 'AG-UI runId(uuid)'
  29. thread_id:
  30. type: string
  31. description: 'AG-UI threadId(uuid)。已经属于别的账号时 403,不扣费'
  32. deep:
  33. type: boolean
  34. description: 是否深度思考(价格不同)
  35. default: false
  36. device_id:
  37. type: string
  38. description: '设备匿名 id(uuid)。游客必填'
  39. client_ip:
  40. type: string
  41. description: '客户端 IP(runtime 写入)。游客必填,没有就 422;只对游客用于同 IP 上限'
  42. required:
  43. - run_id
  44. responses:
  45. 200:
  46. description: 成功
  47. content:
  48. application/json:
  49. schema:
  50. type: object
  51. properties:
  52. data:
  53. type: object
  54. properties:
  55. run_id:
  56. type: string
  57. cost:
  58. type: integer
  59. charged_free:
  60. type: integer
  61. charged_earned:
  62. type: integer
  63. free_remaining:
  64. type: integer
  65. earned_balance:
  66. type: integer
  67. policy_version:
  68. type: integer
  69. 201:
  70. description: '首次扣费。响应体与 200 同形'
  71. content:
  72. application/json:
  73. schema:
  74. type: object
  75. properties:
  76. data:
  77. type: object
  78. properties:
  79. run_id:
  80. type: string
  81. cost:
  82. type: integer
  83. charged_free:
  84. type: integer
  85. charged_earned:
  86. type: integer
  87. free_remaining:
  88. type: integer
  89. earned_balance:
  90. type: integer
  91. policy_version:
  92. type: integer
  93. 401:
  94. $ref: '../../main.yaml#/components/responses/ProblemUnauthorized'
  95. 402:
  96. description: '额度不足或游客同 IP 超上限'
  97. content:
  98. application/problem+json:
  99. schema:
  100. $ref: '../../main.yaml#/components/schemas/ProblemDetails'
  101. 403:
  102. description: 'thread_id 已经属于别的账号'
  103. content:
  104. application/problem+json:
  105. schema:
  106. $ref: '../../main.yaml#/components/schemas/ProblemDetails'
  107. 422:
  108. $ref: '../../main.yaml#/components/responses/ProblemValidation'