BerriAI/litellm · error · ValueError
WANDB_API_KEY must be set for Weave OpenTelemetry integratio
Error message
WANDB_API_KEY must be set for Weave OpenTelemetry integration.
What it means
get_weave_otel_config builds the Weave (W&B) OpenTelemetry exporter configuration and hard-requires WANDB_API_KEY in the environment; without it there is no way to authenticate the OTLP stream, so it raises ValueError immediately. WANDB_PROJECT_ID is checked next and fails separately if the key is present but the project is not.
Source
Thrown at litellm/integrations/weave/weave_otel.py:139
Retrieves the Weave OpenTelemetry configuration based on environment variables.
Environment Variables:
WANDB_API_KEY: Required. W&B API key for authentication.
WANDB_PROJECT_ID: Required. Project ID in format <entity>/<project_name>.
WANDB_HOST: Optional. Custom Weave host URL. Defaults to cloud endpoint.
Returns:
WeaveOtelConfig: A Pydantic model containing Weave OTEL configuration.
Raises:
ValueError: If required environment variables are missing.
"""
api_key: Final = os.getenv("WANDB_API_KEY")
project_id: Final = os.getenv("WANDB_PROJECT_ID")
host = os.getenv("WANDB_HOST")
if not api_key:
raise ValueError("WANDB_API_KEY must be set for Weave OpenTelemetry integration.")
if not project_id:
raise ValueError(
"WANDB_PROJECT_ID must be set for Weave OpenTelemetry integration. Format: <entity>/<project_name>"
)
if host:
if not host.startswith("http"):
host = "https://" + host
# Self-managed instances use a different path
endpoint = host.rstrip("/") + WEAVE_OTEL_ENDPOINT
verbose_logger.debug("Using Weave OTEL endpoint from host: %s", endpoint)
else:
endpoint = WEAVE_BASE_URL + WEAVE_OTEL_ENDPOINT
verbose_logger.debug("Using Weave cloud endpoint: %s", endpoint)
# Weave uses Basic auth with format: api:<WANDB_API_KEY>
auth_header: Final = _get_weave_authorization_header(api_key=api_key)View on GitHub (pinned to 6c2dcb801b)
Solutions
- Export WANDB_API_KEY (and WANDB_PROJECT_ID) before the weave callback initializes: export WANDB_API_KEY=<your-key>
- In Docker/K8s, mount the W&B API key as an env secret on the litellm container
- If you only wanted W&B experiment tracking, not OTEL tracing, use the wandb callback instead and unset the weave one
Example fix
# before litellm.callbacks = ["weave"] # ValueError: WANDB_API_KEY must be set # after import os os.environ["WANDB_API_KEY"] = "wandb-api-key" os.environ["WANDB_PROJECT_ID"] = "my-entity/my-project" litellm.callbacks = ["weave"]
Defensive patterns
Strategy: validation
Validate before calling
import os
for var in ("WANDB_API_KEY", "WANDB_PROJECT_ID"):
if not os.getenv(var):
raise RuntimeError(f"{var} is required for the weave OTEL integration")
litellm.callbacks += ["weave"] Try / catch
try:
from litellm.integrations.weave.weave_otel import get_weave_otel_config
weave_cfg = get_weave_otel_config()
except ValueError as e:
if "WANDB_API_KEY" in str(e):
logger.warning("weave tracing disabled: WANDB_API_KEY not set")
weave_cfg = None
else:
raise Prevention
- Mount W&B credentials as env secrets in every container that enables the weave callback
- Remember `wandb login` alone is not enough — this integration reads env vars directly
- Add the WANDB_* vars to the same startup checklist as provider API keys
When it happens
Trigger: Enabling the weave integration (litellm.callbacks += ["weave"] or the weave_otel config path) in a process without WANDB_API_KEY exported; keys stored only in a notebook-level wandb login that does not touch os.environ; CI runners without W&B secrets.
Common situations: Local runs where wandb was authenticated via `wandb login` (stored in ~/.netrc, not env); Docker deployments missing the secret; rotating W&B keys and forgetting the proxy's env.
Related errors
- LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for
- WANDB_PROJECT_ID must be set for Weave OpenTelemetry integra
- Qdrant url must be provided
- Missing required Redis configuration: {missing_var}. Provide
- Missing required Valkey configuration. Provide host and port
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/4ea2e9f3e6772bc5.
Report an issue: GitHub.