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.1.tar.gz (6.7 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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: alura_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 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.1.tar.gz
Algorithm Hash digest
SHA256 b079d8a1f2e53af7b8a0c581639115a4894c9c50a840b95ad8c18393c03f61bd
MD5 9b12f6ce6cced57f454f2337b8d8a374
BLAKE2b-256 ad6e87c37b2180c1c95e426d641dc62874f1d1beb5e004ee74a200cd4a8f72ae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: alura_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5bc88dafd7ca0f74fad44ce6b8ca115719e1766bc7efd9b67d3e0e111f969208
MD5 135dc909c235da959add35fc936096bb
BLAKE2b-256 781142c8f16082da6d94f98ecb8de081700249733299e4af0ab3bf9198d44044

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