headroomlabs-ai/headroom · error · ImportError

OpenAI package required for prompt comparison. Install with:

Error message

OpenAI package required for prompt comparison. Install with: pip install openai

What it means

Error "OpenAI package required for prompt comparison. Install with: pip install openai" thrown in headroomlabs-ai/headroom.

Source

Thrown at headroom/evals/prompt_comparison.py:250

    Returns:
        PromptComparisonResult with the comparison outcome.

    Raises:
        ImportError: If openai package is not installed.
        ValueError: If API key is not provided and not in environment.

    Example:
        result = compare_prompts(
            original_prompt="Explain quantum computing in simple terms.",
            headroom_modified_prompt="Explain quantum computing in simple terms.",
        )
        if not result.are_equivalent:
            print(f"WARNING: Prompts differ! {result.differences}")
    """
    try:
        from openai import OpenAI
    except ImportError as e:
        raise ImportError(
            "OpenAI package required for prompt comparison. Install with: pip install openai"
        ) from e

    # Get API key
    resolved_api_key = api_key or os.environ.get("OPENAI_API_KEY")
    if not resolved_api_key:
        raise ValueError(
            "OpenAI API key required. Set OPENAI_API_KEY environment variable "
            "or pass api_key parameter."
        )

    client = OpenAI(api_key=resolved_api_key)

    # Build the judge prompt
    judge_prompt = SEMANTIC_EQUIVALENCE_JUDGE_PROMPT.format(
        original_prompt=original_prompt,
        modified_prompt=headroom_modified_prompt,
    )

View on GitHub (pinned to 322425c43b)

Solutions

  1. Install the OpenAI package: pip install openai
  2. Or install the evals extra: pip install headroom-ai[evals]

When it happens

Trigger: Raised when the prompt-comparison eval is configured to use an OpenAI model but the `openai` package is not installed.

Common situations: See trigger scenarios.


AI-assisted analysis of headroomlabs-ai/headroom@322425c43b (2026-08-15). Data as JSON: /api/errors/55c6dc4bfdeb5283. Report an issue: GitHub.