launchdarkly-ai-openai-messages
OpenAI handler for launchdarkly-ai-server using the OpenAI Responses API (openai). Runs a manual function-call loop directly against the Responses API.
provides_for: ['OpenAI', 'messages'] — matches flag variations where provider.name is "OpenAI" and meta.mode is "messages".
Installation
pip install "launchdarkly-ai-server[ld]" launchdarkly-ai-openai-messages
Set OPENAI_API_KEY in your environment (the OpenAI SDK reads it automatically).
Usage
With config()
import asyncio
from launchdarkly_ai_server import config, shutdown
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(),
tool_handlers={"search": lambda q: "..."},
).invoke("What is feature flagging?", {"kind": "user", "key": "user-123"})
print(result.response)
await shutdown()
asyncio.run(main())
Convenience wrapper
import asyncio
from launchdarkly_ai_openai_messages import openai_messages
async def main():
user_input = "What is feature flagging?"
result = await openai_messages(
"my-ai-config-flag",
user_input,
{"kind": "user", "key": "user-123"},
)
print(result.response)
asyncio.run(main())
How It Works
- Uses the system prompt defined in your LaunchDarkly flag config.
- Template placeholders (
{{variable}}) in the prompt are substituted usingvariablesbefore the call. - If tools are defined in the flag config, executes them as the model requests and feeds results back until the model produces a final response.
- Emits an OTel span and LaunchDarkly telemetry for every call.
Environment Variables
| Variable | Description |
|---|---|
OPENAI_API_KEY |
OpenAI API key (read automatically by the OpenAI SDK) |
LD_SDK_KEY |
LaunchDarkly server-side SDK key |
LD_SERVICE_NAME |
OTel service.name resource attribute (default: python-sdk) |
LD_ENVIRONMENT |
deployment.environment attribute attached to telemetry |
OTEL_EXPORTER_OTLP_ENDPOINT |
OTLP endpoint override (default: LaunchDarkly Observability backend) |
Metadata
Release files for launchdarkly-ai-openai-messages 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| launchdarkly_ai_openai_messages-1.0.0.tar.gz | 42.3 kB | Without provenance | Details for launchdarkly_ai_openai_messages-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| launchdarkly_ai_openai_messages-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for launchdarkly_ai_openai_messages-1.0.0-py3-none-any.whl |
Total release size: 60.3 kB
Release files / launchdarkly_ai_openai_messages-1.0.0.tar.gz
| Download URL | launchdarkly_ai_openai_messages-1.0.0.tar.gz |
|---|---|
| Size | 42.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c79916735853ac86c5297174ba5d0249ad4462eeeccdbad6354c450a53c2b71e
|
|
BLAKE2b-256 checksum How to use checksums |
fb35d8e3629dffca2da72cee45b8f356b2711e2696ac7c8c7d0f64bc09b917e2
|
| 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_openai_messages-1.0.0-py3-none-any.whl
| Download URL | launchdarkly_ai_openai_messages-1.0.0-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f5f2cdf6a694a232fe357af8f97ee5337cd320bfefafbc0496eb963f41ea9c7c
|
|
BLAKE2b-256 checksum How to use checksums |
57995836156659aa434877bd8b4c7440193d00255be79e331c81f3cae628ca61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for launchdarkly-ai-openai-messages 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.