Environment:0xSteph Pentest ai FastAPI
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, API |
| Last Updated | 2026-10-23 14:00 GMT |
Overview
FastAPI web framework required by the REST API server and the dashboard's serving infrastructure; provides the async HTTP surface alternative to MCP.
Description
This environment provides the FastAPI web framework that powers the `api/server.py` REST API surface. FastAPI is a modern, fast (high-performance) web framework for building APIs with Python 3.10+ based on standard Python type hints. Pentest-ai's API server exposes engagement management, findings retrieval, SARIF export, and live event streaming over HTTP and WebSocket.
The API server is an alternative integration surface for non-MCP clients. It is an optional dependency installed via `pip install ptai[api]`. The dashboard JavaScript (`api/static/dashboard.js`) is served by this server.
Usage
Use this environment when running the REST API server (`ptai api` or direct `uvicorn api.server:create_app`). Required by any implementation in `api/` that serves HTTP endpoints. Not needed for CLI-only or MCP-only deployments.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, Windows | Same as Environment:0xSteph_Pentest_ai_Python_3_10_Plus |
| Hardware | Any modern CPU | Same as base Python environment |
| Disk | ~30MB additional | FastAPI + uvicorn packages |
Dependencies
System Packages
- Python >= 3.10 (see Environment:0xSteph_Pentest_ai_Python_3_10_Plus)
Python Packages
- `fastapi` (optional extra: `pip install ptai[api]`)
- `uvicorn` (optional extra: included with `[api]`)
Credentials
No additional credentials beyond those in Environment:0xSteph_Pentest_ai_Python_3_10_Plus. The API server optionally reads PENTEST_AI_API_TOKEN for state-mutating endpoints.
Quick Install
# FastAPI is an optional dependency
pip install -e .[api]
# Verify API server starts
ptai api --help
Code Evidence
FastAPI optional dependency declaration from pyproject.toml:
[project.optional-dependencies]
api = ["fastapi", "uvicorn"]
API server factory from api/server.py:
from fastapi import FastAPI
def create_app() -> FastAPI:
app = FastAPI(title="pentest-ai", ...)
return app
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
ImportError: No module named 'fastapi' |
FastAPI not installed | pip install -e .[api]
|
Address already in use |
Port 8000 occupied | Use --port to select a different port
|
401 Unauthorized on POST endpoints |
PENTEST_AI_API_TOKEN mismatch |
Set the env var or disable token auth for local trusted use |
Compatibility Notes
- Transport: HTTP REST + WebSocket (live events). Not an MCP transport.
- Auth: Read endpoints are open; state-mutating endpoints require
PENTEST_AI_API_TOKEN. - Dashboard: The static dashboard at
/dashboardis served by the same FastAPI app.