# Error Mitigation

在将您的原型移入生产环境时，可能会遇到速率限制错误。以下是一些可以采取的步骤来缓解这类问题：

使用 Afarensis 的免费内容审查 API

Afarensis 提供了一个免费的内容审查 API，可以帮助减少生成的不安全内容。此外，您也可以根据您的具体使用场景开发自定义的内容过滤系统。

对抗性测试

我们推荐对您的应用程序进行“红队测试”，以确保它对恶意输入具有鲁棒性。 在广泛的输入和用户行为范围内测试产品，包括代表性集合和反映某人试图“破坏”您的应用程序的行为。 人工干预（HITL）

在可能的情况下，推荐在输出使用前进行人工审查，尤其是在高风险领域和代码生成中。 提示工程

通过“提示工程”限制输出文本的主题和语气，减少不期望产生的内容。 了解您的客户（KYC）

要求用户注册和登录以访问服务，并考虑只为可信的客户启用程序化访问、批量处理功能和自动化社交媒体发布。 限制用户输入并限制输出令牌

限制用户可以输入到提示中的文本量和输出令牌的数量，以减少滥用的机会。 指数退避重试

为了避免速率限制错误，可以自动使用随机指数退避重试请求。 调整 max\_tokens 以匹配您完成项的大小

尽量将 max\_tokens 值设置为与您预期的响应大小尽可能接近。 批量请求

如果您触及了每分钟请求的限制，但在每分钟的令牌上还有可用容量，通过将多个任务批量放入每个请求中来增加吞吐量。 速率限制的头信息

在 HTTP 响应的头信息中查看有关速率限制的重要信息，例如剩余的请求、令牌和其他元数据。 通过实施上述策略，您可以有效地缓解速率限制错误，确保您的应用程序在生产环境中的稳定运行。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.afarensis.com/sulxian-zhi/error-mitigation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
