Skip to main content

LaunchPromptly Python SDK — manage, version, and deploy AI prompts

Project description

launchpromptly

Official Python SDK for LaunchPromptly — manage, version, and deploy AI prompts without redeploying your app.

Install

pip install launchpromptly

Quick Start

import asyncio
from launchpromptly import LaunchPromptly

lp = LaunchPromptly(api_key="lp_live_...")

async def main():
    # Fetch a managed prompt (cached, with stale-while-error fallback)
    system_prompt = await lp.prompt("onboarding-assistant", variables={"userName": "Alice"})

    # Use with any LLM provider
    response = await openai.chat.completions.create(
        model="gpt-4o",
        messages=[
            {"role": "system", "content": system_prompt},
            {"role": "user", "content": "How do I reset my password?"},
        ],
    )

asyncio.run(main())

Features

  • Prompt fetchingawait lp.prompt(slug) fetches the active deployed version
  • Template variables{{variable}} placeholders are interpolated at runtime
  • Caching — prompts are cached in-memory with configurable TTL (default 60s) and LRU eviction
  • Stale-while-error — returns expired cache on network failure (404s always throw)
  • Auto-tracking — wrap your OpenAI client to automatically track cost, latency, and tokens
  • Event batching — LLM events are batched and sent asynchronously
  • Context propagationwith lp.context(trace_id=...) propagates context via contextvars
  • Singleton patternLaunchPromptly.init() / LaunchPromptly.shared() for app-wide usage

API

LaunchPromptly(api_key, endpoint, ...)

Parameter Default Description
api_key LAUNCHPROMPTLY_API_KEY env Your LaunchPromptly API key
endpoint https://api.launchpromptly.dev API base URL
prompt_cache_ttl 60.0 Prompt cache TTL in seconds
flush_at 10 Batch size threshold for auto-flush
flush_interval 5.0 Timer interval for auto-flush (seconds)
max_cache_size 1000 Maximum cached prompts (LRU eviction)

await lp.prompt(slug, *, customer_id, variables)

Fetch a managed prompt by slug. Returns the interpolated content string.

content = await lp.prompt("my-prompt", variables={"name": "Alice", "role": "admin"}, customer_id="user-42")

lp.wrap(client, options)

Wrap an OpenAI client to automatically capture LLM events.

from launchpromptly.types import WrapOptions

wrapped = lp.wrap(openai_client, WrapOptions(
    feature="chat",
    trace_id="req-abc-123",
    span_name="generate",
))

with lp.context(trace_id, customer_id, feature, span_name, metadata)

Context manager for request-scoped context propagation via contextvars.

with lp.context(trace_id="req-123", customer_id="user-42"):
    prompt = await lp.prompt("greeting")
    result = await wrapped.chat.completions.create(...)
    # trace_id and customer_id flow to all SDK calls inside this block

Singleton

# Initialize once at app startup
LaunchPromptly.init(api_key="lp_live_...")

# Access anywhere
lp = LaunchPromptly.shared()

await lp.flush() / await lp.shutdown() / lp.destroy()

  • flush() — send all pending events
  • shutdown() — flush then destroy (for graceful server shutdown)
  • destroy() — stop timers and release resources

Environment Variables

Variable Description
LAUNCHPROMPTLY_API_KEY API key (alternative to passing in constructor)
LP_API_KEY Shorthand alias

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

launchpromptly-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

launchpromptly-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file launchpromptly-0.1.0.tar.gz.

File metadata

  • Download URL: launchpromptly-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for launchpromptly-0.1.0.tar.gz
Algorithm Hash digest
SHA256 79d6e34146a9393e06d2de2cb6dd132e410ec712a2554ecc069abec5b5c9a001
MD5 65ace59d00fafa2e2c8510c995f777aa
BLAKE2b-256 53b168845fc81ccae786cd1b88d4ac984298d764dd49c0970efa64a26f504830

See more details on using hashes here.

File details

Details for the file launchpromptly-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: launchpromptly-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for launchpromptly-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 56ff891f39c8bc44defca4ea1f678e39d6d2614a8d3e7704c32081e6d570c81b
MD5 36613c849b0ca68ad346eabfe245d76f
BLAKE2b-256 0df30e3d01204c97389c8f6d140044791a264cb384da63144a36a76e630ac8d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page