kaman.ai

Docs

Documentation

Guides, use cases & API reference

  • Overview
    • Getting Started
    • Platform Overview
  • Features
    • Features Overview
    • AI Assistant
    • Workflow Automation
    • Intelligent Memory
    • Data Management
    • Universal Integrations
    • Communication Channels
    • Security & Control
  • Use Cases Overview
  • Financial Services
  • Fraud Detection
  • Supply Chain
  • Technical Support
  • Software Development
  • Smart ETL
  • Data Governance
  • ESG Reporting
  • TAC Management
  • Reference
    • API Reference
  • Guides
    • Getting Started
    • Authentication
  • Endpoints
    • Workflows API
    • Tools API
    • KDL (Data Lake) API
    • OpenAI-Compatible API
    • A2A Protocol
    • Skills API
    • Knowledge Base (RAG) API
    • Communication Channels

Tools (Functions) API

Tools are individual functions that perform specific operations. You can search for available tools and execute them directly via the API.

Base URL

All Tools API requests go through the marketplace proxy:

/api/agent/functions

For self-hosted installations, prepend your instance URL: http://kaman.ai/api/agent/functions

Search Tools

Search for available tools by name or description.

Endpoint

GET /api/agent/functions

Parameters

ParameterTypeRequiredDescription
qstringYesSearch query (searches name and description)

Example

bash
curl -X GET "http://kaman.ai/api/agent/functions?q=email" \
  -H "Authorization: Bearer kam_your_api_key"

Response

json
[
  {
    "id": 42,
    "name": "Send Email",
    "description": "Sends an email to specified recipients",
    "inputFields": [
      {
        "name": "to",
        "type": "string",
        "required": true,
        "description": "Recipient email address"
      },
      {
        "name": "subject",
        "type": "string",
        "required": true,
        "description": "Email subject line"
      },
      {
        "name": "body",
        "type": "string",
        "required": true,
        "description": "Email body content"
      }
    ],
    "outputFields": [
      {
        "name": "messageId",
        "type": "string",
        "description": "ID of the sent email"
      },
      {
        "name": "success",
        "type": "boolean",
        "description": "Whether the email was sent successfully"
      }
    ]
  }
]

Execute a Tool

Execute a tool by its ID or name with the provided arguments.

Endpoint

POST /api/agent/functions/{id}

Path Parameters

ParameterTypeDescription
idstringFunction ID (numeric) or function name

Request Body

The request body should contain the arguments required by the tool's input fields.

Example (by ID)

bash
curl -X POST "http://kaman.ai/api/agent/functions/42" \
  -H "Authorization: Bearer kam_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Hello from Kaman",
    "body": "This is a test email sent via the Kaman API."
  }'

Example (by Name)

bash
curl -X POST "http://kaman.ai/api/agent/functions/Send%20Email" \
  -H "Authorization: Bearer kam_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Hello from Kaman",
    "body": "This is a test email sent via the Kaman API."
  }'

Response (Success)

json
{
  "result": {
    "messageId": "msg_abc123",
    "success": true
  }
}

Response (Error)

json
{
  "error": "Invalid email address format"
}

Code Examples

TypeScript

typescript
const API_KEY = process.env.KAMAN_API_KEY;
const BASE_URL = 'http://kaman.ai';

// Search for tools
async function searchTools(query: string) {
  const response = await fetch(
    `${BASE_URL}/api/agent/functions?q=${encodeURIComponent(query)}`,
    {
      headers: {
        'Authorization': `Bearer ${API_KEY}`
      }
    }
  );
  return response.json();
}

// Execute a tool by ID
async function executeTool(toolId: number | string, args: Record<string, any>) {
  const response = await fetch(
    `${BASE_URL}/api/agent/functions/${toolId}`,
    {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${API_KEY}`,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(args)
    }
  );
  return response.json();
}

// Example usage
const emailTools = await searchTools('email');
const result = await executeTool(42, {
  to: 'user@example.com',
  subject: 'Hello',
  body: 'Test email'
});

Python

python
import requests
import os
from typing import Optional, Dict, Any, List

class KamanTools:
    def __init__(self, base_url: str):
        self.base_url = f'{base_url}/api/agent/functions'
        self.headers = {
            'Authorization': f'Bearer {os.getenv("KAMAN_API_KEY")}',
            'Content-Type': 'application/json'
        }

    def search(self, query: str) -> List[Dict]:
        """Search for tools by name or description."""
        response = requests.get(
            self.base_url,
            params={'q': query},
            headers=self.headers
        )
        return response.json()

    def execute(self, tool_id: str | int, args: Dict[str, Any]) -> Dict[str, Any]:
        """Execute a tool with the provided arguments."""
        response = requests.post(
            f'{self.base_url}/{tool_id}',
            json=args,
            headers=self.headers
        )
        return response.json()

# Example usage
client = KamanTools('http://kaman.ai')

# Search for email-related tools
tools = client.search('email')
for tool in tools:
    print(f"{tool['name']}: {tool['description']}")

# Execute a tool
result = client.execute(42, {
    'to': 'user@example.com',
    'subject': 'Hello',
    'body': 'Test email'
})
print(result)

cURL

bash
#!/bin/bash
API_KEY="${KAMAN_API_KEY}"
BASE_URL="http://kaman.ai/api/agent/functions"

# Search for tools
curl -s "$BASE_URL?q=email" \
  -H "Authorization: Bearer $API_KEY"

# Execute a tool by ID
curl -s -X POST "$BASE_URL/42" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "user@example.com",
    "subject": "Hello",
    "body": "Test email"
  }'

Understanding Tool Definitions

Each tool has defined input and output fields:

Input Fields

PropertyTypeDescription
namestringField name (used as the argument key)
typestringData type (string, number, boolean, array, object)
requiredbooleanWhether this field is required
descriptionstringDescription of the field

Output Fields

PropertyTypeDescription
namestringField name in the result
typestringData type of the output
descriptionstringDescription of the output

Error Handling

StatusErrorDescription
400Validation errorMissing or invalid input arguments
401UnauthorizedInvalid or missing authentication
404Tool not foundInvalid tool ID or name
500Execution errorError during tool execution

Error Response

json
{
  "error": "Missing required field: to"
}

Best Practices

  1. Check Tool Requirements: Use the search endpoint to inspect required input fields before execution
  2. Validate Inputs: Ensure all required fields are provided with correct types
  3. Handle Errors: Implement proper error handling for failed executions
  4. Use IDs When Possible: Using tool IDs is faster than names since names require lookup

Next Steps

  • Workflows API - Chain multiple tools into workflows
  • Authentication - Learn about API authentication
  • KDL API - Query your data lake

On this page

  • Base URL
  • Search Tools
  • Endpoint
  • Parameters
  • Example
  • Response
  • Execute a Tool
  • Endpoint
  • Path Parameters
  • Request Body
  • Example (by ID)
  • Example (by Name)
  • Response (Success)
  • Response (Error)
  • Code Examples
  • TypeScript
  • Python
  • cURL
  • Understanding Tool Definitions
  • Input Fields
  • Output Fields
  • Error Handling
  • Error Response
  • Best Practices
  • Next Steps