BerriAI/litellm · error · ValueError
standard_logging_object not found in kwargs
Error message
standard_logging_object not found in kwargs
What it means
create_datadog_logging_payload builds the Datadog payload from kwargs["standard_logging_object"], a StandardLoggingPayload that litellm's core logging machinery attaches to every log_success_event/log_failure_event call. If the key is absent it raises ValueError immediately. In the normal litellm.completion/proxy flow this object is always populated, so hitting it almost always means the payload builder was invoked outside litellm's logging pipeline.
Solutions
- Trigger logging through the real flow: litellm.completion(..., callbacks=[DatadogLogger(...)]) so the core populates standard_logging_object
- If you must build payloads directly, construct kwargs via litellm's own helpers (get_standard_logging_payload) or attach a valid StandardLoggingPayload before calling
- Reinstall litellm as one consistent version so callback and core agree
Example fix
# before
kwargs = {"model": "gpt-4", "messages": [...]}
payload = logger.create_datadog_logging_payload(kwargs, response_obj, start, end) # ValueError
# after
import litellm
resp = litellm.completion(model="gpt-4", messages=[...], callbacks=[logger])
# standard_logging_object is attached internally; payload building happens in the hook Defensive patterns
Strategy: validation
Validate before calling
def has_standard_logging_object(kwargs: dict) -> bool:
"""Caller-side guard before touching datadog payload builders directly."""
slo = kwargs.get("standard_logging_object")
return isinstance(slo, dict) and len(slo) > 0 Type guard
from typing import Any
from litellm.integrations.datadog.types import DatadogPayload
def is_logging_kwargs(kwargs: Any) -> bool:
"""Narrow kwargs to the shape create_datadog_logging_payload requires."""
return isinstance(kwargs, dict) and isinstance(kwargs.get("standard_logging_object"), dict) Try / catch
try:
payload = logger.create_datadog_logging_payload(kwargs, resp, start, end)
except ValueError as e:
if "standard_logging_object" in str(e):
raise RuntimeError("called outside litellm logging flow; pass kwargs from a real completion") from e
raise Prevention
- Never hand-build kwargs for payload builders; capture real kwargs from a hook
- Pin one litellm version so callback/core contracts stay in sync
- In tests, fixture a recorded StandardLoggingPayload instead of an empty dict
When it happens
Trigger: Calling logger.create_datadog_logging_payload(kwargs, ...) directly in unit tests or custom code with hand-built kwargs; manually invoking log_success_event with a fabricated kwargs dict; a litellm version mismatch where an older core does not yet attach standard_logging_object before invoking callbacks.
Common situations: Teams unit-testing callback classes by constructing kwargs themselves instead of running a real completion; mixed-version installs (callback class from newer litellm, core from older one); copy-pasted example code that calls payload builders directly.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- DataDogLLMObs: standard_logging_object is not set
- logging_obj is required
- logging_obj is required
- custom_llm_provider is required
- custom_llm_provider is required
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/94598a54cbbfbc4b.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/datadog/datadog.py:576
start_time: datetime.datetime,
end_time: datetime.datetime,
) -> DatadogPayload:
"""
Helper function to create a datadog payload for logging
Args:
kwargs (Union[dict, Any]): request kwargs
response_obj (Any): llm api response
start_time (datetime.datetime): start time of request
end_time (datetime.datetime): end time of request
Returns:
DatadogPayload: defined in types.py
"""
standard_logging_object: Final[StandardLoggingPayload | None] = kwargs.get("standard_logging_object", None)
if standard_logging_object is None:
raise ValueError("standard_logging_object not found in kwargs")
status = DataDogStatus.INFO
if standard_logging_object.get("status") == "failure":
status = DataDogStatus.ERROR
# Build the initial payload
self.truncate_standard_logging_payload_content(standard_logging_object)
dd_payload: Final = self._create_datadog_logging_payload_helper(
standard_logging_object=standard_logging_object,
status=status,
)
return dd_payload
async def async_send_compressed_data(self, data: list) -> Response:
"""
Async helper to send compressed data to datadog self.intake_url
View on GitHub (pinned to 77b7c6c40c)