> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/advanced-topics/custom-providers.md).

# 凭据、身份与存储

Convai Unity SDK 随附面向生产环境的默认配置，涵盖凭据、最终用户身份和会话持久化。每个系统都由一个定义明确的接口支持；当默认设置不适合你的部署时，你可以自行实现并注册。

### 何时使用自定义提供程序

* **CI / 密钥管理** — API 密钥不得存储在 `ConvaiSettings.asset`中；它来自环境变量或密钥保管库。
* **基于身份验证的身份** — 你的应用程序有自己的用户系统（OAuth、Steam、自定义 LMS），并且你希望 Convai 的长期记忆和 MAU（每月活跃用户）跟踪与你的用户 ID 关联。
* **云端保存或自定义存储** — 会话数据必须持久保存到云后端、加密存储或非`PlayerPrefs` 存储。

这三种提供程序都通过继承 `ConvaiManager` 并重写 `CreateRuntimeBuilder()`。这意味着你需要创建一个新的 C# 类来继承 `ConvaiManager`，将其作为组件添加到同一个 GameObject 上的 `ConvaiManager` 当前所在位置，并移除原始组件。例外：身份和元数据提供程序也可以通过 `ConvaiManager`上的直接 setter 进行设置，这不需要子类化，而且在你不需要更改任何其他设置时更简单。

### 下一步

{% content-ref url="/pages/fdc49f930fecd7fb00d337f46a900594f8f26fb5" %}
[自定义凭据提供程序](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/advanced-topics/custom-providers/custom-credential-provider.md)
{% endcontent-ref %}

{% content-ref url="/pages/4f9746367744635226a122f62cd5fa9abd892214" %}
[自定义身份提供程序](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/advanced-topics/custom-providers/custom-identity-provider.md)
{% endcontent-ref %}

{% content-ref url="/pages/2e48fc65c96962e4ad153649c1ead0353c2ca940" %}
[自定义持久化提供程序](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/advanced-topics/custom-providers/custom-persistence-provider.md)
{% endcontent-ref %}

{% content-ref url="/pages/39c79b51732b2441a1b8ec0d5d75288e27e81e91" %}
[个人访问令牌](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/advanced-topics/custom-providers/personal-access-token.md)
{% endcontent-ref %}

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>自定义凭据提供程序</strong><br>从环境变量、密钥保管库或任何运行时来源提供 API 凭据，而不是使用 ConvaiSettings。</td><td><a href="/pages/fdc49f930fecd7fb00d337f46a900594f8f26fb5">/pages/fdc49f930fecd7fb00d337f46a900594f8f26fb5</a></td></tr><tr><td><strong>自定义身份提供程序</strong><br>将 Convai 的最终用户身份绑定到你自己的认证系统，以实现稳定的按用户记忆和准确的每月活跃用户（MAU）跟踪。</td><td><a href="/pages/4f9746367744635226a122f62cd5fa9abd892214">/pages/4f9746367744635226a122f62cd5fa9abd892214</a></td></tr><tr><td><strong>自定义持久化提供程序</strong><br>将 PlayerPrefs 会话存储替换为云后端、加密文件存储或任何键值实现。</td><td><a href="/pages/2e48fc65c96962e4ad153649c1ead0353c2ca940">/pages/2e48fc65c96962e4ad153649c1ead0353c2ca940</a></td></tr><tr><td><strong>个人访问令牌</strong><br>根据你的 API 密钥生成短期令牌，这样真正的密钥就永远不会随你的 Unity 构建一起发布。</td><td><a href="/pages/39c79b51732b2441a1b8ec0d5d75288e27e81e91">/pages/39c79b51732b2441a1b8ec0d5d75288e27e81e91</a></td></tr></tbody></table>


---

# 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 dynamically by asking a question.

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

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/advanced-topics/custom-providers.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.
