Langfuse JS/TS SDKs
    Preparing search index...

    Manager for prompt operations in Langfuse.

    Provides methods to create, retrieve, and manage prompts with built-in caching for optimal performance. Supports both text and chat prompts with variable substitution and placeholder functionality.

    Index

    Constructors

    Accessors

    Methods

    Constructors

    • Internal

      Creates a new PromptManager instance.

      Parameters

      • params: { apiClient: LangfuseAPIClient }

        Configuration object containing the API client

      Returns PromptManager

    Accessors

    • get logger(): Logger

      Returns Logger

    Methods

    • Creates a new prompt in Langfuse.

      Parameters

      Returns Promise<ChatPromptClient>

      Promise that resolves to a ChatPromptClient

    • Creates a new prompt in Langfuse.

      Parameters

      • body: Omit<Text, "type"> & { type?: "text" }

        The prompt data to create (text prompt)

      Returns Promise<TextPromptClient>

      Promise that resolves to a TextPromptClient

    • Creates a new prompt in Langfuse.

      Parameters

      • body: Chat

        The prompt data to create (chat prompt)

      Returns Promise<ChatPromptClient>

      Promise that resolves to a ChatPromptClient

    • Retrieves a text prompt by name.

      Parameters

      • name: string

        Name of the prompt to retrieve

      • Optionaloptions: {
            cacheTtlSeconds?: number;
            fallback?: string;
            fetchTimeoutMs?: number;
            label?: string;
            maxRetries?: number;
            type?: "text";
            version?: number;
        }

        Optional retrieval configuration

        • OptionalcacheTtlSeconds?: number

          Cache TTL in seconds (0 to disable caching)

        • Optionalfallback?: string

          Fallback text content if prompt fetch fails

        • OptionalfetchTimeoutMs?: number

          Request timeout in milliseconds

        • Optionallabel?: string

          Label to filter by

        • OptionalmaxRetries?: number

          Maximum retry attempts for failed requests

        • Optionaltype?: "text"

          Specify text prompt type

        • Optionalversion?: number

          Specific version to retrieve (defaults to latest)

      Returns Promise<TextPromptClient>

      Promise that resolves to a TextPromptClient

    • Retrieves a chat prompt by name.

      Parameters

      • name: string

        Name of the prompt to retrieve

      • Optionaloptions: {
            cacheTtlSeconds?: number;
            fallback?: ChatMessage[];
            fetchTimeoutMs?: number;
            label?: string;
            maxRetries?: number;
            type: "chat";
            version?: number;
        }

        Optional retrieval configuration

        • OptionalcacheTtlSeconds?: number

          Cache TTL in seconds (0 to disable caching)

        • Optionalfallback?: ChatMessage[]

          Fallback chat messages if prompt fetch fails

        • OptionalfetchTimeoutMs?: number

          Request timeout in milliseconds

        • Optionallabel?: string

          Label to filter by

        • OptionalmaxRetries?: number

          Maximum retry attempts for failed requests

        • type: "chat"

          Specify chat prompt type

        • Optionalversion?: number

          Specific version to retrieve (defaults to latest)

      Returns Promise<ChatPromptClient>

      Promise that resolves to a ChatPromptClient

    • Updates the labels of an existing prompt version.

      Parameters

      • params: { name: string; newLabels: string[]; version: number }

        Update parameters

        • name: string

          Name of the prompt to update

        • newLabels: string[]

          New labels to apply to the prompt version

        • version: number

          Version number of the prompt to update

      Returns Promise<Prompt>

      Promise that resolves to the updated prompt

      const updatedPrompt = await langfuse.prompt.update({
      name: "my-prompt",
      version: 1,
      newLabels: ["production", "v2"]
      });