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 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.
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.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| launchdarkly_ai_claude_messages-0.2.2.tar.gz | 30.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| launchdarkly_ai_claude_messages-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.7 kB
Release files / launchdarkly_ai_claude_messages-0.2.2.tar.gz
| Download URL | launchdarkly_ai_claude_messages-0.2.2.tar.gz |
|---|---|
| Size | 30.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a7c1f1c604f23698a5e67c83dd94cc8ec15eba6847f739712b365d7740b1078
|
|
BLAKE2b-256 checksum How to use checksums |
cdc695872a0727328784ce352a8eeb7675fa41b07bfb3728b2fabb486da3e4ff
|
| 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.2.2-py3-none-any.whl
| Download URL | launchdarkly_ai_claude_messages-0.2.2-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c0b3e48be875b43e1337432166f6555ff1738e837d5fdc01a807b779da05be76
|
|
BLAKE2b-256 checksum How to use checksums |
c0efbb6ffec9857a2642a4041147c4ee7d9daa62d247aad48fcef041f4050b0e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|