> For the complete documentation index, see [llms.txt](https://docs.goassay.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.goassay.ai/overview/zh/cong-zhe-li-kai-shi/how-it-works.md).

# 工作原理

跟随一次付费工具调用，从 AI 发出请求到结算付款或退款。

下面展示一次付费调用及其资金从请求到结算付款或退款的全过程。本例假设使用本地 AI 应用，USDG 已存入托管余额，并已批准支出限额。免费调用会跳过付款步骤，提供方也不会因此获得收益。

```mermaid
flowchart TD
    A[AI asks for a tool] --> B[Local app checks payment permission]
    B --> C[Price reserved in your escrow]
    C --> D[Provider answers; Assay checks]
    D -->|No charge| E[Reservation released to your balance]
    D -->|Charge allowed| F[Payment held in the contract]
    F -->|Timely report accepted| G[Refund to your escrow]
    F -->|Ready to collect| H[Provider wallet receives its share]
```

## 一次调用的各个步骤

{% stepper %}
{% step %}

### 你的 AI 选择工具

AI 阅读工具用途、输入和价格。Assay 会寻找符合条件的提供方。\*\*资金：\*\*你的存款仍在托管余额中；选择工具不会向任何人付款。
{% endstep %}

{% step %}

### 本地应用批准付款

本地 assay-mcp 应用检查付款请求是否符合你批准的限额，再用支付密钥签名。该密钥与你的钱包密钥分开。\*\*资金：\*\*仍在你的托管余额中，尚未向提供方付款。如果没有权限，付费调用会在此停止。
{% endstep %}

{% step %}

### Assay 预留费用并请求提供方

Assay 检查已签名的许可，预留调用金额，再向选定提供方的 API 发送工具请求。\*\*资金：\*\*仍在托管余额中，但预留金额不能用于其他调用或提现。
{% endstep %}

{% step %}

### 答案返回，开始检查

Assay 记录返回内容，并按工具的规则进行检查。检查仍在运行时，你的 AI 可能已经收到答案。\*\*资金：\*\*仍被预留。标为 **Checking** 的结果尚未确定最终收费。
{% endstep %}

{% step %}

### Assay 决定是否收费

如果启用的检查发现提供方失败，会释放预留资金。允许收费的调用会进入链上付款暂扣阶段。\*\*资金：\*\*或者重新成为你的可用托管余额，或者由合约暂扣，直到向提供方付款。收据会显示执行了哪些检查。
{% endstep %}

{% step %}

### 暂扣付款退款或收款

付款暂扣期从付款记录上链时起持续一小时。请以收据上的 **Refundable until** 时间为准，而不是你收到答案的时间。在此之前提交的问题报告会暂停收款；若被认定成立，则会将全额退回你的托管余额。超过这个时间后，你仍可在 7 天内报告不良结果，但不会再为该调用退款；报告会计入提供方的质量记录。

\*\*资金：\*\*一直留在合约中，直到退回你的余额或被收取。收款时，提供方的份额转入其收款钱包，价格中已包含的 Assay 费用转给 Assay。已完成的结算付款无法通过此退款流程追回。如果已提供服务的调用无法收款，会变为 **Owed**，付费调用会暂停，直到你结清欠款。如果长时间仍未收款，会被标为 **Written off**：提供方不会收到付款，但你仍然欠这笔钱，付费调用也会保持暂停，直到你结清欠款。
{% endstep %}
{% endstepper %}

## 收据会告诉你什么

收据会显示标价、实际支付金额、未收费金额、仍暂扣或欠付的金额，以及执行了哪些检查。如果检查漏过了不良答案，请使用收据上的 **Report a bad result**。退款会退回你的 Assay 余额；要将这笔钱转回钱包，需要另外提现。

## 下一步

* 准备开始？[创建账户](https://docs.goassay.ai/use-tools/zh/create-your-account)。
* 想了解技术流程？请查看[一次付费调用的全过程](https://docs.goassay.ai/developers/zh/overview/life-of-a-call)。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.goassay.ai/overview/zh/cong-zhe-li-kai-shi/how-it-works.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
