Skip to main content
PromptLayer fits into your stack at four levels of sophistication:
  1. promptlayer_client.run – zero-setup SDK sugar
  2. Webhook-driven caching – maintain local cache of prompt templates
  3. GitOps with Webhooks – keep Git as your source of truth with bi-directional sync
  4. Managed Agents – let PromptLayer orchestrate everything server-side
PromptLayer Deployment Strategies

Use promptlayer_client.run (quickest path)

When every millisecond of developer time counts, call promptlayer_client.run() directly from your application code.
  1. Fetch latest prompt – We pull the template (by version or release label) from PromptLayer.
  2. Execute – The SDK sends the populated prompt to OpenAI, Anthropic, Gemini, etc.
  3. Log – The raw request/response pair is saved back to PromptLayer.
from promptlayer import PromptLayer
pl_client = PromptLayer(api_key="...")

response = pl_client.run(
    prompt_name="order-summary",
    input_variables={"cart": cart_items},
    prompt_release_label="prod"
)
Under the hood
  1. SDK pulls the latest prompt (or the version/label you specify).
  2. Your client calls the model provider (OpenAI, Anthropic, Gemini, …).
  3. SDK writes the log back to PromptLayer.
💡 Tip – If latency is critical, enqueue the log to a background worker and let your request return immediately.

Cache prompts with Webhooks

Eliminate the extra round‑trip by replicating prompts into your own cache or database. PromptLayer keeps that cache fresh through webhook events—no polling required.

Step‑by‑step

  1. Subscribe to webhooks in the UI
Read more here about webhooks here.
  1. Maintain a local cache
# pseudocode
def handle_pl_webhook(event):
    prompt = event["data"]
    db.prompts.upsert(prompt["prompt_template_name"], prompt)
  1. Serve traffic
prompt = db.prompts.get("order-summary")
llm_response = openai.chat.completions.create(...)
queue.enqueue(track_to_promptlayer, llm_response)
Tip: Most teams push the track_to_promptlayer onto a Redis or SQS queue so as to not block on the logging of a request.
Read the full guide: PromptLayer Webhooks ↗

GitOps with Webhooks

For teams that want Git as the source of truth for prompts, webhooks enable a full bi-directional sync between PromptLayer and your repository. This is the recommended pattern for teams with existing CI/CD pipelines (GitHub Actions, GitLab CI, etc.) that want prompt changes to go through the same review and deploy process as code changes.

Change starts on PromptLayer

When someone edits a prompt or approves a release label in PromptLayer, a webhook fires to your system. Your webhook handler creates a merge request (or pull request) in your repo with the updated prompt. From there, your normal CI/CD pipeline takes over — code review, automated evals, deploy. Key webhook events for this flow:
  • prompt_template_version_created – a new version of a prompt was saved
  • prompt_template_label_moved – a release label (e.g. prod) was moved to a new version
  • prompt_template_label_change_approved – a protected release label change was approved
See the full list of events in the Webhooks docs.

Change starts in code

When an engineer updates a prompt directly in the repo, your CI/CD pipeline can publish it back to PromptLayer using the REST API or SDK. This keeps PromptLayer in sync without any manual steps.
from promptlayer import PromptLayer
pl_client = PromptLayer(api_key="...")

# In your CI/CD pipeline after prompt file changes
pl_client.templates.publish(
    prompt_name="order-summary",
    prompt_template="Your updated prompt template here",
)

Closing the loop with eval results

If your CI/CD pipeline runs evaluations as part of the deploy process, you can push those results back to PromptLayer so everything is visible in one place. This means your team doesn’t lose observability just because the deploy happened outside of PromptLayer.
💡 Tip – Combine this with protected release labels and approval workflows so that a prompt change in PromptLayer requires approval before the webhook fires and the MR is created.

Run fully-managed Agents

For complex workflows requiring orchestration, use PromptLayer’s managed agent infrastructure.

How it works

  1. Define multi-step workflows in PromptLayer’s Agent Builder
  2. Trigger agent execution via API
  3. Monitor execution on PromptLayer servers
  4. Receive results via webhook or polling
PromptLayer handles all orchestration, parallelization, and model provider communication.

Implementation

from promptlayer import PromptLayer
promptlayer_client = PromptLayer(api_key="…")

execution = promptlayer_client.run_workflow(  # SDK method
    workflow_name="customer_support_agent",   # <- this is an Agent
    workflow_label_name="prod",
    input_variables={"ticket_id": 123}
)
Because execution is server-side, you inherit centralized tracing, cost analytics, and secure sandboxed tool-nodes without extra ops. Learn more: Agents documentation ↗

Which pattern should I pick?

Requirementpromptlayer_client.runWebhook CacheGitOpsManaged Agent
⏱️ extreme latency reqs
🛠 Single LLM call
🌩 Complex plans / tools
👥 Non-eng prompt editors
🧰 Zero ops overhead
🔀 Git as source of truth
🔁 Bi-directional sync

Further reading 📚


✉️ Need a hand? Ping us in Discord or email hello@promptlayer.com—happy to chat architecture!