Custom API
Make API calls from your flows.
Custom API Plugin
If you want to make a third-party API call using your LLM, you can utilize the Custom API plugin. This feature allows you to establish a connection between your LLM and your organization’s infrastructure.
GPT-4
and GPT-3.5-Turbo-0613
The custom API node has the following parameters:
- Method: specifies if the request is GET or POST.
- Params: Specifies how to send parameters (As a body or as part of the path)
- URL: The URL basepath for the API.
- Command: the command used by the LLM to call this API.
- For
body
params: specify a specific JSON body. - For
path
params: list all the params of the API and their description.
- For
- Example: an example of how the LLM will specify the parameters in the
args
- Headers: a JSON with the request headers needed to perform the call.
The values of command
and example
must be consistent for the plugin to be called correctly.
Tutorial: Calling the US Federal Reserve API
To explore this feature, we will use it to enable our LLM to load data from the federal reserve API. To achieve this, we will follow these steps:
- Determine the API URL.
- Determine the request type.
- Find the parameters of the API.
- Build a description of the API for the Plugin.
First, let’s determine the API URL. We need to visit the Federal Reserve API website
There we find that each request has the following structure:
Here we can determine the following:
- The API accepts GET requests.
- The URL is:
https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v1/accounting/od/rates_of_exchange
- The parameters are set in the path.
- The parameters available are:
- Fields (a comma-separated list of values to load, including country_currency_desc,exchange_rate, and record_date).
- Filters (a string filter over the fields loaded).
- The request does not need additional headers.
Now we can connect a Custom API node to the LLM:
With the information above, we can get the fields setup as follows:
- Method:
GET
- Params:
Path
- URL:
https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v1/accounting/od/rates_of_exchange
- Command: the command must specify the different path parameters to use, leading to:
- Example: following the default example and the command, we set an example of invoke-tool:
- Instruction: we set “use this tool to call the federal reserve API and read up-t0-date the rates of exchange”.
Now we have completed all the steps needed to enable our LLM to call the federal reserve API: