CustomApiTools enable an Agent to make HTTP requests to any external API with customizable authentication and parameters.

Prerequisites

The following example requires the requests library.

pip install requests

Example

The following agent will use CustomApiTools to make API calls to the Dog CEO API.

cookbook/tools/custom_api_tools.py
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(
    'Make API calls to the following two different endpoints: /breeds/image/random and /breeds/list/all to get a random dog image and list of dog breeds respectively. Use GET method for both calls.'
)

Toolkit Params

ParameterTypeDefaultDescription
base_urlstrNoneBase URL for API calls
usernamestrNoneUsername for basic authentication
passwordstrNonePassword for basic authentication
api_keystrNoneAPI key for bearer token authentication
headersDict[str, str]{}Default headers to include in requests
verify_sslboolTrueWhether to verify SSL certificates
timeoutint30Request timeout in seconds
make_requestboolTrueWhether to register the make_request function

Toolkit Functions

FunctionDescription
make_requestMakes an HTTP request to the API. Takes method (GET, POST, etc.), endpoint, and optional params, data, headers, and json_data parameters.

Developer Resources