Skip to main content

launchdarkly-ai-claude-messages

Anthropic Claude handler for launchdarkly-ai-server using the Anthropic Messages API (anthropic). Runs a manual tool-use loop without the Claude Agent SDK layer.

provides_for: ['Anthropic', 'messages'] — matches flag variations where provider.name is "Anthropic" and meta.mode is "messages".

Installation

pip install launchdarkly-ai-server launchdarkly-ai-claude-messages

Set ANTHROPIC_API_KEY in your environment (the Anthropic SDK reads it automatically).

Usage

With config()

import asyncio
from launchdarkly_ai_server import config, shutdown
from launchdarkly_ai_claude_messages import create_claude_messages_handler

async def main():
    result = await config(
        key="my-ai-config-flag",
        handler=create_claude_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_claude_messages import claude_messages

async def main():
    user_input = "What is feature flagging?"
    result = await claude_messages(
        user_input,
        {"kind": "user", "key": "user-123"},
        {"key": "my-ai-config-flag"},
        variables={"user_input": user_input},
    )
    print(result.response)

asyncio.run(main())

How It Works

  • Uses the system prompt and conversation history 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.

Choosing Between claude-agents and claude-messages

claude-agents claude-messages
Underlying SDK claude-agent-sdk anthropic
Tool loop Managed by the Claude Agent SDK Executed and fed back manually
Complexity Lower (SDK manages loop) More explicit control

Environment Variables

Variable Description
ANTHROPIC_API_KEY Anthropic API key (read automatically by the Anthropic 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-claude-messages 0.3.0

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-claude-messages 0.3.0
File Size Uploaded Provenance Actions
launchdarkly_ai_claude_messages-0.3.0.tar.gz 42.9 kB Without provenance Details for launchdarkly_ai_claude_messages-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for launchdarkly-ai-claude-messages 0.3.0
File Interpreter ABI Platform Actions
launchdarkly_ai_claude_messages-0.3.0-py3-none-any.whl Python 3 none any Details for launchdarkly_ai_claude_messages-0.3.0-py3-none-any.whl

Total release size: 61.4 kB

Release files / launchdarkly_ai_claude_messages-0.3.0.tar.gz

Download URL launchdarkly_ai_claude_messages-0.3.0.tar.gz
Size 42.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d9a37d5fb0e9aba032d7c36854123eb360d2bc1233a78aadee8ccc691de065bd
BLAKE2b-256 checksum
How to use checksums
ef55e877a40f8bfe53fd215bceccd6fa558769c786c9e3570a90ea81358471a0
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_claude_messages-0.3.0-py3-none-any.whl

Download URL launchdarkly_ai_claude_messages-0.3.0-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9bd6e46f56f9efbbe8415f8016dfb814549a16ba096ea9e84beed6b95d4235ed
BLAKE2b-256 checksum
How to use checksums
27b071adad0a5027ba557b48a4494d98ea512b198a8fe98d33a0a059b3a327db
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-claude-messages 0.3.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.

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