{"record":{"id":"4ea2e9f3e6772bc5","repo":"BerriAI/litellm","slug":"wandb-api-key-must-be-set-for-weave-opentelemetry","errorCode":null,"errorMessage":"WANDB_API_KEY must be set for Weave OpenTelemetry integration.","messagePattern":"WANDB_API_KEY must be set for Weave OpenTelemetry integration\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/weave/weave_otel.py","lineNumber":139,"sourceCode":"    Retrieves the Weave OpenTelemetry configuration based on environment variables.\n\n    Environment Variables:\n        WANDB_API_KEY: Required. W&B API key for authentication.\n        WANDB_PROJECT_ID: Required. Project ID in format <entity>/<project_name>.\n        WANDB_HOST: Optional. Custom Weave host URL. Defaults to cloud endpoint.\n\n    Returns:\n        WeaveOtelConfig: A Pydantic model containing Weave OTEL configuration.\n\n    Raises:\n        ValueError: If required environment variables are missing.\n    \"\"\"\n    api_key: Final = os.getenv(\"WANDB_API_KEY\")\n    project_id: Final = os.getenv(\"WANDB_PROJECT_ID\")\n    host = os.getenv(\"WANDB_HOST\")\n\n    if not api_key:\n        raise ValueError(\"WANDB_API_KEY must be set for Weave OpenTelemetry integration.\")\n\n    if not project_id:\n        raise ValueError(\n            \"WANDB_PROJECT_ID must be set for Weave OpenTelemetry integration. Format: <entity>/<project_name>\"\n        )\n\n    if host:\n        if not host.startswith(\"http\"):\n            host = \"https://\" + host\n        # Self-managed instances use a different path\n        endpoint = host.rstrip(\"/\") + WEAVE_OTEL_ENDPOINT\n        verbose_logger.debug(\"Using Weave OTEL endpoint from host: %s\", endpoint)\n    else:\n        endpoint = WEAVE_BASE_URL + WEAVE_OTEL_ENDPOINT\n        verbose_logger.debug(\"Using Weave cloud endpoint: %s\", endpoint)\n\n    # Weave uses Basic auth with format: api:<WANDB_API_KEY>\n    auth_header: Final = _get_weave_authorization_header(api_key=api_key)","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/weave/weave_otel.py#L121-L157","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before\nlitellm.callbacks = [\"weave\"]  # ValueError: WANDB_API_KEY must be set\n\n# after\nimport os\nos.environ[\"WANDB_API_KEY\"] = \"wandb-api-key\"\nos.environ[\"WANDB_PROJECT_ID\"] = \"my-entity/my-project\"\nlitellm.callbacks = [\"weave\"]","handlingStrategy":"validation","validationCode":"import os\n\nfor var in (\"WANDB_API_KEY\", \"WANDB_PROJECT_ID\"):\n    if not os.getenv(var):\n        raise RuntimeError(f\"{var} is required for the weave OTEL integration\")\n\nlitellm.callbacks += [\"weave\"]","typeGuard":null,"tryCatchPattern":"try:\n    from litellm.integrations.weave.weave_otel import get_weave_otel_config\n    weave_cfg = get_weave_otel_config()\nexcept ValueError as e:\n    if \"WANDB_API_KEY\" in str(e):\n        logger.warning(\"weave tracing disabled: WANDB_API_KEY not set\")\n        weave_cfg = None\n    else:\n        raise","preventionTips":["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"],"tags":["weave","wandb","opentelemetry","configuration","environment"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}