Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.zapthinker.com/llms.txt

Use this file to discover all available pages before exploring further.

Overview

API Tools enable your RAG bots to interact with external services and APIs, transforming them from simple Q&A bots into powerful assistants that can perform actions and fetch real-time data. This feature implements function calling, allowing your AI to intelligently decide when to use external tools based on user queries.

Key Features

  • API Connections: Configure authentication and base URLs for external services
  • Custom Tools: Define specific API endpoints as callable tools
  • Function Calling: AI automatically determines when to use tools
  • RAG Integration: Link tools to specific RAG bots
  • Bulk Operations: Sync multiple tools to bots efficiently
  • OpenAPI Import: Import entire API specifications automatically
  • Connection Testing: Validate API connections before deployment

How It Works

  1. Create API Connection: Define the base URL and authentication for an external service
  2. Define Tools: Specify individual endpoints as tools with parameters
  3. Link to RAG Bot: Connect tools to your RAG bot
  4. AI Decision Making: The AI determines when to call tools based on user queries
  5. Execute & Respond: Tool results are incorporated into AI responses

Architecture

API Connections

Connections store authentication and base configuration for external APIs:
{
  "name": "Weather API",
  "baseUrl": "https://api.weather.com",
  "authType": "bearer",
  "authToken": "your-api-token",
  "headers": {
    "Content-Type": "application/json"
  }
}

API Tools

Tools define specific endpoints that can be called:
{
  "name": "Get Current Weather",
  "description": "Fetches current weather for a city",
  "connectionId": "conn-123",
  "method": "GET",
  "endpoint": "/current",
  "parameters": {
    "city": {
      "type": "string",
      "description": "City name",
      "required": true
    }
  }
}

Use Cases

Weather Information

Provide real-time weather data when users ask about weather conditions.

Database Queries

Fetch live data from your database (inventory, orders, customer info).

CRM Integration

Look up customer information, create tickets, or update records.

E-commerce

Check product availability, pricing, or order status.

Booking Systems

Check availability and create reservations.

Custom Business Logic

Execute any custom function via your own API endpoints.

Configuration

Authentication Types

  • None: No authentication required
  • API Key: Header-based API key authentication
  • Bearer Token: OAuth/JWT bearer token
  • Basic Auth: Username and password authentication
  • Custom Headers: Any custom header configuration

Tool Parameters

Define parameters that the AI will extract from user queries:
{
  "parameters": {
    "city": {
      "type": "string",
      "description": "The city name",
      "required": true
    },
    "units": {
      "type": "string",
      "description": "Temperature units (celsius/fahrenheit)",
      "required": false,
      "default": "celsius"
    }
  }
}

OpenAPI Import

Automatically import entire API specifications:
  1. Provide OpenAPI/Swagger JSON or YAML
  2. System creates connection and all tools automatically
  3. Review and enable desired endpoints
  4. Link to RAG bots
This dramatically speeds up integration with well-documented APIs.

Linking Tools to RAG Bots

Individual Linking

Link specific tools to specific bots for precise control.

Bulk Sync

Sync all tools from a connection to a bot at once:
{
  "ragId": "rag-123",
  "apiToolIds": ["tool-1", "tool-2", "tool-3"]
}

Dynamic Unlinking

Remove tools from bots when no longer needed.

Best Practices

  1. Clear Descriptions: Write detailed tool descriptions so the AI knows when to use them
  2. Parameter Validation: Define required vs optional parameters clearly
  3. Error Handling: Ensure your APIs return clear error messages
  4. Rate Limiting: Consider API rate limits when designing tools
  5. Security: Use secure authentication methods and never expose sensitive tokens
  6. Testing: Test connections before linking to production bots
  7. Documentation: Document your tools for easier maintenance

Function Calling Flow

  1. User Query: “What’s the weather in New York?”
  2. AI Analysis: Determines weather tool is needed
  3. Parameter Extraction: Extracts city=“New York”
  4. API Call: Executes GET /current?city=New York
  5. Response Integration: Incorporates weather data into natural response
  6. User Response: “The current weather in New York is 72°F and sunny.”

Advanced Features

Connection Testing

Test API connections before deployment to catch configuration issues early.

Tool Versioning

Maintain multiple versions of tools for A/B testing or gradual rollouts.

Usage Analytics

Track which tools are used most frequently to optimize your integrations.

Conditional Logic

Tools can return data that triggers different response paths.

Security Considerations

  • Store API keys securely (never in client code)
  • Use HTTPS for all API connections
  • Implement rate limiting on your endpoints
  • Validate all tool responses before using
  • Log tool usage for audit trails
  • Rotate API keys regularly

Getting Started

  1. Create an API connection with authentication
  2. Define one or more tools for that connection
  3. Test the connection to verify it works
  4. Link tools to your RAG bot
  5. Test with sample queries that should trigger the tools
  6. Monitor usage and refine tool descriptions
For detailed API documentation, see the API Reference section.