Skip to main content

AI usage tracking and billing SDK

Project description

Alura AI Python SDK

Track AI usage and costs with automatic billing integration.

Installation

pip install alura-ai

With OpenAI support:

pip install alura-ai[openai]

Quick Start

Automatic OpenAI Tracking

from alura import Alura, AluraOpenAI
from openai import OpenAI

# Initialize clients
alura = Alura(api_key="your-alura-api-key")
openai_client = OpenAI(api_key="your-openai-key")
alura_openai = AluraOpenAI(openai_client, alura)

# All calls within trace() are automatically tracked
with alura.trace(customer_id="cust-123", agent_id="my-chatbot"):
    response = alura_openai.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Hello!"}]
    )

Manual Signal Tracking

from alura import Alura

alura = Alura(api_key="your-alura-api-key")

# Track any event
alura.signal(
    event_name="meeting_booked",
    agent_id="sales-agent",
    customer_id="cust-123",
    data={
        "meeting_type": "demo",
        "duration_minutes": 30
    }
)

Bulk Signal Recording

from alura import Alura, Signal

alura = Alura(api_key="your-alura-api-key")

signals = [
    Signal(
        event_name="email_sent",
        agent_id="outreach-agent",
        customer_id="cust-123",
        data={"recipient": "user@example.com"}
    ),
    Signal(
        event_name="call_made",
        agent_id="outreach-agent",
        customer_id="cust-123",
        data={"duration_seconds": 120}
    ),
]

alura.signal_bulk(signals)

API Reference

Alura(api_key, base_url)

Main client for Alura API.

alura.trace(customer_id, agent_id)

Context manager for tracing calls. All AluraOpenAI calls within are auto-tagged.

alura.signal(event_name, agent_id, data, customer_id)

Record a single signal/event.

alura.signal_bulk(signals)

Record multiple signals in one request.

AluraOpenAI(openai_client, alura_client)

OpenAI wrapper with automatic tracking.

License

MIT License

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

alura_ai-0.1.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

alura_ai-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file alura_ai-0.1.2.tar.gz.

File metadata

  • Download URL: alura_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for alura_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e688b7ed907a93db62c91843494af34b6d9aa13a80e52503ce71b663b7eb4949
MD5 88d05dff17a6e4144d6bb020209c878f
BLAKE2b-256 eae0d5f560d90075f0cf484dba004f8b8cb51a3a9deb5549c65dc22443740e37

See more details on using hashes here.

File details

Details for the file alura_ai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: alura_ai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for alura_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1305ee20035efbfbf8e3c33728d7830b058a9464303b6f43a5f76777639a01de
MD5 bfcff6d7e2a651e0a78d3eb189a10152
BLAKE2b-256 4c1f445258c71006aa1f0e4c41aa6b78e3d9642e6607cd953881454b6aa133c0

See more details on using hashes here.

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