Skip to main content

Overview

Integrate ATP with FastAPI to expose your tools as HTTP endpoints with automatic API documentation.

Installation


Setup

Step 1: Create ATP Tools Module

Create a module to register your toolkits and tools (e.g., atp_tools.py):

Step 2: Create FastAPI App

Create your FastAPI app and import the ATP tools module:

Step 3: Run the App

Run your FastAPI app with Uvicorn:
Your API will be available at http://localhost:8000.

Usage

Endpoints

  • GET /atp/<toolkit_name>/ - Get toolkit details and list of tools
  • GET /atp/<toolkit_name>/<tool_name>/ - Get tool context/schema
  • POST /atp/<toolkit_name>/<tool_name>/ - Execute a tool with parameters

Example Requests

Get Toolkit Details

Response:

Get Tool Context

Response:

Execute Tool

Response:

Complete Example

Here’s a complete example with multiple tools:

Automatic API Documentation

FastAPI automatically generates interactive API documentation. Visit:
  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Advanced Usage

Async Tools

FastAPI supports async functions. You can define async tools:

Middleware

You can add FastAPI middleware for authentication, logging, etc.:

Dependency Injection

Use FastAPI’s dependency injection for shared resources:

Next Steps

ToolKitClient

Learn more about ToolKitClient

OAuth2 Guide

Set up OAuth2 authentication

Django Integration

Try ATP with Django

Examples

Explore more examples