{"record":{"id":"866cd10ad11ca382","repo":"BerriAI/litellm","slug":"openmeter-logging-error-e-response-text","errorCode":null,"errorMessage":"OpenMeter logging error: {e.response.text}","messagePattern":"OpenMeter logging error: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"litellm/integrations/openmeter.py","lineNumber":121,"sourceCode":"        else:\n            _url += \"/api/v1/events\"\n\n        api_key: Final = os.getenv(\"OPENMETER_API_KEY\")\n\n        _data: Final = self._common_logic(kwargs=kwargs, response_obj=response_obj)\n        _headers: Final = {\n            \"Content-Type\": \"application/cloudevents+json\",\n            \"Authorization\": f\"Bearer {api_key}\",\n        }\n\n        try:\n            self.sync_http_handler.post(\n                url=_url,\n                data=json.dumps(_data),\n                headers=_headers,\n            )\n        except httpx.HTTPStatusError as e:\n            raise Exception(f\"OpenMeter logging error: {e.response.text}\")\n        except Exception as e:\n            raise e\n\n    async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):\n        _url = os.getenv(\"OPENMETER_API_ENDPOINT\", \"https://openmeter.cloud\")\n        if _url.endswith(\"/\"):\n            _url += \"api/v1/events\"\n        else:\n            _url += \"/api/v1/events\"\n\n        api_key: Final = os.getenv(\"OPENMETER_API_KEY\")\n\n        _data: Final = self._common_logic(kwargs=kwargs, response_obj=response_obj)\n        _headers: Final = {\n            \"Content-Type\": \"application/cloudevents+json\",\n            \"Authorization\": f\"Bearer {api_key}\",\n        }\n","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/openmeter.py#L103-L139","documentation":"The synchronous OpenMeter event POST returned an HTTP error status (httpx.HTTPStatusError), and the logger re-raises with the response body. Common bodies are auth errors (401 invalid key), 4xx malformed CloudEvent, or 5xx from OpenMeter's cloud.","triggerScenarios":"Expired or rotated OPENMETER_API_KEY (401); OPENMETER_API_ENDPOINT pointing to the wrong host or path handling (404); payload rejected (400) because subject is not a string or event type is invalid; OpenMeter outage (5xx).","commonSituations":"Long-running proxies whose OpenMeter key was rotated but not updated in the env; custom OpenMeter-compatible endpoints (e.g. self-hosted) where the URL scheme differs; transient cloud 502/503s surfacing during bursts.","solutions":["Read the response text embedded in the message: 401 -> refresh OPENMETER_API_KEY; 404 -> fix OPENMETER_API_ENDPOINT (it should be the base URL; litellm appends /api/v1/events); 400 -> inspect the event JSON (subject/type)","Verify connectivity: curl -H 'Authorization: Bearer $OPENMETER_API_KEY' $OPENMETER_API_ENDPOINT/api/v1/events","For 5xx or transient errors, retry or rely on callback failure handling rather than crashing the request path","If self-hosting, confirm your endpoint speaks the CloudEvents HTTP API"],"exampleFix":"# before\nexport OPENMETER_API_ENDPOINT=https://openmeter.mycompany.io  # wrong base -> HTTPStatusError\n\n# after\nexport OPENMETER_API_ENDPOINT=https://openmeter.mycompany.io/\n# and refresh key on 401:\nexport OPENMETER_API_KEY=om-new-key","handlingStrategy":"try-catch","validationCode":"import os, httpx\n\ndef openmeter_reachable() -> bool:\n    base = os.getenv(\"OPENMETER_API_ENDPOINT\", \"https://openmeter.cloud\").rstrip(\"/\")\n    headers = {\"Authorization\": f\"Bearer {os.getenv('OPENMETER_API_KEY', '')}\"}\n    try:\n        r = httpx.get(f\"{base}/api/v1/events\", headers=headers, timeout=5)\n        return r.status_code < 500\n    except httpx.HTTPError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    logger.log_success_event(kwargs, response_obj, start, end)\nexcept Exception as e:\n    if \"OpenMeter logging error\" in str(e):\n        log.warning(\"openmeter export failed: %s\", e)  # never fail the LLM request over telemetry\n    else:\n        raise","preventionTips":["Treat telemetry failures as non-fatal: catch and alert, do not propagate","Rotate keys via env with process restart; alert on 401 bodies"],"tags":["python","openmeter","http","authentication","network"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}