The Observatory SDK is the bridge between your code and the Observatory platform. Decorate your agents, chains, and tools; the SDK captures inputs, outputs, timings, token usage, and cost, then ships events toDocumentation Index
Fetch the complete documentation index at: https://docs.flowx.ai/llms.txt
Use this file to discover all available pages before exploring further.
/api/report in the background.
Install
flx-observatory-lib; the import name is flowxobservatory. Optional extras pull in framework integrations — for example pip install flx-observatory-lib[langchain] or flx-observatory-lib[openai]. Python 3.12 or newer is required.
Configure
Callconfigure() once at startup, or set the equivalent environment variables — the SDK reads them on import.
| Variable | Required | Purpose |
|---|---|---|
FLOWX_OBSERVATORY_API_KEY | Yes | API key from the Observatory Home page (scoped to organization + workspace). |
FLOWX_OBSERVATORY_API_URL | Yes | Base URL of your Observatory API. |
FLOWX_OBSERVATORY_ORG_ID | Yes | Organization ID. |
FLOWX_OBSERVATORY_WORKSPACE_ID | Yes | Workspace ID. |
FLOWX_OBSERVATORY_APP_ID | Yes | Project ID (maps to project_id). |
OBSERVATORY_TRACING | No | Set to false to turn off instrumentation without removing decorators. |
How the SDK works
- Calls into decorated functions emit
*_startand*_endevents throughtrack_event. - The event queue is in-memory and non-blocking — your hot path is not on the critical send path.
- A background consumer flushes batches to
/api/reporton a short interval. - Delivery is best-effort: if a batch fails to send, those events are dropped rather than blocking your app.
Where instrumentation belongs
| Layer | Decorator | When to use |
|---|---|---|
| Agent | @agent("name") | The top-level function that handles one user request. |
| Chain | @chain("name") | A sub-step inside the agent — retrieval, planning, formatting. |
| Tool | @tool("name") | A unit of external work — DB query, REST call, file fetch. |
LangChain and LangGraph
The SDK ships a callback handler that auto-captures LangChain’son_*_start / on_*_end hooks. Register it once and every chain, tool, and LLM call inside the LangChain runtime emits events without further decoration.
Where to go next
Decorators
Full reference for
@agent, @chain, @tool.Event reporting
The event protocol, custom events, and
saved / chat semantics.
