[
{
"api_key": "4a232c5264640946b61ec32fb3304278af1a34cc26482066aa66e250cddde75e",
"key_alias": "internlm2",
"key_name": "sk-...ZeoQ",
"total_spend": 28.4
}
]
直接基于数据库的查询
select * from "MonthlyGlobalSpendPerKey" a join "LiteLLM_VerificationToken" b on a.api_key=b.token
注意
MonthlyGlobalSpendPerKey 是一个视图,ddl 如下
CREATE VIEW "MonthlyGlobalSpendPerKey" AS SELECT date("LiteLLM_SpendLogs"."startTime") AS date,
sum("LiteLLM_SpendLogs".spend) AS spend,
"LiteLLM_SpendLogs".api_key
FROM "LiteLLM_SpendLogs"
WHERE "LiteLLM_SpendLogs"."startTime" >= (CURRENT_DATE - '30 days'::interval)
GROUP BY (date("LiteLLM_SpendLogs"."startTime")), "LiteLLM_SpendLogs".api_key;
还有一个LiteLLM_VerificationTokenView的视图可以关联其他信息的基于了LiteLLM_VerificationToken 表
CREATE VIEW "LiteLLM_VerificationTokenView" AS SELECT v.token,
v.key_name,
v.key_alias,
v.soft_budget_cooldown,
v.spend,
v.expires,
v.models,
v.aliases,
v.config,
v.user_id,
v.team_id,
v.permissions,
v.max_parallel_requests,
v.metadata,
v.tpm_limit,
v.rpm_limit,
v.max_budget,
v.budget_duration,
v.budget_reset_at,
v.allowed_cache_controls,
v.model_spend,
v.model_max_budget,
v.budget_id,
t.spend AS team_spend,
t.max_budget AS team_max_budget,
t.tpm_limit AS team_tpm_limit,
t.rpm_limit AS team_rpm_limit
FROM "LiteLLM_VerificationToken" v
LEFT JOIN "LiteLLM_TeamTable" t ON v.team_id = t.team_id;
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
- 36.
- 37.
- 38.
- 39.
- 40.
- 41.
- 42.
- 43.
- 44.
- 45.
- 46.
- 47.
- 48.
- 49.
- 50.