Skip to main content

OpenTelemetry-native run-level cost attribution for AI workflows

Project description

botanu SDK for Python

License

botanu is platform that helps AI companies understand the real cost of their AI features per customer, enabling outcome-based pricing and smarter scaling. This SDK is built on OpenTelemetry for event-level cost attribution for AI workflow. For more email- deborah@botanu.ai

Getting Started

An event is one business transaction — resolving a support ticket, processing an order, generating a report. Each event may involve multiple runs (LLM calls, retries, sub-workflows) across multiple services. By correlating every run to a stable event_id, Botanu gives you per-event cost attribution and outcome tracking without sampling artefacts.

Install

pip install botanu

An event is one business transaction — resolving a support ticket, processing an order, generating a report. Each event may involve multiple runs (LLM calls, retries, sub-workflows) across multiple services. By correlating every run to a stable event_id, botanu gives you per-event cost attribution and outcome tracking without sampling artifacts.

export BOTANU_API_KEY=<your-api-key>

Wrap your agent:

import botanu

with botanu.event(event_id=ticket.id, customer_id=user.id, workflow="Support"):
    agent.run(ticket)

That single wrap captures every LLM call, HTTP call, and DB call inside and stamps them with event_id, customer_id, and workflow.

Decorator form

import botanu

@botanu.event(
    workflow="Support",
    event_id=lambda ticket: ticket.id,
    customer_id=lambda ticket: ticket.user_id,
)
def handle_ticket(ticket):
    return agent.run(ticket)

Works for both sync and async def functions.

Multi-phase workflows

with botanu.event(event_id=ticket.id, customer_id=user.id, workflow="Support"):
    with botanu.step("retrieval"):
        docs = vector_db.query(ticket.query)
    with botanu.step("generation"):
        response = llm.complete(docs)

See the Quickstart for the full five-minute walkthrough.

Documentation

Topic
Installation Install and configure
Quickstart Zero-to-first-trace in five minutes
Configuration Env vars, YAML, trusted-host auth
Run Context Events, runs, retries, baggage
Context Propagation Cross-service and queue propagation
Architecture SDK + collector split
LLM Tracking Manual LLM instrumentation (usually not needed)
Data Tracking DB, storage, messaging (usually not needed)
Content Capture Prompt/response capture for eval, with PII scrubbing
Outcomes Diagnostic annotations and server-side resolution
Auto-Instrumentation Supported libraries
Kubernetes Zero-code instrumentation at scale
Existing OTel / Datadog Brownfield coexistence
event / step API Primary API reference
Best Practices Patterns that work
Anti-Patterns Patterns that break cost attribution

Requirements

  • Python 3.9 or newer
  • An OpenTelemetry Collector (Botanu Cloud runs one for you; self-hosted is supported too)

Contributing

Contributions are welcome. Read the Contributing Guide before opening a pull request.

All commits require DCO sign-off:

git commit -s -m "Your commit message"

Looking for a place to start? See the good first issues.

Community

Governance

See GOVERNANCE.md for roles, decision-making, and the contributor ladder. Current maintainers are in MAINTAINERS.md.

Security

Report security vulnerabilities via GitHub Security Advisories or see SECURITY.md. Do not file a public issue.

Code of Conduct

This project follows the LF Projects Code of Conduct. See CODE_OF_CONDUCT.md.

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

botanu-0.1.dev77.tar.gz (52.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

botanu-0.1.dev77-py3-none-any.whl (62.7 kB view details)

Uploaded Python 3

File details

Details for the file botanu-0.1.dev77.tar.gz.

File metadata

  • Download URL: botanu-0.1.dev77.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for botanu-0.1.dev77.tar.gz
Algorithm Hash digest
SHA256 ce494493d1fdbf076b1893c185e0f4a8e75ac2de93394ee56a103f011d28804e
MD5 0a16f496d0f9407c1c9dfa1520062f84
BLAKE2b-256 894dbae0555969e6f56bac0295341418e0090de8ff03256965edd22e9ac435b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for botanu-0.1.dev77.tar.gz:

Publisher: release.yml on botanu-ai/botanu-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file botanu-0.1.dev77-py3-none-any.whl.

File metadata

  • Download URL: botanu-0.1.dev77-py3-none-any.whl
  • Upload date:
  • Size: 62.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for botanu-0.1.dev77-py3-none-any.whl
Algorithm Hash digest
SHA256 cf182522dd02015c9741633935f13f71e9e3f00894ad7732ca43fe022c97bdf2
MD5 2aa834e5e96e36df73f85cd4db98b846
BLAKE2b-256 e7bbc75db4f514247acb0a2725119714011186542308296867315effed9217d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for botanu-0.1.dev77-py3-none-any.whl:

Publisher: release.yml on botanu-ai/botanu-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page