Skip to main content

Python SDK for LenzyAI analytics platform

Project description

LenzyAI Python SDK

Official Python SDK for the LenzyAI analytics platform.

Python Version

Installation

pip install lenzyai

Quick Start

from lenzyai import LenzyAI

# Initialize the client
client = LenzyAI(api_key="your-api-key")

# Record messages
client.record_messages(
    project_id="proj_123",
    external_conversation_id="conv_456",
    messages=[
        {"role": "USER", "content": "Hello!"},
        {"role": "ASSISTANT", "content": "Hi there! How can I help you?"},
    ],
    external_user_id="user_789",  # optional
)

Configuration

The SDK can be configured in three ways (in order of precedence):

1. Constructor Parameters

from lenzyai import LenzyAI

client = LenzyAI(
    api_key="your-api-key",
    enabled=True,  # Optional, defaults to True
)

2. Environment Variables

export LENZYAI_API_KEY="your-api-key"
export LENZYAI_ENABLED="true"  # Optional, set to "false" or "0" to disable
from lenzyai import LenzyAI

# Will use environment variables
client = LenzyAI()

3. Defaults

  • enabled: True

Disabling the SDK

You can disable the SDK in non-production environment without removing code:

# Method 1: Constructor
client = LenzyAI(api_key="your-api-key", enabled=False)

# Method 2: Environment variable
# export LENZYAI_ENABLED="false"
client = LenzyAI(api_key="your-api-key")

# All record_messages() calls will be no-ops
client.record_messages(...)  # Does nothing

Error Handling

The SDK uses a fail-safe design:

  • Errors during initialization raise exceptions
  • Errors during record_messages() are logged but never raise exceptions
  • All errors are logged with the prefix "LenzyAI Error:"
import logging

# Configure logging to see errors
logging.basicConfig(level=logging.ERROR)

client = LenzyAI(api_key="your-api-key")
client.record_messages(...)  # Logs errors, never crashes

Requirements

  • Python 3.8+
  • requests>=2.25.0
  • typing-extensions>=4.0.0

License

MIT License - see LICENSE file for details.

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

lenzyai-0.0.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

lenzyai-0.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file lenzyai-0.0.1.tar.gz.

File metadata

  • Download URL: lenzyai-0.0.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for lenzyai-0.0.1.tar.gz
Algorithm Hash digest
SHA256 19d78de802c1f026094b1c198062e317975b953850689bef431952fb9bc6baf5
MD5 30ad71cffd224a758fd61c2cf15eb716
BLAKE2b-256 c7e9cf978cf0b6b2a8b2be81fddb1d8c72374f8c2c1eb84e3552dae2e05ea7ba

See more details on using hashes here.

File details

Details for the file lenzyai-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: lenzyai-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for lenzyai-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e099f97d0daa69d0e5e9b6d2e82575aa5e1362571d3bdabc52404c7d38db3c8
MD5 6b9016ef607c85d0dfa9fec9eaa56a2e
BLAKE2b-256 ba85fd90f188a43f0063ffcd356d2ea99d6ab62eccc0847f642cc37f0236f062

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