BerriAI/litellm · error · ValueError

LiteLLM Error, trying to use DynamoDB but not table name…

Error message

LiteLLM Error, trying to use DynamoDB but not table name passed. Create a table and set `litellm.dynamodb_table_name=<your-table>`

What it means

DynamoDBLogger.__init__ reads the process-global litellm.dynamodb_table_name; if it is None the logger refuses to construct because every log write needs a table. Note __init__ first executes os.environ['AWS_REGION_NAME'], so a missing AWS_REGION_NAME env var fails with KeyError before this ValueError is even reached.

Solutions

  1. Set litellm.dynamodb_table_name = '<your-table>' before any request triggers the callback
  2. Also export AWS_REGION_NAME (and standard AWS credentials) — __init__ requires the env var
  3. Create the DynamoDB table in the target region first
  4. For the LiteLLM proxy, prefer the UI/env config for DynamoDB logging so the global is set at startup

Example fix

# before
import litellm
litellm.success_callback = ['dynamodb']

# after
import os
import litellm
os.environ['AWS_REGION_NAME'] = 'us-east-1'
litellm.dynamodb_table_name = 'litellm-logs'
litellm.success_callback = ['dynamodb']
Defensive patterns

Strategy: validation

Validate before calling

import litellm

if 'dynamodb' in litellm.success_callback:
    assert litellm.dynamodb_table_name, 'set litellm.dynamodb_table_name before enabling dynamodb callback'
    assert 'AWS_REGION_NAME' in os.environ, 'set AWS_REGION_NAME for dynamodb logging'

Try / catch

try:
    logger = DynamoDBLogger()
except (ValueError, KeyError) as e:
    logger.warning('dynamodb logging disabled: %s', e)
    litellm.success_callback.remove('dynamodb')

Prevention

When it happens

Trigger: Adding 'dynamodb' to litellm.success_callback (which instantiates DynamoDBLogger on first logged event) without setting litellm.dynamodb_table_name first; setting the attribute after the first request has already triggered logger construction; running the proxy where the setting lives only in a worker that skipped it.

Common situations: Enabling DynamoDB logging in a notebook/script and forgetting the global; proxy config setting the table via environment only (this code reads the litellm global, not env); staging works because another path set the global, production fails.

Related errors


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

Appendix: source

Thrown at litellm/integrations/dynamodb.py:21

import os
import traceback
from typing import Any, Final

import litellm
from litellm._uuid import uuid


class DyanmoDBLogger:
    # Class variables or attributes

    def __init__(self):
        # Instance variables
        import boto3

        self.dynamodb: Any = boto3.resource("dynamodb", region_name=os.environ["AWS_REGION_NAME"])
        if litellm.dynamodb_table_name is None:
            raise ValueError(
                "LiteLLM Error, trying to use DynamoDB but not table name passed. Create a table and set `litellm.dynamodb_table_name=<your-table>`"
            )
        self.table_name = litellm.dynamodb_table_name

    async def _async_log_event(self, kwargs, response_obj, start_time, end_time, print_verbose):
        self.log_event(kwargs, response_obj, start_time, end_time, print_verbose)

    def log_event(self, kwargs, response_obj, start_time, end_time, print_verbose):
        try:
            print_verbose(f"DynamoDB Logging - Enters logging function for model {kwargs}")

            # construct payload to send to DynamoDB
            # follows the same params as langfuse.py
            litellm_params: Final = kwargs.get("litellm_params", {})
            metadata: Final = litellm_params.get("metadata", {}) or {}  # if litellm_params['metadata'] == None
            messages: Final = kwargs.get("messages")
            optional_params: Final = kwargs.get("optional_params", {})
            call_type: Final = kwargs.get("call_type", "litellm.completion")

View on GitHub (pinned to 77b7c6c40c)