Create API Tools

circle-info

You can use MaiAgent's Tool Creation AI Assistantarrow-up-right to help you create API tools

API tools are used to integrate external services and automate operational workflows.

What is an API?

API (Application Programming Interface) is a bridge for communication between different software systems. Simply put, it's like a "waiter" in the software world, helping different programs exchange information and execute functions.

Imagine you're dining at a restaurant:

  • You: The customer who needs food (application)

  • Kitchen: The place where food is prepared (system providing services)

  • Waiter: Passing messages between you and the kitchen (API)

You don't need to go directly to the kitchen; you just tell the waiter what you want, the waiter communicates your needs to the kitchen, and then brings the prepared meal to you.

API Process Diagram

API tools can help you automate standardized processes and configure specific return formats. They can also help you retrieve information from your system, such as:

E-commerce Customer Service Automation

Marketing Campaign Management

Online Course Platform:

Through API tools, AI assistants evolve from simple chatbots into intelligent assistants capable of actually executing business processes, significantly improving work efficiency and automation.

Quick Create API Tool

1. Access Tool Management Interface

First, navigate to the "AI Features" section from the left sidebar, then click "🔧 Tools". After entering the tools list page, click the "➕ Add Tool" button in the upper right corner.

Tools list page and add button
Click "➕ Add Tool" to start creating

2. Select Tool Type

For tool type, select API.

3. Set Display Name

Set a clear display name for the tool, here set as google calendar.

  • Purpose: This name will be displayed in the platform interface for all users to view.

  • Recommendation: Choose a name that clearly expresses the tool's main function for easy user understanding. There are no strict format restrictions for this name.

4. Set Tool Name

Next is the "Tool Name" field.

  • Purpose: This name is the unique identifier used by the AI assistant to internally call and identify this tool.

  • Naming Rules (Important):

    • Must use English.

    • Can only include:

      • Lowercase letters (a-z)

      • Uppercase letters (A-Z)

      • Numbers (0-9)

      • Underscores (_)

      • Hyphens (-)

    • Examples: get_weather_forecast, database-query-tool

In the image below, it's set as google_calendar_retriever

API Tool Name Definition

5. Write Tool Description

In the "Tool Description" field, users can provide a clear and detailed tool explanation.

  • Importance: A good description helps the AI assistant more accurately understand:

    • The tool's functionality and purpose.

    • When this tool should be used.

    • How to interpret the tool's output results.

  • Recommended Content: Explain what the tool does, what it inputs, what it outputs, and any usage precautions.

Tool Description

6. API Configuration Detailed Settings

a. 🔗 API URL

  • Fill in the complete URL of the target API endpoint (including http:// or https://).

  • Example: https://api.opencalendar.org/data/2.5

b. 📮 HTTP Method

  • Select the HTTP verb required by the API service from the dropdown menu:

    • GET: Typically used to retrieve resources.

    • POST: Typically used to create new resources or submit data.

    • PUT: Typically used to completely replace or update resources.

    • DELETE: Typically used to delete resources.

c. 📰 Headers

Headers are like the "envelope" of a letter, telling the receiver some important information before seeing the actual data content. Without correct headers, API requests may fail authentication, or the receiver may be unable to parse the data correctly.

Common Uses:

  • Authentication (Authorization, X-API-Key)

  • Specify content type (Content-Type)

  • Specify accepted response format (Accept)

To add headers, you need to:

  • Click "➕ Add Header" to define HTTP headers sent with the request.

  • Format: Must be a valid JSON object, where keys are header names and values are header contents (strings).

  • Example:

API header settings screenshot
Configure necessary HTTP request headers

d. 🧩 Parameters Schema

Parameters schema is like an "order form", telling the AI assistant what data it can request from the API and how to request it.

  • Core Configuration: Define which parameters the AI assistant can or must provide when calling this tool (content to be passed to the system for processing), and the format of these parameters.

  • Format: Uses standard JSON Schema format.

  • Key Elements:

    • type: "object": Indicates parameters are an object.

    • properties: Defines the object for each parameter.

      • Parameter Name (e.g., "search"): The corresponding object contains details about that parameter.

        • type: Parameter's data type (string, integer, number, boolean, array, object).

        • description: Explanation for the AI assistant, describing the meaning of this parameter.

        • default (optional): Default value for the parameter.

        • enum (optional): If parameter values can only be specific options, list them here.

    • required: An array containing all required parameter names.

  • Example (Video Search Tool):

API parameters schema settings screenshot
Use JSON Schema to precisely define API parameters

7. 💾 Save Tool

After confirming all settings are correct, scroll to the bottom of the page and click the "Confirm" button. Your new tool is now created!

⚠️ Important Reminders

Connection Testing

  • After creating the tool, it's recommended to test whether the API works normally

  • You can use testing tools to verify tool functionality, such as:

    • POSTMAN

    • Enterprise's own API testing request platform

Permission Management

  • Regularly review tool usage status and permission access status

Last updated

Was this helpful?