{"record":{"id":"69ed1dbee632952d","repo":"BerriAI/litellm","slug":"posthog-credentials-not-found-in-kwargs","errorCode":null,"errorMessage":"PostHog credentials not found in kwargs","messagePattern":"PostHog credentials not found in kwargs","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/integrations/posthog.py","lineNumber":84,"sourceCode":"            self.flush_lock = None\n            self.log_queue = []\n\n            # Register cleanup handler to flush internal queue on exit\n            atexit.register(self._flush_on_exit)\n\n            super().__init__(**kwargs, flush_lock=None, batch_size=POSTHOG_MAX_BATCH_SIZE)\n\n        except Exception as e:\n            verbose_logger.exception(\"PostHog: Got exception on init PostHog client %s\", e)\n            raise e\n\n    def log_success_event(self, kwargs, response_obj, start_time, end_time):\n        try:\n            verbose_logger.debug(\"PostHog: Sync logging - Enters logging function for model %s\", kwargs)\n\n            api_key, api_url = self._get_credentials_for_request(kwargs)\n            if api_key is None or api_url is None:\n                raise Exception(\"PostHog credentials not found in kwargs\")\n            event_payload: Final = self.create_posthog_event_payload(kwargs)\n\n            headers: Final = {\n                \"Content-Type\": \"application/json\",\n            }\n\n            payload: Final = self._create_posthog_payload([event_payload], api_key)\n            capture_url: Final = f\"{api_url.rstrip('/')}/batch/\"\n\n            response: Final = self.sync_client.post(\n                url=capture_url,\n                content=safe_dumps(payload),\n                headers=headers,\n            )\n            response.raise_for_status()\n\n            if response.status_code != 200:\n                raise Exception(f\"Response from PostHog API status_code: {response.status_code}, text: {response.text}\")","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/posthog.py#L66-L102","documentation":"Error \"PostHog credentials not found in kwargs\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/integrations/posthog.py:84 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass PostHog credentials (api key/host) in the logging kwargs or environment."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}