{"record":{"id":"db125f9c462cc759","repo":"BerriAI/litellm","slug":"missing-prometheus-client-run-pip-install-promet","errorCode":null,"errorMessage":"Missing prometheus_client. Run `pip install prometheus-client`","messagePattern":"Missing prometheus_client\\. Run `pip install prometheus-client`","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/prometheus_services.py","lineNumber":35,"sourceCode":"\nFAILED_REQUESTS_LABELS: Final = [\"error_class\", \"function_name\"]\n\n\nclass PrometheusServicesLogger:\n    # Class variables or attributes\n    litellm_service_latency = None  # Class-level attribute to store the Histogram\n\n    def __init__(\n        self,\n        mock_testing: bool = False,\n        **kwargs,\n    ):\n        try:\n            try:\n                from prometheus_client import REGISTRY, Counter, Gauge, Histogram\n                from prometheus_client.gc_collector import Collector\n            except ImportError:\n                raise Exception(\"Missing prometheus_client. Run `pip install prometheus-client`\")\n\n            _custom_buckets: Final = litellm.prometheus_latency_buckets\n            self.latency_buckets = tuple(_custom_buckets) if _custom_buckets is not None else LATENCY_BUCKETS\n\n            self.Histogram = Histogram\n            self.Counter = Counter\n            self.Gauge = Gauge\n            self.REGISTRY = REGISTRY\n\n            verbose_logger.debug(\"in init prometheus services metrics\")\n\n            self.payload_to_prometheus_map: dict[str, list[Histogram | Counter | Gauge | Collector]] = {}\n\n            for service in ServiceTypes:\n                service_metrics: list[Histogram | Counter | Gauge | Collector] = []\n\n                metrics_to_initialize = self._get_service_metrics_initialize(service)\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/prometheus_services.py#L17-L53","documentation":"PrometheusServices.__init__ imports prometheus_client (Counter/Gauge/Histogram/REGISTRY plus gc_collector.Collector); on ImportError it converts to this Exception with the pip hint. litellm's core install does not hard-require prometheus-client — it ships in the [proxy] extra — so enabling prometheus callbacks on a bare install fails at callback construction with exactly this message.","triggerScenarios":"pip install litellm (no extras) then configuring success_callback: ['prometheus'] or any prometheus metrics feature; slim Docker images that pruned 'optional' dependencies; a venv where prometheus-client was uninstalled during a cleanup.","commonSituations":"CI or production images built from requirements.txt listing only litellm; local venvs reused after dependency pruning; upgrading litellm without reinstalling extras.","solutions":["pip install prometheus-client in the same environment that runs litellm","Or install the bundle: pip install 'litellm[proxy]' which includes prometheus-client","Rebuild the Docker image with the extra and confirm with python -c \"import prometheus_client\"","If metrics are unwanted, remove the prometheus callback from config instead of shipping the dependency"],"exampleFix":"# before\npip install litellm\n# proxy config: success_callback: ['prometheus'] -> Exception: Missing prometheus_client\n\n# after\npip install 'litellm[proxy]'\n# or: pip install litellm prometheus-client","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec('prometheus_client') is None:\n    raise RuntimeError('prometheus-client required for prometheus metrics: pip install prometheus-client')","typeGuard":null,"tryCatchPattern":"try:\n    from litellm.integrations.prometheus_services import PrometheusServices\n    services = PrometheusServices()\nexcept Exception as e:\n    logger.warning('prometheus metrics disabled: %s', e)\n    services = None","preventionTips":["Install litellm[proxy] (or add prometheus-client) wherever metrics are enabled","Add an import smoke test for prometheus_client to your image build","Keep dependency extras in version control with the litellm pin"],"tags":["prometheus","missing-dependency","installation","callback"],"backgroundTag":"missing-dependency","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}