Skip to main content

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 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 using variables before 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 0.2.2

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-openai-messages 0.2.2
File Size Uploaded
launchdarkly_ai_openai_messages-0.2.2.tar.gz 29.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for launchdarkly-ai-openai-messages 0.2.2
File Interpreter ABI Platform
launchdarkly_ai_openai_messages-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 43.5 kB

Release files / launchdarkly_ai_openai_messages-0.2.2.tar.gz

Download URL launchdarkly_ai_openai_messages-0.2.2.tar.gz
Size 29.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a25ef8a60e09511bfb3740a867c9d6b54a13cbd107652952800ede28bd275a48
BLAKE2b-256 checksum
How to use checksums
3ac022b5fa76d8a61ad4415ca6094915188f8aeea792f9cbab6b2b74345e923a
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-0.2.2-py3-none-any.whl

Download URL launchdarkly_ai_openai_messages-0.2.2-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34075f40a2483ecc665dc92b7f04d0573e5ca91868c6d6b53ac93240cf0b95fa
BLAKE2b-256 checksum
How to use checksums
eb9f6efb4dae5a0eea8173ff8e1241428cc8e180f9159ef85e5998ee0af28a5c
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.4

2 release files

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.1.4

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