{"record":{"id":"4380766f4d278413","repo":"BerriAI/litellm","slug":"please-set-confident-api-key-in-your-environm","errorCode":null,"errorMessage":"Please set 'CONFIDENT_API_KEY=<>' in your environment variables.","messagePattern":"Please set 'CONFIDENT_API_KEY=<>' in your environment variables\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/deepeval/deepeval.py","lineNumber":30,"sourceCode":"    TraceSpanApiStatus,\n)\nfrom litellm.integrations.deepeval.utils import (\n    to_zod_compatible_iso,\n    validate_environment,\n)\n\n\n# This file includes the custom callbacks for LiteLLM Proxy\n# Once defined, these can be passed in proxy_config.yaml\nclass DeepEvalLogger(CustomLogger):\n    \"\"\"Logs litellm traces to DeepEval's platform.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        api_key: Final = os.getenv(\"CONFIDENT_API_KEY\")\n        self.litellm_environment = os.getenv(\"LITELM_ENVIRONMENT\", \"development\")\n        validate_environment(self.litellm_environment)\n        if not api_key:\n            raise ValueError(\"Please set 'CONFIDENT_API_KEY=<>' in your environment variables.\")\n        self.api = Api(api_key=api_key)\n        super().__init__(*args, **kwargs)\n\n    def log_success_event(self, kwargs, response_obj, start_time, end_time):\n        \"\"\"Logs a success event to DeepEval's platform.\"\"\"\n        self._sync_event_handler(kwargs, response_obj, start_time, end_time, is_success=True)\n\n    def log_failure_event(self, kwargs, response_obj, start_time, end_time):\n        \"\"\"Logs a failure event to DeepEval's platform.\"\"\"\n        self._sync_event_handler(kwargs, response_obj, start_time, end_time, is_success=False)\n\n    async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time):\n        \"\"\"Logs a failure event to DeepEval's platform.\"\"\"\n        await self._async_event_handler(kwargs, response_obj, start_time, end_time, is_success=False)\n\n    async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):\n        \"\"\"Logs a success event to DeepEval's platform.\"\"\"\n        await self._async_event_handler(kwargs, response_obj, start_time, end_time, is_success=True)","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/deepeval/deepeval.py#L12-L48","documentation":"DeepEvalLogger.__init__ reads CONFIDENT_API_KEY from the environment and raises ValueError when absent — before any super().__init__. Because litellm instantiates custom loggers when loading callbacks (proxy config.yaml litellm_settings.callbacks, or callbacks= at import), a missing key fails logger construction and typically aborts proxy startup or callback registration.","triggerScenarios":"litellm_settings: callbacks: [\"deepeval\"] in proxy config without CONFIDENT_API_KEY; direct DeepEvalLogger() instantiation in tests; CI/containers where the secret was not injected; key named differently (DEEPEVAL_API_KEY).","commonSituations":"Local works (key in shell) but deployed container lacks the env; .env file not loaded; secret stored under the official deepeval variable name rather than CONFIDENT_API_KEY.","solutions":["Export CONFIDENT_API_KEY (exact name) in the environment of the process that builds the logger and verify with printenv","For docker/k8s, inject it via env: / Secret and restart","If DeepEval logging is optional, gate the callback on the key's presence in config so startup never hard-fails"],"exampleFix":"# before (config.yaml)\nlitellm_settings:\n  callbacks: [\"deepeval\"]   # startup ValueError without key\n\n# after\nexport CONFIDENT_API_KEY=<key>\n# or gate it programmatically:\nimport os, litellm\nif os.getenv(\"CONFIDENT_API_KEY\"):\n    from litellm.integrations.deepeval import DeepEvalLogger\n    litellm.callbacks = [DeepEvalLogger()]","handlingStrategy":"validation","validationCode":"import os\n\ndef deepeval_configured() -> bool:\n    return bool(os.getenv(\"CONFIDENT_API_KEY\"))\n\n# in startup:\n# if deepeval_configured(): register DeepEvalLogger() else skip (or warn)","typeGuard":null,"tryCatchPattern":"try:\n    from litellm.integrations.deepeval import DeepEvalLogger\n    deepeval_logger = DeepEvalLogger()\nexcept ValueError as e:\n    if \"CONFIDENT_API_KEY\" in str(e):\n        deepeval_logger = None  # degrade to no telemetry, keep service up\n    else:\n        raise","preventionTips":["Gate optional telemetry callbacks on their env var at config time","Inject secrets via the platform (k8s Secret, docker env) and verify with printenv in a smoke test","Name the variable exactly CONFIDENT_API_KEY — not DEEPEVAL_API_KEY"],"tags":["deepeval","env-var","initialization","proxy-startup","configuration"],"backgroundTag":"missing-env-var","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}