{"record":{"id":"0ead195875f930bf","repo":"BerriAI/litellm","slug":"response-from-opik-api-status-code-response-stat","errorCode":null,"errorMessage":"Response from opik API status_code: {response.status_code}, text: {response.text}","messagePattern":"Response from opik API status_code: (.+?), text: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"warning","filePath":"litellm/integrations/opik/opik.py","lineNumber":175,"sourceCode":"                    \"OpikLogger added event to log_queue - Will flush in %s seconds...\", self.flush_interval\n                )\n\n                if len(self.log_queue) >= self.batch_size:\n                    verbose_logger.debug(\"OpikLogger - Flushing batch\")\n                    await self.flush_queue()\n        except Exception as e:\n            verbose_logger.exception(\"OpikLogger failed to log success event - %s\\n%s\", e, traceback.format_exc())\n\n    def _sync_send(self, url: str, headers: dict[str, str], batch: dict[str, Any]) -> None:\n        try:\n            response: Final = self.sync_httpx_client.post(\n                url=url,\n                headers=headers,\n                json=batch,\n            )\n            response.raise_for_status()\n            if response.status_code != 204:\n                raise Exception(f\"Response from opik API status_code: {response.status_code}, text: {response.text}\")\n        except Exception as e:\n            verbose_logger.exception(\"OpikLogger failed to send batch - %s\\n%s\", e, traceback.format_exc())\n\n    def log_success_event(\n        self,\n        kwargs: dict[str, Any],\n        response_obj: Any,\n        start_time: datetime,\n        end_time: datetime,\n    ) -> None:\n        try:\n            if _should_skip_event(kwargs):\n                return\n\n            # Build payload using the payload builder\n            trace_payload, span_payload = opik_payload_builder.build_opik_payload(\n                kwargs=kwargs,\n                response_obj=response_obj,","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/opik/opik.py#L157-L193","documentation":"OpikLogger._sync_send POSTs a batch of span data to the Opik API and calls response.raise_for_status(), then additionally requires the response to be exactly 204 No Content — any other 2xx code raises Exception('Response from opik API status_code: ..., text: ...'). The outer except immediately catches it and records it via verbose_logger.exception('OpikLogger failed to send batch'), so it never propagates to the caller: it is an observability/log-line error, and the LLM request itself is unaffected.","triggerScenarios":"A successful Opik HTTP response with an unexpected status — e.g. 200/201/202 returning a body where the client contract expects 204 — typically caused by an endpoint mismatch (OPIK_URL_OVERRIDE pointing at a different Opik version or an incompatible path), a gateway/proxy that rewrites responses, or non-2xx raise_for_status failures logged through the same handler. Visible in verbose logs after LLM calls when Opik tracing is enabled.","commonSituations":"Self-hosted Opik (Comet) whose version returns a JSON body with 200 on batch ingest; reverse proxies (nginx, service meshes) injecting responses; OPIK_URL_OVERRIDE typos hitting the wrong route; version drift between litellm's Opik client expectations and the deployed Opik backend; workspace/API-key misconfigurations that produce error bodies instead of 204.","solutions":["Enable verbose/DEBUG logging and read the full logged exception — it includes the status code and response text from Opik, which identifies auth vs routing vs backend-version issues","Verify OPIK_URL_OVERRIDE points at the correct Opik deployment base URL and that OPIK_API_KEY/OPIK_WORKSPACE_ID are valid for it","Align versions: upgrade litellm (or pin an Opik backend version known compatible) so the batch endpoint returns the expected 204","If the response text shows auth errors, rotate/re-set the Opik credentials in the deployment env"],"exampleFix":"# before\nOPIK_URL_OVERRIDE=https://opik.myco.com/wrong/path\n# after\nOPIK_URL_OVERRIDE=https://opik.myco.com\n# plus: pip install -U litellm to match the Opik API contract","handlingStrategy":"validation","validationCode":"import os, httpx\n\nbase = os.getenv('OPIK_URL_OVERRIDE', 'https://www.comet.com/opik/api').rstrip('/')\nkey = os.environ.get('OPIK_API_KEY')\nif key:\n    r = httpx.get(f'{base}/check-readiness', timeout=10)  # cheap liveness/auth probe\n    if r.status_code >= 400:\n        raise SystemExit(f'Opik endpoint unhealthy or misconfigured: {r.status_code}')","typeGuard":null,"tryCatchPattern":"# The logger already swallows and logs this via verbose_logger.exception.\n# Guard at the observability layer instead:\nimport logging\nh = logging.getLogger('LiteLLM')\nh.addHandler(AlertOnSubstringHandler(substring='OpikLogger failed to send batch'))","preventionTips":["Run a readiness probe against your Opik deployment before enabling the callback","Pin litellm and your Opik backend to a tested-compatible version pair","Alert on 'OpikLogger failed to send batch' log lines — each is silently dropped trace data","Avoid response-rewriting proxies in front of Opik; pass the API through unchanged"],"tags":["opik","logging-callback","api-response","http-status","observability"],"backgroundTag":"unexpected-api-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}