Skip to main content

Python SDK for Lumina LLM observability — OpenTelemetry-native instrumentation

Project description

lumina-sdk

Python SDK for Lumina — OpenTelemetry-native LLM observability.

Installation

pip install lumina-sdk

Or install directly from the monorepo for development:

pip install -e packages/sdk-python/

Quick start

import os
from lumina import init_lumina

lumina = init_lumina({
    "api_key": os.environ["LUMINA_API_KEY"],
    "service_name": "my-app",
    "endpoint": "https://collector.lumina.app/v1/traces",
})

# Trace an OpenAI call
import openai
client = openai.OpenAI()

response = lumina.trace_llm(
    lambda: client.chat.completions.create(
        model="gpt-4",
        messages=[{"role": "user", "content": "Hello!"}],
    ),
    name="greeting",
    system="openai",
    prompt="Hello!",
)
print(response.choices[0].message.content)

Async usage

import asyncio
import openai
from lumina import init_lumina

lumina = init_lumina({"service_name": "my-app"})
client = openai.AsyncOpenAI()

async def main():
    response = await lumina.trace_llm(
        lambda: client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": "Hello!"}],
        ),
        name="greeting",
        system="openai",
    )
    print(response.choices[0].message.content)

asyncio.run(main())

Custom spans

result = lumina.trace(
    "rag_pipeline",
    lambda span: run_rag(span),
    metadata={"query": "What is observability?"},
    tags=["rag", "production"],
)

Environment variables

Variable Default Description
LUMINA_API_KEY API key (omit for self-hosted)
LUMINA_ENDPOINT http://localhost:9411/v1/traces OTLP collector URL
LUMINA_SERVICE_NAME Service name attached to all spans
LUMINA_ENVIRONMENT live live or test
LUMINA_CUSTOMER_ID Customer identifier
LUMINA_ENABLED true Set to false to disable
LUMINA_BATCH_SIZE 10 Max spans per export batch
LUMINA_BATCH_INTERVAL_MS 5000 Batch flush interval (ms)
LUMINA_MAX_RETRIES 3 Export retry count
LUMINA_TIMEOUT_MS 30000 Export timeout (ms)

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

lumina_sdk-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

lumina_sdk-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lumina_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for lumina_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 25cb1a5576ab155fa9fa82cd13b1d386c9c70e52dfacdef585bb6e0f28a4c6df
MD5 5684b81026a098e575899941bb92897f
BLAKE2b-256 94f03c2ae259eca592222549fece2027f5840299917ef033ad93ab77ac82357d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lumina_sdk-0.1.0-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.13.5

File hashes

Hashes for lumina_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51c973d97d9445606a0b43f86928c4ccec98c2e70338053128c0904c3a6ebf59
MD5 8dd63a6a852c83ab728365e5f643fd1a
BLAKE2b-256 d57393d123553c912255f57562fe793eda7873033e876b54cd536f4a664df3ad

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