Implementation:BerriAI Litellm Supabase Logger
| Attribute | Value |
|---|---|
| Sources | litellm/integrations/supabase.py
|
| Domains | Logging, Supabase, Integrations, Observability |
| Last Updated | 2026-02-15 16:00 GMT |
Overview
Supabase is a logging integration that records LiteLLM request and response events to a Supabase database table for observability and cost tracking.
Description
The Supabase class connects to a Supabase instance using the SUPABASE_URL and SUPABASE_KEY environment variables. It provides two main methods: input_log_event for recording the initiation of an API call (with status "initiated"), and log_event for recording the final result (with status "success" or "failure"). Each event is stored in a configurable table (default: request_logs) and includes the model name, messages, end user, response time, total cost (computed via litellm.completion_cost), and the litellm_call_id for correlation. The class uses upsert with conflict resolution on litellm_call_id to update existing entries.
Usage
Import and instantiate Supabase when you want to log LiteLLM completion events to a Supabase database. Ensure the environment variables SUPABASE_URL and SUPABASE_KEY are set, and that a request_logs table exists in your Supabase project.
Code Reference
Source Location
litellm/integrations/supabase.py
Signature
class Supabase:
supabase_table_name = "request_logs"
def __init__(self)
def input_log_event(self, model, messages, end_user, litellm_call_id, print_verbose)
def log_event(self, model, messages, end_user, response_obj, start_time, end_time, litellm_call_id, print_verbose)
Import
from litellm.integrations.supabase import Supabase
I/O Contract
Inputs
| Parameter | Type | Description |
|---|---|---|
model |
str |
The model name used for the completion call. |
messages |
list |
The messages sent to the model. |
end_user |
str |
The end user identifier. |
response_obj |
dict |
The completion response object (contains choices or error).
|
start_time |
datetime |
Start time of the API call. |
end_time |
datetime |
End time of the API call. |
litellm_call_id |
str |
Unique call identifier for correlation. |
print_verbose |
Callable |
Verbose logging function. |
Outputs
| Method | Return Type | Description |
|---|---|---|
input_log_event |
None |
Inserts an "initiated" status row; no explicit return value. |
log_event |
None |
Upserts a "success" or "failure" status row; no explicit return value. |
Usage Examples
import os
import litellm
# Set Supabase credentials
os.environ["SUPABASE_URL"] = "https://your-project.supabase.co"
os.environ["SUPABASE_KEY"] = "your-supabase-key"
# Add supabase as a success callback
litellm.success_callback = ["supabase"]
litellm.failure_callback = ["supabase"]
# The Supabase logger is automatically invoked on completion calls
response = litellm.completion(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello!"}],
)
Related Pages
- Implementation:BerriAI_Litellm_S3_Logger - Alternative S3-based logging integration
- Implementation:BerriAI_Litellm_Weights_Biases_Logger - Weights & Biases logging integration