mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
feat(usage): 用户 API Key 用量页支持按日明细
This commit is contained in:
@@ -69,6 +69,25 @@ export interface ModelStatsResponse {
|
||||
end_date: string
|
||||
}
|
||||
|
||||
export interface ApiKeyDailyUsagePoint {
|
||||
date: string
|
||||
requests: number
|
||||
input_tokens: number
|
||||
output_tokens: number
|
||||
cache_read_tokens: number
|
||||
cache_write_tokens: number
|
||||
total_tokens: number
|
||||
cost: number
|
||||
actual_cost: number
|
||||
}
|
||||
|
||||
export interface ApiKeyDailyUsageResponse {
|
||||
items: ApiKeyDailyUsagePoint[]
|
||||
days: number
|
||||
start_date: string
|
||||
end_date: string
|
||||
}
|
||||
|
||||
/**
|
||||
* List usage logs with optional filters
|
||||
* @param page - Page number (default: 1)
|
||||
@@ -234,6 +253,23 @@ export async function getDashboardModels(params?: {
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* Get daily usage details for one API key owned by the current user.
|
||||
* @param apiKeyId - API key ID
|
||||
* @param days - Number of days to include (1-90)
|
||||
* @returns Daily usage detail rows
|
||||
*/
|
||||
export async function getMyApiKeyDailyUsage(
|
||||
apiKeyId: number,
|
||||
days: number = 30
|
||||
): Promise<ApiKeyDailyUsageResponse> {
|
||||
const { data } = await apiClient.get<ApiKeyDailyUsageResponse>(
|
||||
`/user/api-keys/${apiKeyId}/usage/daily`,
|
||||
{ params: { days } }
|
||||
)
|
||||
return data
|
||||
}
|
||||
|
||||
export interface BatchApiKeyUsageStats {
|
||||
api_key_id: number
|
||||
today_actual_cost: number
|
||||
@@ -279,6 +315,7 @@ export const usageAPI = {
|
||||
getDashboardStats,
|
||||
getDashboardTrend,
|
||||
getDashboardModels,
|
||||
getMyApiKeyDailyUsage,
|
||||
getDashboardApiKeysUsage
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user