> 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/list-your-api/zh/ru-men/publish-your-own-api.md).

# 或者：发布你自己的 API

为自己的 API 定义新工具，建立连接并选择谁能使用。

如果目录中没有描述你 API 功能的工具，选择此流程。你定义新工具的名称、输入和答案，且你的端点是唯一提供方。如果已有适用工具，请改用[上架目录中的工具](/list-your-api/zh/ru-men/list-a-catalogue-tool.md)。两条路径选一条即可。

{% hint style="info" %}
**开始前：**[设置账户与钱包](/list-your-api/zh/ru-men/set-up-your-account.md)。了解 API 接受和返回的内容。要认领公开名称，组织必须通过 Assay 的资格检查，例如至少充值过一次或是已验证的提供方。认领名称按人限频。如果认领被拒绝，请联系 Assay 支持为你验证。分享还需要可用的上架项、结算付款钱包和必要质押。
{% endhint %}

## 操作步骤

{% stepper %}
{% step %}

### 认领公开名称

打开 **Listings → Your APIs**，选择 **Publish your API**。如果还没有公开名称，在 **Name** 输入业务的 **Public name**，选择 **Claim**。此名称会成为你发布的每个工具名称的前缀。分享工具后名称即被锁定；之后要修改，请联系 Assay 支持。

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-cd866f301c5a63b47cd3c4392d3087d6e7837172%2Fpublish-your-own-api-1.png?alt=media" alt="提交前的公开名称认领表单，已标出公开名称字段和 Claim"><figcaption><p>选择用于标识工具的业务名称。</p></figcaption></figure>
{% endstep %}

{% step %}

### 命名工具

填写 **Tool name**、**Topic** 和 **What it does, in one line**。例如，天气摘要服务可以使用 `get_weather_summary`。请慎重选择名称，以后无法修改。预览会显示智能体调用的完整名称，包括公开名称。选择 **Save and continue** 创建私有草稿。

{% hint style="success" %}
\*\*节省时间：\*\*在 **Fill this in from your endpoint** 下粘贴 curl 命令或 OpenAPI 文档，选择 **Try it**。Assay 会实际调用一次，并根据答案给出输入、输出和示例。选择 **Use these inputs, outputs and example** 填入它们，再进行检查。不会保存任何内容。**Inputs & outputs** 中也有同样的面板。
{% endhint %}

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-d1fbb7886b850e10bd300ed1d7f008eb5d5cd99b%2Fpublish-your-own-api-2.png?alt=media" alt="新 API 表单，显示天气摘要工具名称、主题和一句话描述"><figcaption><p>说明 API 的功能，以及智能体何时应使用它。</p></figcaption></figure>

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-d47e68f5177f67ea3962edae2bac1006ae6f9289%2Fpublish-your-own-api-3.png?alt=media" alt="端点辅助工具，已填入示例 curl 命令，已标出 Save and continue"><figcaption><p>核对端点辅助工具，准备好后保存私有草稿。</p></figcaption></figure>
{% endstep %}

{% step %}

### 描述输入和答案

在 **Inputs & outputs** 检查 **Summary** 和 **Description**。使用 **What agents send** 和 **What your API returns** 下的字段编辑器。为每个字段填写名称、类型和描述。只有每个有效请求或答案都必须包含该字段时，才勾选 **Required**。

这些字段共同构成工具契约：约定智能体发送什么、API 返回什么。不要把密钥和密码放在输入字段中；它们应放在连接的身份验证设置中。

对于天气摘要，可以描述一个名为 `place` 的必填文本输入，以及一个名为 `summary` 的必填文本答案。请与你的实际 API 保持一致。可以使用 **Add a starter example** 根据字段生成示例，再检查它是否代表有效答案。

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-2cafef4c6ee57b6dcde274f42132b5601db8f2be%2Fpublish-your-own-api-4.png?alt=media" alt="输入输出字段编辑器，显示必填的 place 输入和 summary 答案"><figcaption><p>描述 API 接受和返回的字段。</p></figcaption></figure>

检查预览和所有发现的问题。首个版本准备好后，选择 **Save as v1.0.0 (only your team)**。只用 **Save draft** 会保留进行中的工作，不会生成可用于下一步的版本。

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-271391b45b96ff7fa559a4a7826079713e1a6d7b%2Fpublish-your-own-api-5.png?alt=media" alt="首版控件，已标出 Save as v1.0.0 only your team"><figcaption><p>为团队保存首个版本。</p></figcaption></figure>
{% endstep %}

{% step %}

### 连接并测试端点

在 **Connect & check** 选择 **Connect your endpoint**。新工具的上架向导会打开。

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-37f6ab356083d19f26f4736320cb6dd08d2be439%2Fpublish-your-own-api-6.png?alt=media" alt="Connect and check 入口，已标出天气摘要工具的 Connect your endpoint"><figcaption><p>打开新工具的连接设置。</p></figcaption></figure>

输入 **Your API's address**，再选择 Assay 的身份验证方式：

* \*\*Assay signature (recommended)：\*\*先使用[无需代码的 Cloudflare Worker](https://docs.goassay.ai/developers/zh/list-your-api/cloudflare-worker)或[代码中的验证器](https://docs.goassay.ai/developers/zh/list-your-api/verify-in-your-code)设置检查，再选择它和 **Save connection**。不会保存任何密钥。
* \*\*API key：\*\*选择它，再选择 **Save connection**。选择 **Add headers**，输入 API 的请求头名称和值，再选择 **Save headers**。值会加密，且之后不会再次显示。

[上架目录中的工具](/list-your-api/zh/ru-men/list-a-catalogue-tool.md)解释了每种方式。

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-3b73f01ca84e8e400dec03e8ba36b0b69c744e4d%2Fpublish-your-own-api-7.png?alt=media" alt="天气摘要连接表单，已输入 API 地址并选择 API key，尚未保存或测试"><figcaption><p>输入地址，选择 Assay 的身份验证方式。</p></figcaption></figure>

如果建议的连接设置符合 API，请保留。在 **Test it** 下填写有用的输入，选择 **Save and run test**。检查 **Request built**、**Your API answered**、**Output mapped** 和 **Checks**。测试不向任何人收费。修复失败步骤后重新运行，再继续。
{% endstep %}

{% step %}

### 发布提供服务的上架项

选择 **Continue to Go live**。设置 **How agents pay** 和 **Price per call**。**Free + paid** 为每个智能体提供每日免费额度，用完后再收费；默认额度是 100 次调用。保留默认失败率承诺 2%，无需展开 **Advanced**。

在 **Summary** 阅读价格、你的份额和所需质押。满足要求后选择 **Publish**。如果按钮要求添加质押，按提示连接并验证质押钱包，核对金额后批准 USDG 和质押交易。你需要 USDG，以及支付网络手续费的 ETH。质押确认后，此流程会发布上架项。免费上架无需质押。

你会返回 **Connect & check**。分享前再次检查要求。上线提供服务的上架项与分享工具是此流程中的两个独立部分；外部客户要使用，必须两者都完成。
{% endstep %}

{% step %}

### 选择谁能使用工具

打开 **Who can use it**。选择适合此次发布的使用范围：

{% tabs %}
{% tab title="Only my team" %}
准备工具期间保留 **Only my team**。组织以外的人无法使用。

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-e642ca03bed0c03bb854246fbda3e94c8d6df370%2Fpublish-your-own-api-8.png?alt=media" alt="Who can use it 卡片，已选择 Only my team"><figcaption><p>准备发布期间，保持工具私有。</p></figcaption></figure>
{% endtab %}

{% tab title="Anyone with the link" %}
选择 **Anyone with the link**，所有检查通过后选择 **Share with anyone with the link**。工具可通过链接使用，并标记为未经审核。
{% endtab %}

{% tab title="Listed in the catalogue" %}
选择 **Listed in the catalogue**，阅读 **What the reviewer checks**。检查通过后选择 **Submit for review**。提交只会开始审核，不会立即将工具列入目录。在 **Inbox** 阅读决定。如果要求修改，请修复版本并重新提交。
{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

## 确认是否成功

在 **Your APIs** 中，状态应与所选范围一致：**Only my team**、**Anyone with the link**、**In review** 或 **Listed**。向外部发布时，还要确认提供服务的上架项为 **Live**，且 **Connect & check** 中的检查通过。

**Versions** 部分记录已发布的契约。修改已列入目录的工具时，新版本会进入审核，已批准版本继续提供服务。输入或答案的变更应视为契约变更，并针对打算提供的版本测试端点。

<figure><img src="https://2968587239-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEVw4IWiK1TgVNFeMYjWm%2Fuploads%2Fgit-blob-27833c2660ae6ffea99d68c007a5b0bf4ce68f9e%2Fpublish-your-own-api-9.png?alt=media" alt="Versions 部分，将首个天气摘要契约记录为 v1.0.0"><figcaption><p>Versions 记录了 v1.0.0，即智能体获得的版本。</p></figcaption></figure>

## 遇到问题时

| 你看到的情况                    | 处理方式                                                                    |
| ------------------------- | ----------------------------------------------------------------------- |
| 无法认领公开名称                  | 检查建议名称。如果账户尚不符合条件，先完成提供方验证再重试。                                          |
| **Save and continue** 不可用 | 认领公开名称，补全工具名称、主题和摘要。                                                    |
| 第 3、4 步被锁定                | 在 **Inputs & outputs** 使用 **Save as v1.0.0 (only your team)** 保存首个可用版本。 |
| 已保存草稿中有发现的问题              | 修复页面指出的字段或示例，保存后重新检查。                                                   |
| 分享被阻止                     | 使用 **Connect & check** 补齐测试、已上线的上架项、结算付款钱包或质押。                          |
| **Changes requested**     | 阅读审核说明，更新契约并重新提交。                                                       |

## 进一步了解

* 开发者（可选）：[API 密钥或签名](https://docs.goassay.ai/developers/zh/list-your-api/api-key-or-signature)。
* 开发者（可选）：[用 Cloudflare Worker 验证](https://docs.goassay.ai/developers/zh/list-your-api/cloudflare-worker)。
* 开发者（可选）：[在代码中验证](https://docs.goassay.ai/developers/zh/list-your-api/verify-in-your-code)。

## 下一步

* [获取收益](/list-your-api/zh/ru-men/get-paid.md)


---

# 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/list-your-api/zh/ru-men/publish-your-own-api.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.
