Skip to main content

Python SDK for Lenzy AI analytics platform

Project description

Lenzy AI Python SDK

Official Python SDK for the Lenzy AI analytics platform.

Python Version

Installation

pip install lenzyai

Quick Start

from lenzyai import Lenzy

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

# Record messages
client.record_messages(
    project_id="proj_123",
    external_conversation_id="conv_456",
    messages=[
        {
            "role": "USER",
            "content": "Hello!",
            "external_id": "msg_1",  # optional
            "sent_at": "2025-11-27T10:30:00.000Z",  # optional
        },
        {"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 Lenzy

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

2. Environment Variables

export LENZY_API_KEY="your-api-key"
export LENZY_ENABLED="true"  # Optional, set to "false" or "0" to disable
from lenzyai import Lenzy

# Will use environment variables
client = Lenzy()

3. Defaults

  • enabled: True

Disabling the SDK

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

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

# Method 2: Environment variable
# export LENZY_ENABLED="false"
client = Lenzy(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 "Lenzy Error:"
import logging

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

client = Lenzy(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.4.tar.gz (6.6 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.4-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lenzyai-0.0.4.tar.gz
  • Upload date:
  • Size: 6.6 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.4.tar.gz
Algorithm Hash digest
SHA256 7b76f6653c385a56739fa2de572f6fdec46501a33453a5bd55068611b11deb40
MD5 de6a09e606acc7d2a1791f4c0ca13a6c
BLAKE2b-256 88bcc02199038603e7167df473d8c38af60a73a2112df42e7f0b8f2e52b4188e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lenzyai-0.0.4-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.13.2

File hashes

Hashes for lenzyai-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b68d4bf3f528feda3dfe03e42e28118b414389e0bb58f6d8014ec45b01b2ffee
MD5 c9eb69a2eb1c188fb5187ebd6327b629
BLAKE2b-256 ae439aa9fce94b39e2119b72da646ceebfe664605a83bec4c443ae304601c9d7

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