Metadata-Version: 2.5
Name: launchdarkly-ai-litellm-messages
Version: 1.1.0
Summary: LiteLLM messages handler for LaunchDarkly AI SDK
Project-URL: Homepage, https://github.com/launchdarkly/python-ai-sdk
Project-URL: Repository, https://github.com/launchdarkly/python-ai-sdk
Project-URL: Bug Tracker, https://github.com/launchdarkly/python-ai-sdk/issues
Author-email: LaunchDarkly <team@launchdarkly.com>
License-Expression: Apache-2.0
Keywords: ai,launchdarkly,litellm
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.12
Requires-Dist: launchdarkly-ai-server<2,>=1.1.0
Requires-Dist: litellm>=1.83.0
Requires-Dist: opentelemetry-api>=1.25
Description-Content-Type: text/markdown

# `launchdarkly-ai-litellm-messages`

**Experimental.** This package stays on 0.x until the Python and JavaScript LiteLLM integrations match.

Provider-agnostic LaunchDarkly AI Config handler backed by LiteLLM's in-process
`acompletion` API.

## Installation

```bash
pip install "launchdarkly-ai-server[ld]" launchdarkly-ai-litellm-messages
```

Python uses LiteLLM in-process; no proxy endpoint is required. Set the provider
credentials required by the models in your AI Config, such as
`OPENAI_API_KEY` or `ANTHROPIC_API_KEY`. Standard LiteLLM configuration,
gateways, and model aliases are supported.

To route every call through a specific endpoint or key instead (for example a
LiteLLM proxy), pass `base_url` / `api_key` to `create_litellm_messages_handler`.
These come from your code, never from the AI Config's `model.parameters` — an
AI Config variation cannot redirect the request.

## Usage

```python
from launchdarkly_ai_litellm_messages import create_litellm_messages_handler
from launchdarkly_ai_server import config

result = await config(
    key="assistant",
    handler=create_litellm_messages_handler(),
).invoke("Hello", {"kind": "user", "key": "user-123"})
```

The evaluated AI Config model name is passed directly to LiteLLM, so standard
LiteLLM model prefixes, gateways, and aliases are supported. The one rewrite is
for Bedrock: a `bedrock/...` name, or a bare name when the provider is Bedrock,
gets `model.region` (`us`, `global`, ...) prepended to the model id as its
cross-region inference-profile prefix, unless the id already has one. A name
containing an ARN is sent as configured. Tool calls,
structured output, multimodal history, and streaming are supported without
constructing a provider-native client.

Because this is a wildcard messages handler, do not register it together with
another `["*", "messages"]` handler such as LangChain in the same registry.
