> ## Documentation Index
> Fetch the complete documentation index at: https://ikun.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom API

**CustomApiTools** 使代理能够通过可自定义的身份验证和参数向任何外部 API 发出 HTTP 请求。

## 先决条件

以下示例需要 `requests` 库。

```shell theme={null}
pip install requests
```

## 示例

以下代理将使用 CustomApiTools 向 Dog CEO API 发出 API 调用。

```python cookbook/tools/custom_api_tools.py theme={null}
from agno.agent import Agent
from agno.tools.api import CustomApiTools

agent = Agent(
    tools=[CustomApiTools(base_url="https://dog.ceo/api")],
    markdown=True,
)

agent.print_response(
    '向以下两个不同端点发出 API 调用：/breeds/image/random 和 /breeds/list/all，分别获取随机的狗图片和狗品种列表。两个调用均使用 GET 方法。'
)
```

## Toolkit 参数

| 参数             | 类型               | 默认值    | 描述                        |
| -------------- | ---------------- | ------ | ------------------------- |
| `base_url`     | `str`            | `None` | API 调用的基 URL              |
| `username`     | `str`            | `None` | 基本身份验证的用户名                |
| `password`     | `str`            | `None` | 基本身份验证的密码                 |
| `api_key`      | `str`            | `None` | Bearer token 身份验证的 API 密钥 |
| `headers`      | `Dict[str, str]` | `{}`   | 请求中包含的默认标头                |
| `verify_ssl`   | `bool`           | `True` | 是否验证 SSL 证书               |
| `timeout`      | `int`            | `30`   | 请求超时（秒）                   |
| `make_request` | `bool`           | `True` | 是否注册 make\_request 函数     |

## Toolkit 函数

| 函数             | 描述                                                                                            |
| -------------- | --------------------------------------------------------------------------------------------- |
| `make_request` | 向 API 发出 HTTP 请求。接受 method (GET, POST, 等)、endpoint 以及可选的 params、data、headers 和 json\_data 参数。 |

## 开发者资源

* 查看 [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/api.py)
* 查看 [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/custom_api_tools.py)

```
```
