# 查询智能体状态 (/zh-CN/api-reference/api-ref/conversational-ai/query)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

查询指定智能体实例的当前运行状态。

- OpenAPI: /openapi/conversational-ai/rest-api.zh-CN.yaml
- Operation ID: query-agent-status
- Method: GET
- Path: /v2/projects/{appid}/agents/{agentId}
- Endpoint: https://api.agora.io/cn/api/conversational-ai-agent/v2/projects/{appid}/agents/{agentId}

## Servers

- https://api.agora.io/cn/api/conversational-ai-agent

## Authorization

This endpoint requires authentication.

- `Basic Auth`
- `Agora Token`

## Parameters

- `Authorization` (header, required, string) - 发送 HTTP 请求时，你可以从以下鉴权方式中任选其一：

1. **使用 Token 认证（推荐）**：参考[实现 HTTP 鉴权](/zh-CN/ai/build/http-basic-auth#使用-token-认证)生成 Token 并填入 `Authorization` Header。传参示例：`Authorization: agora token="007abcxxxxxxx123"`。
2. **使用 Basic Auth**：参考[实现 HTTP 鉴权](/zh-CN/ai/build/http-basic-auth#使用-http-基本认证)生成 Base64 编码的 `Authorization` 字段。传参示例：`Authorization: Basic NDI1OTQ3N2I4MzYy...YwZjA=`。

  - Example: `agora token="007abcxxxxxxx123"`
- `appid` (path, required, string) - 你的项目使用的 [App ID](/zh-CN/ai/get-started/enable-service#%E8%8E%B7%E5%8F%96-app-id)。
- `agentId` (path, required, string) - 智能体实例 ID，即智能体的唯一标识。调用 [POST 创建对话式智能体](/zh-CN/api-reference/api-ref/conversational-ai/join) 成功后在响应包体中获取。

## Request body

No request body.

## Responses

### 200

- 若返回的状态码为 `200` 则表示请求成功。响应包体中包含本次请求的结果。
- 若返回的状态码不为 `200` 则表示请求失败。响应包体中包含错误的类别和描述，你可以参考[响应状态码](/zh-CN/api-reference/conversational-ai/rest-api/api/response-code)了解可能的原因。

- `message` (string) - 请求信息。
- `start_ts` (integer) - 智能体创建时间戳。
- `stop_ts` (integer) - 智能体停止时间戳。
- `status` (string) - 智能体运行状态：
- `IDLE` (0)：空闲状态的智能体。
- `STARTING` (1)：正在启动的智能体。
- `RUNNING` (2)：正在运行的智能体。
- `STOPPING` (3)：正在停止的智能体。
- `STOPPED` (4)：已完成退出的智能体。
- `FAILED` (6)：执行失败的智能体。
- `name` (string) - 智能体名称，即调用创建接口时传入的 `name`。同一频道内唯一。
- `agent_id` (string) - 智能体唯一标识。

## Response examples

### 200

```json
{
  "message": "agent exits with reason: xxxx",
  "start_ts": 1735035893,
  "stop_ts": 1735035900,
  "status": "FAILED",
  "name": "support_agent_001",
  "agent_id": "1NT29X11GQSxxxxxNU80BEIN56XF"
}
```
