Skip to content

Prompt management: support fetching multiple prompts in a single call (batch fetch) #4353

Description

@darkopia

Summary

The prompt management SDK (@posthog/ai, and posthog-python) currently only supports fetching one prompt at a time via prompts.get(name). Retrieving N prompts means N separate calls. Add a way to fetch multiple prompts in a single request.

Why

Requested by a customer using @posthog/ai who is loading several prompts and would like to fetch them together rather than issuing one request per prompt. They noted this would be an improvement over competing tools (Langfuse doesn't offer batch fetching either), so it's a potential differentiator.

Benefits:

  • Fewer round trips when an app depends on multiple prompts
  • Simpler consuming code (no need to Promise.all a set of individual get() calls)
  • Shared client-side cache across the batch

Proposed shape

Something like a batch method that returns multiple compiled prompts in one call, keeping the existing single get() backwards-compatible:

const prompts = await client.prompts.getMany(['welcome', 'summary', 'followup'])
// prompts.welcome, prompts.summary, prompts.followup

Exact API/naming open to design — an array/comma-separated name param on a new method would work. Should reuse the existing caching and fallback behaviour.

Context

Raised via a support ticket about the newly released prompt configuration feature.


Created with PostHog from a Slack thread

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions