> For the complete documentation index, see [llms.txt](https://tinyhumans.gitbook.io/openhuman/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tinyhumans.gitbook.io/openhuman/zh/kai-fa/embed/api-reference.md). Agents can also search and read this documentation through its [MCP server](https://tinyhumans.gitbook.io/openhuman/~gitbook/mcp).

# 嵌入 API 参考

使用本地 rustdoc 和源代码生成的索引查看完整的 Embed 公共接口。

使用以下命令生成可用的本地 Rust API 文档： `cargo doc -p openhuman-embed --no-deps --open`。包括 `--features mcp,skills,channels,storage-sqlite` 用于离线示例所使用的门面门控，或者选择你的宿主实际构建的功能集。对于所有导出的可选接口，请使用 `--all-features`.

该 crate 目前 `publish = false`；docs.rs 链接只是发布元数据目标，并不表示存在一个可用的包引用。本地 rustdoc 和 [规范的门面源](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-embed/src/lib.rs) 是当前完整的参考。

## 生成的清单

* [API 索引](https://tinyhumans.gitbook.io/openhuman/zh/kai-fa/embed/api-reference/api-index.md)：公开门面导出的名称以及带版本的运行时报告。
* [机器可读的 API 索引](https://github.com/tinyhumansai/openhuman/tree/main/docs/gitbooks/en/developing/embed/api-index.json)：导出名称、构建器签名、能力和页面路径。
* [RuntimeBuilder 设置项](https://tinyhumans.gitbook.io/openhuman/zh/kai-fa/embed/api-reference/builder-setters.md)：当前公开的消费型 setter 及其源位置。
* [编译后的功能矩阵](https://tinyhumans.gitbook.io/openhuman/zh/kai-fa/embed/api-reference/capability-matrix.md)：来自默认功能能力报告可执行文件的实际核心门控。
* [食谱](https://tinyhumans.gitbook.io/openhuman/zh/kai-fa/embed/cookbook.md)：示例标题、运行模式以及源头部注释中所需的命名门面功能。

生成的 setter 列表是权威的开关清单。它排除了静态预设以及借用的检查/构建/运行方法；这些属于本地 rustdoc。核心编译门控、运行时模块/域选择以及命名的门面导出是彼此独立的可用性层。

## 按用途划分的公开接口

| 用途          | API 起点                                                     |
| ----------- | ---------------------------------------------------------- |
| 启动并检查主机     | `RuntimeBuilder`, `运行时`, `RuntimeInfo`                     |
| 注册和移除作用域代理  | `AgentSpec`, `Agent`, `AgentDefinitionSpec`, `RemoveAgent` |
| 配置执行和决策     | `访问`, `SandboxModeSpec`, `Approvals`, `ApprovalHandler`    |
| 执行或流式传输原生回合 | `Turn`, `TurnOutcome`, `TurnStream`, `StreamEvent`         |
| 提供自定义模型适配器  | `Provider` 和 `providers::ChatModel`                        |
| 无状态生成       | `补全器`, `CompletionRequest`，结构化响应辅助方法                       |
| 有类型的非回合域    | 内存和 cron 门面、配置/认证/制品/聊天接口                                  |
| 替换基础设施端口    | `切面`, `session_store`，内存引擎和提供方契约                           |
| 提供隔离的客户资料   | `ProfileRuntime`, `ProfileHandle`, `SaasConfig`            |

## 带版本的能力数据

```rust
    let info = runtime.capabilities();
    assert_eq!(info.schema_version, 1);
    assert!(info.defaults.routed_provider);
    let serialized = serde_json::to_string(&info)?;
    assert!(!serialized.contains("sk-test"));
    assert!(!serialized.contains(&provider.uri()));
    assert!(!serialized.contains(&runtime.workspace_dir().display().to_string()));
    println!("{}", serde_json::to_string_pretty(&info)?);
```

[完整可运行示例](https://github.com/tinyhumansai/openhuman/blob/main/crates/openhuman-embed/examples/capability_report.rs)，包括运行时构造、导入和测试夹具设置。

该报告的架构版本是显式的。应读取其字段，而不是从预设名称推断能力，并且要有意识地处理未来的架构变更。它省略了端点、凭据、提示词和工作区值，因此宿主可以公开构建元数据，而不会暴露私有配置。
