Installation
FastAPI integration is an optional installation. To install all required dependencies, run:Setting Up FastAPI Endpoints
You can expose your agencies and tools as API endpoints using therun_fastapi()
function.
Example: Create an API endpoint for a single agency
- host (default:
"0.0.0.0"
) - port (default:
8000
) - app_token_env (default:
"APP_TOKEN"
) - Name of the env variable storing app token. - return_app (default: False) - If True, will return the FastAPI instead of running the server
- cors_origins: (default: [”*”])
- enable_agui (default:
False
) - Enable AG-UI protocol compatibility for streaming endpoints - enable_logging (default:
False
) - Enable request tracking and expose/get_logs
endpoint - logs_dir (default:
"activity-logs"
) - Directory for log files when logging is enabled
/test_agency/get_response
/test_agency/get_response_stream
/test_agency/get_metadata
enable_logging=True
, a /get_logs
endpoint is also added.
Both of these endpoints will accept following input parameters:
"APP_TOKEN"
specified (or a differently named variable if you provided app_token_env). If the token is not specified in the env variables, authentication will be disabled.
Example: Serving Multiple Agencies and Tools
/test_agency_1/get_response
/test_agency_1/get_response_stream
/test_agency_1/get_metadata
/test_agency_2/get_response
/test_agency_2/get_response_stream
/test_agency_2/get_metadata
/tool/ExampleTool
(for BaseTools) or/tool/example_tool
(for function tools)/tool/TestTool
(for BaseTools) or/tool/test_tool
(for function tools)
enable_logging=True
, a /get_logs
endpoint is also added.
Inputs for the tool endpoints will follow their respective schemas.
API Usage Example
You can interact with your agents and tools using HTTP requests. Here’s an example using Python’srequests
library:
Endpoint Structure
-
Agency Endpoints:
Each agency is served at:
/your_agency_name/get_response
(POST)/your_agency_name/get_response_stream
(POST, streaming responses)/your_agency_name/get_metadata
(GET)
-
Tool Endpoints:
Each tool is served at:
/tool/ToolClassName
(POST) - for BaseTools/tool/function_name
(POST) - for FunctionTools
-
Logging Endpoint:
When
enable_logging=True
:/get_logs
(POST)
-
AG-UI Protocol:
When
enable_agui=True
, only the streaming endpoint is exposed and follows the AG-UI protocol for enhanced frontend integration.
File Attachments
When using the agency endpoints (/{your_agency}/get_response
and /{your_agency}/get_response_stream
), you can attach files in two ways:
- Direct inline:
.pdf
,.jpeg
,.jpg
,.gif
,.png
- Via
file_ids
/file_urls
(processed, not inline):.c
,.cs
,.cpp
,.csv
,.html
,.java
,.json
,.php
,.py
,.rb
,.css
,.js
,.sh
,.ts
,.pkl
,.tar
,.xlsx
,.xml
,.zip
,.doc
,.docx
,.md
,.pptx
,.tex
,.txt
- Rejected:
.go
and any extension not listed above - Payload fields:
file_ids: string[]
ORfile_urls: { filename: url }
file_urls
:
- The server downloads each URL, uploads it to OpenAI, waits until processed, and uses the resulting File IDs.
file_ids_map
(shape:{ filename: file_id }
) is returned in the non‑streaming JSON response ofPOST /get_response
and in the finalevent: messages
SSE payload ofPOST /get_response_stream
.