BerriAI/litellm · error · ImportError

OpenTelemetry OTLP HTTP exporter is not available. Install…

Error message

OpenTelemetry OTLP HTTP exporter is not available. Install `opentelemetry-exporter-otlp` to enable OTLP HTTP.

What it means

When the OpenTelemetry callback is configured with exporter otlp_http (or the OTLP-spec aliases http/protobuf, http/json), it lazily imports the OTLP HTTP span exporter from opentelemetry.exporter.otlp.proto.http.trace_exporter inside a try block. If the opentelemetry-exporter-otlp distribution is not installed, the ImportError is caught and re-raised with a prescriptive message telling you to install opentelemetry-exporter-otlp. The chained original ImportError is preserved via raise ... from exc.

Solutions

  1. Install the exporter package into the runtime image/venv: pip install opentelemetry-exporter-otlp (or add it to requirements)
  2. Alternatively switch to console exporter while iterating: OTEL_EXPORTER=console — no extra dependency needed
  3. Rebuild/redeploy the image and restart so the callback reconstructs its exporter
  4. Pin consistent versions of opentelemetry-sdk and opentelemetry-exporter-otlp to avoid mixed OTel version sets

Example fix

# before
# OTEL_EXPORTER=otlp_http with only: pip install litellm
# -> ImportError at callback init

# after
pip install litellm opentelemetry-exporter-otlp
# OTEL_EXPORTER=otlp_http now builds BatchSpanProcessor(OTLPSpanExporterHTTP)
Defensive patterns

Strategy: validation

Validate before calling

import importlib.util, os

if os.getenv('OTEL_EXPORTER', 'console') in ('otlp_http', 'http/protobuf', 'http/json'):
    if importlib.util.find_spec('opentelemetry.exporter.otlp.proto.http.trace_exporter') is None:
        raise SystemExit('OTEL_EXPORTER=otlp_http requires: pip install opentelemetry-exporter-otlp')

Try / catch

try:
    from litellm.integrations.opentelemetry import OpenTelemetry
    cb = OpenTelemetry()
except ImportError as e:
    if 'opentelemetry-exporter-otlp' in str(e):
        raise SystemExit('Install opentelemetry-exporter-otlp or set OTEL_EXPORTER=console') from e
    raise

Prevention

When it happens

Trigger: Setting OTEL_EXPORTER=otlp_http (or OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf|http/json) and enabling the otel callback in an environment that lacks the opentelemetry-exporter-otlp extra — e.g. a slim Docker image, a fresh venv with only core litellm installed, or an image built from a lockfile predating the OTel adoption. The failure occurs while building the span processor at callback init.

Common situations: Minimal deployment images that pip install litellm without extras; upgrading litellm and newly setting OTEL_EXPORTER to a real exporter after testing with console; CI environments diverging from local dev (local has the package via another dependency, CI does not); opentelemetry SDK present but exporter extras stripped by dependency pruning.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/d9ed059810c23117. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/opentelemetry.py:2889

            verbose_logger.debug(
                "OpenTelemetry: intiializing SpanExporter. Value of OTEL_EXPORTER: %s",
                otel_exporter,
            )
            return SimpleSpanProcessor(cast(SpanExporter, otel_exporter))

        if otel_exporter == "console":
            verbose_logger.debug(
                "OpenTelemetry: intiializing console exporter. Value of OTEL_EXPORTER: %s",
                otel_exporter,
            )
            return BatchSpanProcessor(ConsoleSpanExporter())
        elif otel_exporter == "otlp_http" or otel_exporter == "http/protobuf" or otel_exporter == "http/json":
            try:
                from opentelemetry.exporter.otlp.proto.http.trace_exporter import (
                    OTLPSpanExporter as OTLPSpanExporterHTTP,
                )
            except ImportError as exc:
                raise ImportError(
                    "OpenTelemetry OTLP HTTP exporter is not available. Install "
                    "`opentelemetry-exporter-otlp` to enable OTLP HTTP."
                ) from exc

            verbose_logger.debug(
                "OpenTelemetry: intiializing http exporter. Value of OTEL_EXPORTER: %s",
                otel_exporter,
            )
            normalized_endpoint = self._normalize_otel_endpoint(otel_endpoint, "traces")
            return BatchSpanProcessor(
                OTLPSpanExporterHTTP(endpoint=normalized_endpoint, headers=_split_otel_headers),
            )
        elif otel_exporter == "otlp_grpc" or otel_exporter == "grpc":
            try:
                from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (
                    OTLPSpanExporter as OTLPSpanExporterGRPC,
                )
            except ImportError as exc:

View on GitHub (pinned to 77b7c6c40c)