BerriAI/litellm · error · ValueError
WANDB_PROJECT_ID must be set for Weave OpenTelemetry integra
Error message
WANDB_PROJECT_ID must be set for Weave OpenTelemetry integration. Format: <entity>/<project_name>
What it means
Companion check to the WANDB_API_KEY guard: after the API key is validated, get_weave_otel_config requires WANDB_PROJECT_ID in the format <entity>/<project_name> so it can route traces to the right Weave project. Missing or malformed (non-slash) values raise this ValueError.
Source
Thrown at litellm/integrations/weave/weave_otel.py:142
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)
otlp_auth_headers: Final = f"Authorization={auth_header},project_id={project_id}"
# Set standard OTEL environment variablesView on GitHub (pinned to 6c2dcb801b)
Solutions
- Set WANDB_PROJECT_ID to the full form: export WANDB_PROJECT_ID="<wandb-entity>/<project-name>" (find the entity in your W&B URL: wandb.ai/<entity>/<project>)
- Optionally set WANDB_HOST for self-managed W&B instances
- Verify both vars before enabling the callback (see validation snippet)
Example fix
# before export WANDB_API_KEY=... export WANDB_PROJECT_ID=my-project # missing entity -> ValueError # after export WANDB_API_KEY=... export WANDB_PROJECT_ID=my-team/my-project
Defensive patterns
Strategy: validation
Validate before calling
import os
def valid_project_id(v: str | None) -> bool:
return bool(v) and "/" in v and len(v.split("/")) == 2
project = os.getenv("WANDB_PROJECT_ID")
assert valid_project_id(project), "WANDB_PROJECT_ID must be '<entity>/<project_name>'" Type guard
from typing import Any, TypeGuard
import re
_WANDB_PROJECT = re.compile(r"^[^/\s]+/[^/\s]+$")
def is_wandb_project_id(v: Any) -> TypeGuard[str]:
return isinstance(v, str) and bool(_WANDB_PROJECT.match(v)) Try / catch
try:
cfg = get_weave_otel_config()
except ValueError as e:
if "WANDB_PROJECT_ID" in str(e):
raise RuntimeError(
"Set WANDB_PROJECT_ID='<entity>/<project>' (see your wandb.ai URL)"
) from e
raise Prevention
- Copy the entity/project pair directly from the wandb.ai URL to avoid prefix mistakes
- Lint env config with a regex for WANDB_PROJECT_ID at deploy time
- Keep the W&B variable trio (API key, project id, optional host) together in one secret block
When it happens
Trigger: WANDB_API_KEY is set but WANDB_PROJECT_ID is absent; the variable holds only a project name ('my-project') without the entity prefix; the var name is misspelled (WANDB_PROJECT vs WANDB_PROJECT_ID).
Common situations: Copy-pasting setup snippets that omit the entity; default-entity assumptions when the W&B entity differs from the username; deploying with only the API key secret configured.
Related errors
- WANDB_API_KEY must be set for Weave OpenTelemetry integratio
- Missing `LLM_GUARD_API_BASE` from environment
- PAGERDUTY_API_KEY is not set
- Qdrant url must be provided
- Missing required Redis configuration: {missing_var}. Provide
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/73da569a96aa9a16.
Report an issue: GitHub.