> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.alephant.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.alephant.io/_mcp/server.

# 智能体与路由

> 如何在 Alephant 中创建和管理 AI 智能体

智能体代表通过 Alephant 使用 AI 模型的应用程序或服务。创建一个智能体时，您将为该特定用例生成一个隔离的 Virtual Key（VK）。

## 创建智能体

创建智能体时，需要定义：

1. **基本信息：** 应用程序的名称和描述。
2. **配置：** 所需的 LLM provider、目标 model 和环境（例如 production、staging）。
3. **路由：** 用于处理请求的底层 Master Key（Provider Key）。

创建后，Alephant 会自动生成一个绑定到该智能体的 Virtual Key。

## 智能体 ID

每个智能体都有稳定的 Agent ID。发送网关流量时使用该 ID，以便 Alephant 将请求、运行、成本、策略和日志归属到正确的智能体。

对于新的集成，请发送：

```http
Alephant-Agent-Id: agt_support_bot_8f3a
Alephant-Run-Id: run_<your-run-id>
```

对来自同一智能体的每个请求使用相同的 Agent ID。每次任务执行使用新的 Run ID。

## 智能体可观测性

仪表盘会深入追踪智能体指标（请求量、延迟、成本、token）。虽然智能体数量本身不会影响订阅计费，但追踪每个智能体的性能对于优化和识别异常（如延迟激增或异常成本）至关重要。

当请求包含 Agent ID 和 Run ID 上下文时，智能体可观测性最强。请参阅 [智能体 ID 与运行 ID](/docs/overview/core-concepts/agent-i-ds-and-run-i-ds) 了解使用示例。

## 智能路由

借助 Alephant，您可以实施智能路由策略（支持的套餐可用）来配置备用模型。如果主 provider 发生故障，网关可将流量无缝路由到次要 provider，而无需您修改任何代码。