BerriAI/litellm · error · ValueError

LiteLLM Error, trying to use Supabase but url or key not pas

Error message

LiteLLM Error, trying to use Supabase but url or key not passed. Create a table and set `litellm.supabase_url=<your-url>` and `litellm.supabase_key=<your-key>`

What it means

SupabaseLogger.__init__ reads SUPABASE_URL and SUPABASE_KEY from the environment and, if either is missing, raises ValueError telling you to configure them (the message references litellm.supabase_url but the code actually reads env vars). Note it also pip-installs supabase via subprocess on first use, so the import is not the failure mode here — the missing env vars are.

Source

Thrown at litellm/integrations/supabase.py:28

import litellm


class Supabase:
    # Class variables or attributes
    supabase_table_name = "request_logs"

    def __init__(self):
        # Instance variables
        self.supabase_url = os.getenv("SUPABASE_URL")
        self.supabase_key = os.getenv("SUPABASE_KEY")
        try:
            import supabase
        except ImportError:
            subprocess.check_call([sys.executable, "-m", "pip", "install", "supabase"])
            import supabase

        if self.supabase_url is None or self.supabase_key is None:
            raise ValueError(
                "LiteLLM Error, trying to use Supabase but url or key not passed. Create a table and set `litellm.supabase_url=<your-url>` and `litellm.supabase_key=<your-key>`"
            )
        self.supabase_client = supabase.create_client(self.supabase_url, self.supabase_key)

    def input_log_event(self, model, messages, end_user, litellm_call_id, print_verbose):
        try:
            print_verbose(f"Supabase Logging - Enters input logging function for model {model}")
            supabase_data_obj: Final = {
                "model": model,
                "messages": messages,
                "end_user": end_user,
                "status": "initiated",
                "litellm_call_id": litellm_call_id,
            }
            data, count = self.supabase_client.table(self.supabase_table_name).insert(supabase_data_obj).execute()
            print_verbose(f"data: {data}")
        except Exception:
            print_verbose(f"Supabase Logging Error - {traceback.format_exc()}")

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Export SUPABASE_URL and SUPABASE_KEY in the proxy's environment before constructing the callback
  2. If you were following the message literally (litellm.supabase_url=...), switch to env vars — that is what the code reads
  3. Verify inside the process: python -c "import os; print(bool(os.getenv('SUPABASE_URL')), bool(os.getenv('SUPABASE_KEY')))"
  4. Also pip install supabase ahead of time to avoid the subprocess auto-install

Example fix

# before (has no effect)
litellm.supabase_url = "https://xyz.supabase.co"
litellm.supabase_key = "eyJ..."
litellm.callbacks = ["supabase"]  # ValueError

# after
import os
os.environ["SUPABASE_URL"] = "https://xyz.supabase.co"
os.environ["SUPABASE_KEY"] = "eyJ..."
litellm.callbacks = ["supabase"]
Defensive patterns

Strategy: validation

Validate before calling

import os

missing = [v for v in ("SUPABASE_URL", "SUPABASE_KEY") if not os.getenv(v)]
if missing:
    raise RuntimeError(f"Supabase logging requires env vars: {missing}")
litellm.callbacks = ["supabase"]

Try / catch

try:
    from litellm.integrations.supabase import SupabaseLogger
    supabase_logger = SupabaseLogger()
except ValueError as e:
    if "url or key not passed" in str(e):
        supabase_logger = None  # run without supabase logging
    else:
        raise

Prevention

When it happens

Trigger: Adding litellm.callbacks = ["supabase"] without exporting SUPABASE_URL/SUPABASE_KEY; setting litellm.supabase_url as a Python attribute (as the message hints) — which has no effect, since __init__ only reads os.environ; env vars defined in .env but the callback constructed before .env is loaded.

Common situations: Confusion between the documented litellm.supabase_url=... snippet and the env-var implementation; keys set in a different shell/container than the proxy process; project templates that omit the supabase env block.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/312ade13e6046d98. Report an issue: GitHub.