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.0.tar.gz (5.8 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.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: alura_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 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.0.tar.gz
Algorithm Hash digest
SHA256 41aa9567806f00a61f8765b210667e1f9cf8005e30ec5781729deb2fcddad4dc
MD5 c1e760f6ba4be5295b423df5aa222b7f
BLAKE2b-256 4ec7b46cae69cead669f910e1a1e145260fd77f7154db70cc2751416bb36bb9d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: alura_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d7f1d1f135b8f57526ed1a92634077a56674b89c5497a3c652a2b6d6879e20c
MD5 f77aa9d40e40e9e134b7dcb9b579f8e1
BLAKE2b-256 afa2e9016819cb390d4cc33669fc13aa74798c9cb45337d39ebf50802b08c179

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