docs(daily-activity): describe guardrail spend fields and reporting key IDs in OpenAPI (#49236)

* docs(daily-activity): describe guardrail spend and reporting key IDs

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* docs(daily-activity): describe reporting key IDs on /user/daily/activity

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
mrinal-berri 2026-10-30 10:59:28 -07:00 • committed by GitHub
parent 707ac1ffee
commit ccdc8c7d10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 64 additions and 26 deletions

View file

@ -3491,6 +3491,7 @@
"additionalProperties": {
"$ref": "#/components/schemas/GuardrailMetric"
},
"description": "Spend by guardrail ID, already included in key and model spend. Populated on user, team and organization aggregated activity only, without a model filter",
"title": "Guardrails",
"type": "object"
},
@ -3812,10 +3813,12 @@
"GuardrailKeyMetric": {
"properties": {
"metadata": {
"$ref": "#/components/schemas/KeyMetadata"
"$ref": "#/components/schemas/KeyMetadata",
"description": "API key alias and existence information"
},
"metrics": {
"$ref": "#/components/schemas/GuardrailSpendMetrics"
"$ref": "#/components/schemas/GuardrailSpendMetrics",
"description": "Guardrail spend and unpriced units for this API key"
}
},
"required": [
@ -3828,6 +3831,7 @@
"GuardrailMetadata": {
"properties": {
"guardrail_name": {
"description": "Guardrail display name, falling back to the guardrail ID",
"title": "Guardrail Name",
"type": "string"
}
@ -3844,14 +3848,17 @@
"additionalProperties": {
"$ref": "#/components/schemas/GuardrailKeyMetric"
},
"description": "Per-key guardrail spend and unpriced units, limited to keys in the day's API key breakdown",
"title": "Api Key Breakdown",
"type": "object"
},
"metadata": {
"$ref": "#/components/schemas/GuardrailMetadata"
"$ref": "#/components/schemas/GuardrailMetadata",
"description": "Guardrail name information"
},
"metrics": {
"$ref": "#/components/schemas/GuardrailSpendMetrics"
"$ref": "#/components/schemas/GuardrailSpendMetrics",
"description": "Guardrail spend and unpriced units across all matching API keys"
}
},
"required": [
@ -3865,11 +3872,13 @@
"properties": {
"spend": {
"default": 0.0,
"description": "Guardrail spend in USD, already included in key and model spend",
"title": "Spend",
"type": "number"
},
"untracked_units": {
"default": 0,
"description": "Guardrail units with no known price, excluded from spend",
"title": "Untracked Units",
"type": "integer"
}

View file

@ -216,7 +216,11 @@ def _user_query(
start_date: str | None = Query(default=None, description="Start date in YYYY-MM-DD format"),
end_date: str | None = Query(default=None, description="End date in YYYY-MM-DD format"),
model: str | None = Query(default=None, description="Filter by specific model"),
api_key: str | None = Query(default=None, description="Filter by specific API key"),
api_key: str | None = Query(
default=None,
description="Filter by reporting API key ID. Missing keys are reported as unattributed. "
"For a literal key unattributed or a key starting with raw:, add an extra raw: prefix",
),
user_id: str | None = Query(
default=None,
description="Filter by specific user ID. Admins can filter by any user or omit for global view. "

View file

@ -2922,7 +2922,8 @@ async def get_user_daily_activity(
),
api_key: str | None = fastapi.Query(
default=None,
description="Filter by specific API key",
description="Filter by reporting API key ID. Missing keys are reported as unattributed. "
"For a literal key unattributed or a key starting with raw:, add an extra raw: prefix",
),
user_id: str | None = fastapi.Query(
default=None,

View file

@ -68,29 +68,34 @@ class MetricWithMetadata(MetricBase):
class GuardrailSpendMetrics(LiteLLMBaseModel):
model_config = ConfigDict(frozen=True)
spend: float = 0.0
untracked_units: int = 0
spend: float = Field(default=0.0, description="Guardrail spend in USD, already included in key and model spend")
untracked_units: int = Field(default=0, description="Guardrail units with no known price, excluded from spend")
class GuardrailKeyMetric(LiteLLMBaseModel):
model_config = ConfigDict(frozen=True)
metrics: GuardrailSpendMetrics
metadata: KeyMetadata
metrics: GuardrailSpendMetrics = Field(description="Guardrail spend and unpriced units for this API key")
metadata: KeyMetadata = Field(description="API key alias and existence information")
class GuardrailMetadata(LiteLLMBaseModel):
model_config = ConfigDict(frozen=True)
guardrail_name: str
guardrail_name: str = Field(description="Guardrail display name, falling back to the guardrail ID")
class GuardrailMetric(LiteLLMBaseModel):
model_config = ConfigDict(frozen=True)
metrics: GuardrailSpendMetrics
metadata: GuardrailMetadata
api_key_breakdown: Mapping[str, GuardrailKeyMetric] = Field(default_factory=dict)
metrics: GuardrailSpendMetrics = Field(
description="Guardrail spend and unpriced units across all matching API keys"
)
metadata: GuardrailMetadata = Field(description="Guardrail name information")
api_key_breakdown: Mapping[str, GuardrailKeyMetric] = Field(
default_factory=dict,
description="Per-key guardrail spend and unpriced units, limited to keys in the day's API key breakdown",
)
class BreakdownMetrics(LiteLLMBaseModel):
@ -103,7 +108,11 @@ class BreakdownMetrics(LiteLLMBaseModel):
endpoints: dict[str, MetricWithMetadata] = Field(default_factory=dict) # endpoint -> {metrics, metadata}
api_keys: dict[str, KeyMetricWithMetadata] = Field(default_factory=dict) # api_key -> {metrics, metadata}
entities: dict[str, MetricWithMetadata] = Field(default_factory=dict) # entity -> {metrics, metadata}
guardrails: Mapping[str, GuardrailMetric] = Field(default_factory=dict) # guardrail_id -> spend
guardrails: Mapping[str, GuardrailMetric] = Field(
default_factory=dict,
description="Spend by guardrail ID, already included in key and model spend. "
"Populated on user, team and organization aggregated activity only, without a model filter",
)
class DailySpendData(LiteLLMBaseModel):

View file

@ -27870,7 +27870,10 @@ export interface components {
entities?: {
[key: string]: components["schemas"]["MetricWithMetadata"];
};
/** Guardrails */
/**
* Guardrails
* @description Spend by guardrail ID, already included in key and model spend. Populated on user, team and organization aggregated activity only, without a model filter
*/
guardrails?: {
[key: string]: components["schemas"]["GuardrailMetric"];
};
@ -33448,32 +33451,44 @@ export interface components {
};
/** GuardrailKeyMetric */
GuardrailKeyMetric: {
/** @description API key alias and existence information */
metadata: components["schemas"]["KeyMetadata"];
/** @description Guardrail spend and unpriced units for this API key */
metrics: components["schemas"]["GuardrailSpendMetrics"];
};
/** GuardrailMetadata */
GuardrailMetadata: {
/** Guardrail Name */
/**
* Guardrail Name
* @description Guardrail display name, falling back to the guardrail ID
*/
guardrail_name: string;
};
/** GuardrailMetric */
GuardrailMetric: {
/** Api Key Breakdown */
/**
* Api Key Breakdown
* @description Per-key guardrail spend and unpriced units, limited to keys in the day's API key breakdown
*/
api_key_breakdown?: {
[key: string]: components["schemas"]["GuardrailKeyMetric"];
};
/** @description Guardrail name information */
metadata: components["schemas"]["GuardrailMetadata"];
/** @description Guardrail spend and unpriced units across all matching API keys */
metrics: components["schemas"]["GuardrailSpendMetrics"];
};
/** GuardrailSpendMetrics */
GuardrailSpendMetrics: {
/**
* Spend
* @description Guardrail spend in USD, already included in key and model spend
* @default 0
*/
spend: number;
/**
* Untracked Units
* @description Guardrail units with no known price, excluded from spend
* @default 0
*/
untracked_units: number;
@ -76633,7 +76648,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;
@ -76682,7 +76697,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;
@ -76727,7 +76742,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;
@ -76773,7 +76788,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;
@ -76820,7 +76835,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;
@ -76866,7 +76881,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;
@ -76912,7 +76927,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;
@ -76958,7 +76973,7 @@ export interface operations {
end_date?: string | null;
/** @description Filter by specific model */
model?: string | null;
/** @description Filter by specific API key */
/** @description Filter by reporting API key ID. Missing keys are reported as unattributed. For a literal key unattributed or a key starting with raw:, add an extra raw: prefix */
api_key?: string | null;
/** @description Filter by specific user ID. Admins can filter by any user or omit for global view. Non-admins must provide their own user_id. */
user_id?: string | null;