Skip to main content

Overview

The ToolKitClient class allows you to register Python functions as tools and serve them via WebSocket. It handles:
  • Tool registration with metadata
  • WebSocket(WS(S))/Hyper Text Transfer Protocol(HTTP(S)) connection to the ATP server
  • Tool invocation with parameter validation
  • OAuth2 token injection for authenticated tools
  • Automatic reconnection on connection loss

Constructor

Parameters

string
required
Your ATP Toolkit API key. Get it from the ATP Dashboard.
string
required
Name of your application/toolkit. This will be used to identify your toolkit on the ATP platform.
string
default:"https://api.chat-atp.com.com"
ATP Server backend URL. Use the default unless you’re running a custom ATP server.

Methods

register_tool

Registers a Python function as a tool with the ATP platform.

Parameters

string
required
Unique name for the tool. This is how the LLM will reference the tool.
list[str]
required
List of all parameter names the tool accepts.
list[str]
required
List of required parameter names. The tool will fail if these are not provided.
string
required
Human-readable description of what the tool does. This helps the LLM understand when to use the tool.
string
Name of OAuth2 provider (e.g., “hubspot”, “google”, “salesforce”). Set to None if no authentication is required.
string
Authentication type (e.g., “OAuth2”, “apiKey”). Set to None if no authentication is required.
string
Name of the token parameter (e.g., “access_token”, “api_key”). Set to None if no authentication is required.

Returns

A decorator to wrap your function.

start

Starts the WebSocket client and begins listening for tool requests.
This method blocks the main thread. Make sure all tools are registered before calling start().

stop

Stops the WebSocket client and closes the connection.

Tool Function Requirements

Your tool functions must follow these requirements:
  1. Accept **kwargs: All parameters must be passed as keyword arguments.
  2. Return serializable data: Return a dict, str, list, or other JSON-serializable type.
  3. Handle auth_token: If your tool requires authentication, expect auth_token in kwargs.

Example Tool Function


Examples

Minimal Tool (No Authentication)


Tool with OAuth2 Authentication


Multiple Tools

You can register multiple tools with the same client:

Error Handling

The ATP SDK automatically handles errors and returns them in a standardized format:

Missing Required Parameters

Missing Auth Token

Function Exception


WebSocket Events

Tool Registration

When you call client.start(), all registered tools are announced to the ATP backend.

Tool Invocation

When a tool request is received, your function is called with the provided parameters and (if needed) auth_token. Example incoming message:

Advanced Usage

Custom Backend

If you’re running a custom ATP server, you can specify the base URL:

Next Steps

LLMClient

Connect LLMs to your toolkits

OAuth2 Guide

Set up OAuth2 authentication

Framework Integration

Use ATP with Django, FastAPI, or Flask

Examples

Explore more examples