> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# 列出智能体

GET https://api.elevenlabs.io/v1/convai/agents

返回智能体及其元数据列表。

Reference: https://elevenlabs.io/docs/api-reference/agents/list

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Query parameters

- `page_size` (integer, optional, default: 30) — 最多返回的智能体数量。不能超过 100，默认为 30。
- `search` (string, optional, nullable) — 按智能体名称搜索。
- `archived` (boolean, optional, nullable, default: false) — 按归档状态筛选智能体
- `show_only_owned_agents` (boolean, optional, default: false, deprecated) — 设为 true 时，此端点将忽略他人分享给你的智能体，仅包含你拥有的智能体。已弃用：请改用 created_by_user_id。
- `created_by_user_id` (string, optional, nullable) — 按创建者用户 ID 筛选智能体。设置后，仅返回该用户创建的智能体。优先于 show_only_owned_agents。使用 '@me' 指代已认证用户。
- `tags` (list of string, optional, nullable) — 按标签筛选智能体。重复传入此参数可匹配多个标签中的任意一个。
- `sort_direction` (enum, optional) — 结果排序方向
  - Allowed values: `asc`, `desc`
- `sort_by` (enum, optional, nullable) — 用于排序结果的字段
  - Allowed values: `name`, `created_at`, `updated_at`, `call_count_7d`
- `cursor` (string, optional, nullable) — 用于获取下一页。响应中会返回游标。

## Response

### 200

成功响应

- `agents` (list of AgentSummaryResponseModel, required) — 智能体及其元数据列表。
- `has_more` (boolean, required) — 是否还有更多智能体可分页获取
- `next_cursor` (string, optional, nullable) — 用于分页浏览智能体的下一个游标

## Errors

### 422 Unprocessable Entity Error

验证错误。

- `detail` (list of ValidationError, optional)

## Types

### AgentSummaryResponseModel

- `agent_id` (string, required) — 智能体 ID
- `name` (string, required) — 智能体名称
- `voice_id` (string, required) — 分配给此智能体的音色 ID。
- `tags` (list of string, required) — 用于分类智能体的标签
- `created_at_unix_secs` (integer, required) — 智能体创建时间，以 Unix 秒数表示
- `updated_at_unix_secs` (integer, required) — 智能体主分支或智能体级设置的上次更新时间，以 Unix 秒数表示。
- `access_info` (ResourceAccessInfo, required) — 智能体的访问信息
- `last_call_time_unix_secs` (integer, optional, nullable) — 最近一次通话的 Unix 秒级时间戳；如果尚未通话则为 null
- `archived` (boolean, optional, default: false) — 智能体是否已归档

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ResourceAccessInfo

- `is_creator` (boolean, required) — 发出请求的用户是否为该智能体的创建者
- `creator_name` (string, required) — 智能体创建者名称
- `creator_email` (string, required) — 智能体创建者的邮箱
- `role` (enum, required) — 发出请求的用户角色
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `anonymous_access_level_override` (enum, optional, nullable) — 匿名用户的访问级别。若为 None，该资源不会公开共享。
  - Allowed values: `admin`, `editor`, `commenter`, `viewer`
- `access_source` (enum, optional, nullable) — 请求用户拥有此资源访问权限的原因。'creator' = 调用者是所有者。'explicit' = 调用者（或其所属的某个工作区群组）列于 role_to_group_ids 中，且不包括工作区范围的所有人群组。'workspace_default' = 工作区范围的所有人群组列于 role_to_group_ids 中（所有非匿名工作区成员，包括管理员，均可查看此资源）。'workspace_admin' = 调用者是工作区管理员，且管理员席位是 *唯一* 的访问路径；此项仅用于其他人均无法查看的文档。这样 UI 可说明管理员绕过权限的查看者为何能看到未明确向其共享的文档。
  - Allowed values: `creator`, `explicit`, `workspace_admin`, `workspace_default`

### ValidationErrorLocItems

- string
- integer

## Examples

**Response**

```json
{
  "agents": [
    {
      "agent_id": "J3Pbu5gP6NNKBscdCdwB",
      "name": "My Agent",
      "voice_id": "UCaNsl8F6Xh4GALkVMLS",
      "tags": [
        "Customer Support",
        "Technical Help",
        "Eleven"
      ],
      "created_at_unix_secs": 1716153600,
      "updated_at_unix_secs": 1716240000,
      "access_info": {
        "is_creator": true,
        "creator_name": "John Doe",
        "creator_email": "john@example.com",
        "role": "admin"
      },
      "archived": false
    }
  ],
  "has_more": false,
  "next_cursor": "123"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/agents"

querystring = {"archived":"false","tags":"[\"Customer Support\"]"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/agents?archived=false&tags=%5B%22Customer+Support%22%5D';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/convai/agents?archived=false&tags=%5B%22Customer+Support%22%5D"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/agents?archived=false&tags=%5B%22Customer+Support%22%5D")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.elevenlabs.io/v1/convai/agents?archived=false&tags=%5B%22Customer+Support%22%5D")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/agents?archived=false&tags=%5B%22Customer+Support%22%5D');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/agents?archived=false&tags=%5B%22Customer+Support%22%5D");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/agents?archived=false&tags=%5B%22Customer+Support%22%5D")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```