Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

feat: add focus schema

Yuta Saito3af9bab6a504
diff --git a/litellm/integrations/focus/schema.py b/litellm/integrations/focus/schema.py
new file mode 100644
index 00000000000..766e29c0856
--- /dev/null
+++ b/litellm/integrations/focus/schema.py
@@ -0,0 +1,33 @@
+"""Schema definitions for Focus export data."""
+
+from __future__ import annotations
+
+import polars as pl
+
+
+FOCUS_NORMALIZED_SCHEMA = pl.Schema(
+ {
+ "usage_date": pl.Datetime(time_unit="us"),
+ "team_id": pl.String,
+ "team_alias": pl.String,
+ "user_id": pl.String,
+ "user_email": pl.String,
+ "api_key_alias": pl.String,
+ "model": pl.String,
+ "model_group": pl.String,
+ "custom_llm_provider": pl.String,
+ "prompt_tokens": pl.Int64,
+ "completion_tokens": pl.Int64,
+ "total_tokens": pl.Int64,
+ "spend": pl.Float64,
+ "cache_creation_input_tokens": pl.Int64,
+ "cache_read_input_tokens": pl.Int64,
+ "api_requests": pl.Int64,
+ "successful_requests": pl.Int64,
+ "failed_requests": pl.Int64,
+ "created_at": pl.Datetime(time_unit="us"),
+ "updated_at": pl.Datetime(time_unit="us"),
+ }
+)
+
+__all__ = ["FOCUS_NORMALIZED_SCHEMA"]
diff --git a/litellm/integrations/focus/transformer.py b/litellm/integrations/focus/transformer.py
index 45a77dd8ac5..612082505fa 100644
--- a/litellm/integrations/focus/transformer.py
+++ b/litellm/integrations/focus/transformer.py
@@ -4,10 +4,14 @@ from __future__ import annotations
import polars as pl
+from .schema import FOCUS_NORMALIZED_SCHEMA
+
class FocusTransformer:
"""Transforms LiteLLM DB rows into Focus-compatible schema."""
+ schema = FOCUS_NORMALIZED_SCHEMA
+
def transform(self, frame: pl.DataFrame) -> pl.DataFrame:
"""Return a normalized frame expected by downstream serializers."""
raise NotImplementedError