BerriAI/litellm · error · ValueError

Prompt ' ' not found in prompt directory

Error message

Prompt '{prompt_id}'{version_str} not found in prompt directory

What it means

After resolving prompt_id, DotpromptManager calls self.prompt_manager.get_prompt(prompt_id, version=prompt_version); a None template means no matching prompt was found in the configured directory/prompt_data, and it raises ValueError naming the prompt and (if given) the version. The prompt sources are: <prompt_directory>/<prompt_id>.prompt files or in-memory prompt_data entries.

Solutions

  1. Confirm the file exists at <prompt_directory>/<prompt_id>.prompt exactly matching the ID and extension
  2. If a version is requested, verify that version exists (or drop prompt_version to fall back to base)
  3. Print the resolved prompt_directory at startup and fix typos/paths; prefer absolute paths in containers
  4. For prompt_data sources, verify the data dict actually contains the prompt_id key

Example fix

# before
litellm.global_prompt_directory = "./promts"   # typo: no such dir
litellm.completion(model="dotprompt/greeting")    # ValueError: 'greeting' not found

# after
import os
litellm.global_prompt_directory = os.path.abspath("./prompts")
assert os.path.exists(os.path.join(litellm.global_prompt_directory, "greeting.prompt"))
litellm.completion(model="dotprompt/greeting")
Defensive patterns

Strategy: validation

Validate before calling

import os

def prompt_exists(prompt_directory: str, prompt_id: str, version: int | None = None) -> bool:
    candidates = [f"{prompt_id}.v{version}.prompt"] if version else []
    candidates.append(f"{prompt_id}.prompt")
    return any(os.path.isfile(os.path.join(prompt_directory, c)) for c in candidates)

Type guard

from typing import Any

def is_resolvable_prompt(manager: Any, prompt_id: str, version: int | None = None) -> bool:
    """True when the manager's store actually contains the prompt."""
    try:
        return manager.get_prompt(prompt_id=prompt_id, version=version) is not None
    except Exception:
        return False

Try / catch

try:
    client = manager.compile_prompt_helper(prompt_id, prompt_variables, dynamic_callback_params)
except ValueError as e:
    if "not found in prompt directory" in str(e):
        raise KeyError(f"missing prompt file for {prompt_id!r}; check prompt_directory and versions") from e
    raise

Prevention

When it happens

Trigger: File my_prompt.prompt absent from the configured directory; requesting version=3 when only the base prompt or version 2 exists; prompt_directory pointing at the wrong path (typo, relative path resolved from a different cwd); ID/file-name mismatch (file saved as my-prompt.prompt but requested as my_prompt).

Common situations: Deployments where the prompts directory isn't shipped into the container; prompts renamed during refactors; version pinning in config drifting from available versions; relative paths breaking under different working directories.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/7b3daf50191d672f. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/dotprompt/dotprompt_manager.py:131

        """
        Compile a .prompt file into a PromptManagementClient structure.

        This method:
        1. Loads the prompt template from the .prompt file (with optional version)
        2. Renders it with the provided variables
        3. Converts the rendered text into chat messages
        4. Extracts model and optional parameters from metadata
        """

        if prompt_id is None:
            raise ValueError("prompt_id is required for dotprompt manager")

        try:
            # Get the prompt template (versioned or base)
            template: Final = self.prompt_manager.get_prompt(prompt_id=prompt_id, version=prompt_version)
            if template is None:
                version_str: Final = f" (version {prompt_version})" if prompt_version else ""
                raise ValueError(f"Prompt '{prompt_id}'{version_str} not found in prompt directory")

            # Render the template with variables (pass version for proper lookup)
            rendered_content: Final = self.prompt_manager.render(
                prompt_id=prompt_id,
                prompt_variables=prompt_variables,
                version=prompt_version,
            )

            # Convert rendered content to chat messages
            messages: Final = self._convert_to_messages(rendered_content)

            # Extract model from metadata (if specified)
            template_model: Final = template.model

            # Extract optional parameters from metadata
            optional_params: Final = self._extract_optional_params(template)

            return PromptManagementClient(

View on GitHub (pinned to 77b7c6c40c)