{"record":{"id":"55c6dc4bfdeb5283","repo":"headroomlabs-ai/headroom","slug":"openai-package-required-for-prompt-comparison-ins","errorCode":null,"errorMessage":"OpenAI package required for prompt comparison. Install with: pip install openai","messagePattern":"OpenAI package required for prompt comparison\\. Install with: pip install openai","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"headroom/evals/prompt_comparison.py","lineNumber":250,"sourceCode":"    Returns:\n        PromptComparisonResult with the comparison outcome.\n\n    Raises:\n        ImportError: If openai package is not installed.\n        ValueError: If API key is not provided and not in environment.\n\n    Example:\n        result = compare_prompts(\n            original_prompt=\"Explain quantum computing in simple terms.\",\n            headroom_modified_prompt=\"Explain quantum computing in simple terms.\",\n        )\n        if not result.are_equivalent:\n            print(f\"WARNING: Prompts differ! {result.differences}\")\n    \"\"\"\n    try:\n        from openai import OpenAI\n    except ImportError as e:\n        raise ImportError(\n            \"OpenAI package required for prompt comparison. Install with: pip install openai\"\n        ) from e\n\n    # Get API key\n    resolved_api_key = api_key or os.environ.get(\"OPENAI_API_KEY\")\n    if not resolved_api_key:\n        raise ValueError(\n            \"OpenAI API key required. Set OPENAI_API_KEY environment variable \"\n            \"or pass api_key parameter.\"\n        )\n\n    client = OpenAI(api_key=resolved_api_key)\n\n    # Build the judge prompt\n    judge_prompt = SEMANTIC_EQUIVALENCE_JUDGE_PROMPT.format(\n        original_prompt=original_prompt,\n        modified_prompt=headroom_modified_prompt,\n    )","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/evals/prompt_comparison.py#L232-L268","documentation":"Error \"OpenAI package required for prompt comparison. Install with: pip install openai\" thrown in headroomlabs-ai/headroom.","triggerScenarios":"Raised when the prompt-comparison eval is configured to use an OpenAI model but the `openai` package is not installed.","commonSituations":"See trigger scenarios.","solutions":["Install the OpenAI package: pip install openai","Or install the evals extra: pip install headroom-ai[evals]"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}