Skip to main content
The optional aiplanet-agentops Python package records an application’s agent runs, nested steps, tool calls, and feedback as standard OpenTelemetry traces. It correlates model requests routed through the AI Planet gateway without patching the OpenAI SDK.

Basic usage

Install the approved package build with the OTLP export extra, then initialize it once during application startup:
Wrap each end-to-end task and its meaningful steps:
The metadata helper attaches the active trace, parent span, run, tenant, application, environment, agent, and optional user/session identifiers. The gateway verifies scope assertions against the application key before forwarding a request. Operators configure the gateway and SDK to use the same OTLP-compatible backend; the gateway then emits one child generation carrying its authoritative route, usage, cost, latency, and outcome. Requests do not wait for that bounded export. Runs and spans map to typed backend-neutral observations. Gateway model calls remain generation observations carrying authoritative model, token, cost, and latency data; tool, retrieval, guardrail, retry, and application-step spans keep the control flow around them. Direct provider callers can use agentops.generation(...).set_usage(...) with provider-returned values.

Data handling

Input and output content is not exported by default. The SDK records redacted type, size, and digest attributes so repeated calls and loops can still be identified. Content capture is an explicit opt-in with a maximum size and must follow your trace backend’s access, region, retention, and deletion policy. Exception details are also disabled by default. Export is asynchronous and bounded; an unavailable trace backend does not fail the agent request. Call agentops.shutdown() from the application shutdown hook so the final batch has a bounded opportunity to flush.