Observe FastAPI services and any standard Python ASGI/WSGI app.
The NxtOne Python SDK runs inside your Python process and sends behavioral events straight to the NxtOne platform over HTTPS — there is no separate process, container, or daemon to run. It works with web frameworks (FastAPI, Flask, Django) and background workers (Celery) to trace requests and code execution.
Install the SDK with pip. It requires Python 3.10+.
Set your API key and a project ID for this service as environment variables:
| Variable | Default | Description |
|---|---|---|
NXTONE_API_KEY | required | Without it the SDK does nothing (it prints a hint to stderr) and never fails your app. |
NXTONE_PROJECT_ID | Project folder name | Groups execution flows in the UI. Set it explicitly — the folder name is often the same across services (for example app in containers). |
NXTONE_EXCLUDE | — | Packages or paths to leave uninstrumented. |
NXTONE_LOG_LEVEL | warn | SDK log verbosity on stderr. |
NXTONE_SHUTDOWN_TIMEOUT | 60 s | How long the SDK waits to flush buffered events at shutdown. See Shutdown below. |
You can also keep settings in a nxtone.toml file in your project root, or in ~/.nxtone/config.toml, both under an [nxtone] table. Environment variables override the project file, which overrides the home-directory file:
Activate the SDK by decorating the function that starts your application with @nxtone.NxtOneAgent:
nxtone.run(main) and @nxtone.instrument are also accepted, if you prefer them to the decorator.
Start the service through the decorated function:
There is no python -m nxtone wrapper and no separate nxtone command — the decorator is the whole integration. If you usually launch with the uvicorn command, move the uvicorn.run(...) call into the decorated main() as shown above so the SDK is active.
The SDK batches events in memory and flushes them when the process exits, or on ASGI lifespan shutdown. At startup it also creates a nxtone/ directory under the system temp directory ($TMPDIR, else /tmp), and writes batches there only when memory is full or sends fail — so if your root filesystem is read-only, mount a tmpfs on /tmp.
SIGTERM handler of its own. Servers such as uvicorn handle SIGTERM and run the lifespan shutdown, where the SDK flushes.NXTONE_SHUTDOWN_TIMEOUT (60 seconds by default) — longer than Docker's 10-second stop timeout and Kubernetes' 30-second grace period. Raise the grace period to match, or lower the timeout.The SDK logs at warn level by default, so a healthy start produces little or no output. The message to watch for is the stderr hint that the API key is missing: it means the SDK is running as a no-op. Otherwise, send a request to your service and check that its execution flow appears in NxtOne under your project ID. If it does not, raise NXTONE_LOG_LEVEL and work through Troubleshooting.
The SDK only makes outbound HTTPS (443) connections — to www.api.nxtone.ai and to Amazon S3 for large values — and opens no ports.