Requires Python 3.10+. Set FORGE_API_KEY on the server. Install forgeintel-sdk (imported as forgeintel).
server.py
Install: python -m pip install forgeintel-sdk==0.1.0b14.

Complete example

A paid weather API with FastAPI, x402 and Forge, ready to run on Base Sepolia testnet.
Starlette executes the last added middleware first, so this places Forge outside the payment handler. Keep your existing uvicorn server:app entry point and ASGI lifespan enabled; Forge flushes at lifespan shutdown. For a plain ASGI application use app = forge.wrap(app) instead. Agent context is off by default. agent_context=True asks for it and records it, optional: no paid request is rejected without it. AgentContextOptions(required=True) requires it before payment. Agent context. Forge can enrich the existing /openapi.json response. FastAPI may not declare 402 responses generated by payment middleware; add those responses to paid route documentation or configure OpenAPIOptions(is_paid_operation=...) so eligible operations are identified. Keep any existing request validators and payment handlers. OpenAPI details. Check forge.diagnostics()["enabled"] and ["config_errors"] during setup. Verify collector contact.