Skip to main content

launchdarkly-ai-python

Convenience barrel package for the LaunchDarkly AI Python SDK. Re-exports the complete public API of launchdarkly-ai-server — install this instead of launchdarkly-ai-server for the simplest setup.

Installation

pip install launchdarkly-ai-python launchdarkly-ai-openai-messages

To enable trace export to the LaunchDarkly Observability dashboard, install the otel extras group:

pip install "launchdarkly-ai-python[otel]"

init_client() detects the OTel packages at runtime and configures tracing automatically. If the extras are not installed, a single warning is logged and all AI calls continue normally with no-op spans.

Usage

Import everything from launchdarkly_ai_python instead of launchdarkly_ai_server:

import asyncio
from launchdarkly_ai_python import config, graph, resolve_graph
from launchdarkly_ai_python import init_client, shutdown, global_registry
from launchdarkly_ai_openai_messages import create_openai_messages_handler

async def main():
    result = await config(
        key="my-ai-config-flag",
        handler=create_openai_messages_handler(),
    ).invoke("What is feature flagging?", {"kind": "user", "key": "user-123"})

    print(result.response)
    await shutdown()

asyncio.run(main())

inspect_config(key, context)

Reads an AI Config flag variation without invoking any AI provider. Re-exported from launchdarkly-ai-server — see the full reference there.

from launchdarkly_ai_python import inspect_config

result = await inspect_config("my-ai-config-flag", {"kind": "user", "key": "user-123"})
if result["enabled"]:
    print(result["config"]["model"]["name"])

Never raises. Returns {"enabled": bool, "config": dict | None, "meta": dict | None}.

Evaluations from code

init_evaluations and the evaluations result types are also re-exported:

from launchdarkly_ai_python import init_evaluations

evals = init_evaluations()
result = await evals.run(
    project_key="my-project",
    key="unique-evaluation-key",
    dataset="golden-dataset",
    handler=my_handler,
    generation={"provider": "OpenAI", "model": "gpt-4o"},
)

LD_API_TOKEN is required. Configure LD_SDK_KEY — or initialize your own client with init_client(client=...) — to emit one $ld:ai:offline-evals:generation event per generated row through the standard SDK event transport. Use LD_API_BASE_URI for staging or local management API traffic; it is separate from the SDK delivery setting LD_BASE_URI. Evaluation-run links use the explicit ui_base_uri option or LD_UI_BASE_URI (for example, https://ld-stg.launchdarkly.com in staging), defaulting to https://app.launchdarkly.com. See the core evaluations guide.


All exports, types, and behaviors are identical to launchdarkly-ai-server. See the core client README for the full API reference.

Metadata

Release files for launchdarkly-ai-python 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for launchdarkly-ai-python 0.1.6
File Size Uploaded
launchdarkly_ai_python-0.1.6.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for launchdarkly-ai-python 0.1.6
File Interpreter ABI Platform
launchdarkly_ai_python-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / launchdarkly_ai_python-0.1.6.tar.gz

Download URL launchdarkly_ai_python-0.1.6.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
081096d7566867ef1e13277447f539cddbb47b12d3c75c69fffa03760ad3aa0c
BLAKE2b-256 checksum
How to use checksums
08b9e80f19e42b23be9029d68c00f2e35eb76b29e1d37332fb3d5c0ae9cfa65a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / launchdarkly_ai_python-0.1.6-py3-none-any.whl

Download URL launchdarkly_ai_python-0.1.6-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb941a0aa98dade6add9e1b49c8ae8b5c1fe162e6d90076730ccadfbe830fc3b
BLAKE2b-256 checksum
How to use checksums
17cd3d1bc7725d4941e574bc821b3bf2d6b07c167c9a45e820da5fbff3500e21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

This release

0.1.6 This release

2 release files

0.1.3

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page