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.3.tar.gz (7.3 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.3-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: alura_ai-0.1.3.tar.gz
  • Upload date:
  • Size: 7.3 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.3.tar.gz
Algorithm Hash digest
SHA256 2a4f8b55b98c4438fd3a0adb0fc8f51263b79652dd5d18e7e6e7bfc6b37df686
MD5 b27d0908b8c3fbb355f7dc56e8fbbc8d
BLAKE2b-256 732c7de4532f3f3a62519ab2d5f3f6cc4b1766c125f37a8cf53a3f7de7c6b682

See more details on using hashes here.

File details

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

File metadata

  • Download URL: alura_ai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 8.0 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 67003366947e98e77a19bdbff816d8767b87fc570b2f23fae924886243029575
MD5 b00bf61c10862b382a83cb4860df1750
BLAKE2b-256 1d995b3560038b3dfea9d28b985c63c4e93ff3d507b5f366eb5da0d50094ae43

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