API Agent
The API Agent connects to REST APIs to fetch and process data. It is ideal for integrating with external services, performing semantic search, and working with dynamic data sources.
Steps to Create
Section titled “Steps to Create”-
Click on Agent in the left sidebar, then give your agent a name.
-
Select API Agent from the Agent Type list and click Next.
-
Fill in the API Configuration:
- API URL: The endpoint to fetch data from.
- HTTP Method: The request method (GET, POST, PUT, etc.).
- API Headers (optional): Add headers such as
Authorization,Content-Type, etc. - API Description: Describe what this API does, what data it returns, and when to use it. A clear description helps the agent decide when to call this API.
- Example Questions (optional): Sample questions this API can answer (e.g., “What are the top 10 customers by revenue?”).
- API Fields: Define the payload or query parameters — for each field, specify:
- Field Name
- Type
- Description
- Allowed Values (optional)
- Default Value (optional)
-
Review the configuration and click Create Agent.
How It Works
Section titled “How It Works”When a user submits a question, the API Agent follows this pipeline:
User Input → Security Check → Question Rewrite → [API Definition + Payload Examples] → Generate Payload →Invoke API → Generate AnswerKey Components
Section titled “Key Components”Security Check
- Validates the question for security concerns (SQL injection, prompt injection) before processing.
Question Rewriting
- Rewrites user queries into complete, self-contained questions.
- Handles date conversions and incorporates follow-up context.
Knowledge Retrieval
- API Definition: Retrieves the API specification to understand available endpoints and parameters.
- Payload Examples: Fetches example API calls to guide payload generation.
Payload Generation
- Generates the API request body or query parameters based on the user’s question.
- Supports GET (query params) and POST/PUT (JSON body) methods.
- Handles dynamic URL placeholder replacement.
API Invocation
- Executes the API call to the configured endpoint.
- Timeout: 300 seconds.
Answer Generation
- Interprets the API response and presents results in natural language.
- Handles empty results gracefully with a clear message.