+
{/* Admin-only fields */}
{isAdmin && (
<>
diff --git a/web/src/features/dashboard/constants.ts b/web/src/features/dashboard/constants.ts
index 34e6828e7678..b3c2dfc93491 100644
--- a/web/src/features/dashboard/constants.ts
+++ b/web/src/features/dashboard/constants.ts
@@ -66,4 +66,5 @@ export const EMPTY_DASHBOARD_FILTERS: DashboardFilters = {
end_timestamp: undefined,
time_granularity: 'hour',
username: '',
+ token_id: undefined,
}
diff --git a/web/src/features/dashboard/lib/filters.ts b/web/src/features/dashboard/lib/filters.ts
index 321f608d995c..9613497846e0 100644
--- a/web/src/features/dashboard/lib/filters.ts
+++ b/web/src/features/dashboard/lib/filters.ts
@@ -154,16 +154,18 @@ export function buildDefaultDashboardFilters(
export function buildQueryParams(
timeRange: { start_timestamp: number; end_timestamp: number },
- filters?: { time_granularity?: TimeGranularity; username?: string }
+ filters?: { time_granularity?: TimeGranularity; username?: string; token_id?: number }
): {
start_timestamp: number
end_timestamp: number
default_time: string
username?: string
+ token_id?: number
} {
return {
...timeRange,
default_time: getSavedGranularity(filters?.time_granularity),
...(filters?.username && { username: filters.username }),
+ ...(filters?.token_id && filters.token_id > 0 && { token_id: filters.token_id }),
}
}
diff --git a/web/src/features/dashboard/types.ts b/web/src/features/dashboard/types.ts
index b8771df2565a..8587f6e3d010 100644
--- a/web/src/features/dashboard/types.ts
+++ b/web/src/features/dashboard/types.ts
@@ -189,6 +189,7 @@ export interface DashboardFilters {
end_timestamp?: Date
time_granularity?: TimeGranularity
username?: string
+ token_id?: number
}
export type ConsumptionDistributionChartType = 'bar' | 'area'
diff --git a/web/src/features/keys/api.ts b/web/src/features/keys/api.ts
index df3cc5ff74bc..e5e3ec2beffa 100644
--- a/web/src/features/keys/api.ts
+++ b/web/src/features/keys/api.ts
@@ -54,6 +54,20 @@ export async function searchApiKeys(
return res.data
}
+// Admin-only: search all users' API keys by keyword or token (with pagination)
+export async function searchAdminApiKeys(
+ params: SearchApiKeysParams
+): Promise {
+ const { keyword = '', token = '', p, size } = params
+ const queryParams = new URLSearchParams()
+ if (keyword) queryParams.set('keyword', keyword)
+ if (token) queryParams.set('token', token)
+ if (p != null) queryParams.set('p', String(p))
+ if (size != null) queryParams.set('size', String(size))
+ const res = await api.get(`/api/token/admin/search?${queryParams.toString()}`)
+ return res.data
+}
+
// Get single API key by ID
export async function getApiKey(id: number): Promise> {
const res = await api.get(`/api/token/${id}`)
diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json
index 609e72eb08c8..1f0af95a8e6d 100644
--- a/web/src/i18n/locales/en.json
+++ b/web/src/i18n/locales/en.json
@@ -279,6 +279,7 @@
"Ali": "Alibaba Bailian",
"Alipay": "Alipay",
"All": "All",
+ "All API keys": "All API keys",
"All API tokens": "All API tokens",
"All categories": "All categories",
"All conditions must match before this tier is used.": "All conditions must match before this tier is used.",
@@ -381,6 +382,7 @@
"API info updated. Click \"Save Settings\" to apply.": "API info updated. Click \"Save Settings\" to apply.",
"API key": "API key",
"API Key": "API Key",
+ "API Key Filter": "API Key Filter",
"API Key (one per line for batch mode)": "API Key (one per line for batch mode)",
"API Key (Production)": "API Key (Production)",
"API Key (Sandbox)": "API Key (Sandbox)",
@@ -1985,7 +1987,7 @@
"Filter models by provider, group, type, endpoint, and tags.": "Filter models by provider, group, type, endpoint, and tags.",
"Filter models by type, endpoint, vendor, group and tags": "Filter models by type, endpoint, vendor, group and tags",
"Filter models...": "Filter models...",
- "Filter the model analytics view by time range and user.": "Filter the model analytics view by time range and user.",
+ "Filter the model analytics view by time range, user and API key.": "Filter the model analytics view by time range, user and API key.",
"Filter the traffic flow view by time range and user.": "Filter the traffic flow view by time range and user.",
"Filter...": "Filter...",
"Filters": "Filters",
@@ -2847,6 +2849,7 @@
"No apps match the selected filters": "No apps match the selected filters",
"No Auth": "No Auth",
"No available models": "No available models",
+ "No API key found.": "No API key found.",
"No available Web chat links": "No available Web chat links",
"No backup": "No backup",
"No base input price": "No base input price",
@@ -3984,6 +3987,7 @@
"Search": "Search",
"Search by name or URL...": "Search by name or URL...",
"Search by order number...": "Search by order number...",
+ "Search API keys...": "Search API keys...",
"Search channel type...": "Search channel type...",
"Search chat presets...": "Search chat presets...",
"Search colors...": "Search colors...",
diff --git a/web/src/i18n/locales/fr.json b/web/src/i18n/locales/fr.json
index 443b3fa1b55f..5a5cdce5106e 100644
--- a/web/src/i18n/locales/fr.json
+++ b/web/src/i18n/locales/fr.json
@@ -279,6 +279,7 @@
"Ali": "Alibaba Bailian",
"Alipay": "Alipay",
"All": "Tout",
+ "All API keys": "Toutes les clés API",
"All API tokens": "Tous les jetons API",
"All categories": "Toutes catégories",
"All conditions must match before this tier is used.": "Toutes les conditions doivent correspondre avant que ce palier soit utilisé.",
@@ -381,6 +382,7 @@
"API info updated. Click \"Save Settings\" to apply.": "Informations API mises à jour. Cliquez sur \"Enregistrer les paramètres\" pour appliquer.",
"API key": "Clé API",
"API Key": "Clé API",
+ "API Key Filter": "Filtre de clé API",
"API Key (one per line for batch mode)": "Clé API (une par ligne pour le mode batch)",
"API Key (Production)": "Clé API (Production)",
"API Key (Sandbox)": "Clé API (Sandbox)",
@@ -1985,7 +1987,7 @@
"Filter models by provider, group, type, endpoint, and tags.": "Filtrer les modèles par fournisseur, groupe, type, endpoint et tags.",
"Filter models by type, endpoint, vendor, group and tags": "Filtrer les modèles par type, point d'accès, fournisseur, groupe et tags",
"Filter models...": "Filtrer les modèles...",
- "Filter the model analytics view by time range and user.": "Filtrez la vue d’analyse des modèles par période et utilisateur.",
+ "Filter the model analytics view by time range, user and API key.": "Filtrez la vue d’analyse des modèles par période, utilisateur et clé API.",
"Filter the traffic flow view by time range and user.": "Filtrez la vue du flux de trafic par plage horaire et utilisateur.",
"Filter...": "Filtrer...",
"Filters": "Filtres",
@@ -2844,6 +2846,7 @@
"No API routes configured": "Aucune route API configurée",
"No API tokens": "Aucun jeton API",
"No app usage data available for this model.": "Aucune donnée d'utilisation d'application n'est disponible pour ce modèle.",
+ "No API key found.": "Aucune clé API trouvée.",
"No apps match the selected filters": "Aucune application ne correspond aux filtres",
"No Auth": "Sans auth",
"No available models": "Aucun modèle disponible",
@@ -3984,6 +3987,7 @@
"Search": "Rechercher",
"Search by name or URL...": "Rechercher par nom ou URL...",
"Search by order number...": "Rechercher par numéro de commande...",
+ "Search API keys...": "Rechercher des clés API...",
"Search channel type...": "Rechercher un type de canal...",
"Search chat presets...": "Rechercher des préréglages de chat...",
"Search colors...": "Rechercher des couleurs...",
diff --git a/web/src/i18n/locales/ja.json b/web/src/i18n/locales/ja.json
index c15de5534b82..49c45f64a3e3 100644
--- a/web/src/i18n/locales/ja.json
+++ b/web/src/i18n/locales/ja.json
@@ -279,6 +279,7 @@
"Ali": "アリババ百炼",
"Alipay": "Alipay",
"All": "すべて",
+ "All API keys": "すべての API キー",
"All API tokens": "すべての API キー",
"All categories": "すべてのカテゴリ",
"All conditions must match before this tier is used.": "この段階を使用するには、すべての条件に一致する必要があります。",
@@ -381,6 +382,7 @@
"API info updated. Click \"Save Settings\" to apply.": "API情報が更新されました。「Save Settings」をクリックして適用してください。",
"API key": "APIキー",
"API Key": "APIキー",
+ "API Key Filter": "API キー フィルター",
"API Key (one per line for batch mode)": "API キー (バッチモード時は1行に1つ)",
"API Key (Production)": "APIキー(本番)",
"API Key (Sandbox)": "APIキー(サンドボックス)",
@@ -1985,7 +1987,7 @@
"Filter models by provider, group, type, endpoint, and tags.": "プロバイダー、グループ、タイプ、エンドポイント、タグでモデルを絞り込みます。",
"Filter models by type, endpoint, vendor, group and tags": "タイプ、エンドポイント、ベンダー、グループ、タグでモデルをフィルタリング",
"Filter models...": "モデルをフィルタリング...",
- "Filter the model analytics view by time range and user.": "時間範囲とユーザーでモデル分析ビューを絞り込みます。",
+ "Filter the model analytics view by time range, user and API key.": "時間範囲、ユーザー、API キーでモデル分析ビューを絞り込みます。",
"Filter the traffic flow view by time range and user.": "時間範囲とユーザーでトラフィックフロー表示を絞り込みます。",
"Filter...": "フィルター…",
"Filters": "フィルター",
@@ -2841,6 +2843,7 @@
"No API key yet": "API キーはまだありません",
"No API keys available. Create your first API key to get started.": "利用可能なAPIキーがありません。最初のAPIキーを作成して開始してください。",
"No API Keys Found": "APIキーが見つかりません",
+ "No API key found.": "API キーが見つかりません。",
"No API routes configured": "APIルートが設定されていません",
"No API tokens": "API キーなし",
"No app usage data available for this model.": "このモデルのアプリ利用データはまだありません。",
@@ -3984,6 +3987,7 @@
"Search": "検索",
"Search by name or URL...": "名前またはURLで検索...",
"Search by order number...": "注文番号で検索...",
+ "Search API keys...": "API キーを検索...",
"Search channel type...": "チャネルタイプを検索...",
"Search chat presets...": "チャットプリセットを検索...",
"Search colors...": "色を検索...",
diff --git a/web/src/i18n/locales/ru.json b/web/src/i18n/locales/ru.json
index a1c18a35657e..18b7d267659d 100644
--- a/web/src/i18n/locales/ru.json
+++ b/web/src/i18n/locales/ru.json
@@ -279,6 +279,7 @@
"Ali": "Alibaba Байлянь",
"Alipay": "Alipay",
"All": "Все",
+ "All API keys": "Все API-ключи",
"All API tokens": "Все API-ключи",
"All categories": "Все категории",
"All conditions must match before this tier is used.": "Все условия должны совпасть, прежде чем будет использован этот уровень.",
@@ -381,6 +382,7 @@
"API info updated. Click \"Save Settings\" to apply.": "Информация API обновлена. Нажмите «Сохранить настройки», чтобы применить.",
"API key": "Ключ API",
"API Key": "Ключ API",
+ "API Key Filter": "Фильтр API-ключа",
"API Key (one per line for batch mode)": "Ключ API (по одному на строку для пакетного режима)",
"API Key (Production)": "API-ключ (Продакшн)",
"API Key (Sandbox)": "API-ключ (Песочница)",
@@ -1985,7 +1987,7 @@
"Filter models by provider, group, type, endpoint, and tags.": "Фильтруйте модели по поставщику, группе, типу, endpoint и тегам.",
"Filter models by type, endpoint, vendor, group and tags": "Фильтровать модели по типу, точке доступа, поставщику, группе и тегам",
"Filter models...": "Фильтровать модели...",
- "Filter the model analytics view by time range and user.": "Фильтруйте представление аналитики моделей по периоду и пользователю.",
+ "Filter the model analytics view by time range, user and API key.": "Фильтруйте представление аналитики моделей по периоду, пользователю и API-ключу.",
"Filter the traffic flow view by time range and user.": "Фильтруйте представление потока трафика по диапазону времени и пользователю.",
"Filter...": "Фильтр...",
"Filters": "Фильтры",
@@ -2842,6 +2844,7 @@
"No API keys available. Create your first API key to get started.": "Нет доступных ключей API. Создайте свой первый ключ API, чтобы начать.",
"No API Keys Found": "Ключи API не найдены",
"No API routes configured": "Нет настроенных маршрутов API",
+ "No API key found.": "API-ключ не найден.",
"No API tokens": "Нет API-ключей",
"No app usage data available for this model.": "Данные об использовании приложений для этой модели пока недоступны.",
"No apps match the selected filters": "Нет приложений, соответствующих фильтрам",
@@ -3984,6 +3987,7 @@
"Search": "Поиск",
"Search by name or URL...": "Поиск по имени или URL...",
"Search by order number...": "Поиск по номеру заказа...",
+ "Search API keys...": "Поиск API-ключей...",
"Search channel type...": "Поиск типа канала...",
"Search chat presets...": "Поиск предустановок чата...",
"Search colors...": "Поиск цветов...",
diff --git a/web/src/i18n/locales/vi.json b/web/src/i18n/locales/vi.json
index 19cdddb1621d..09ffb0dad559 100644
--- a/web/src/i18n/locales/vi.json
+++ b/web/src/i18n/locales/vi.json
@@ -279,6 +279,7 @@
"Ali": "Alibaba Bailian",
"Alipay": "Alipay",
"All": "All",
+ "All API keys": "Tất cả Khóa API",
"All API tokens": "Tất cả khóa API",
"All categories": "Tất cả danh mục",
"All conditions must match before this tier is used.": "Tất cả điều kiện phải khớp trước khi tầng này được sử dụng.",
@@ -380,6 +381,7 @@
"API info saved successfully": "Đã lưu thông tin API thành công",
"API info updated. Click \"Save Settings\" to apply.": "Thông tin API đã được cập nhật. Nhấp vào \"Lưu Cài đặt\" để áp dụng.",
"API key": "Khóa API",
+ "API Key Filter": "Bộ lọc Khóa API",
"API Key": "Khóa API",
"API Key (one per line for batch mode)": "Khóa API (mỗi khóa một dòng cho chế độ hàng loạt)",
"API Key (Production)": "API Key (Sản xuất)",
@@ -1985,7 +1987,7 @@
"Filter models by provider, group, type, endpoint, and tags.": "Lọc mô hình theo nhà cung cấp, nhóm, loại, endpoint và thẻ.",
"Filter models by type, endpoint, vendor, group and tags": "Lọc mô hình theo loại, endpoint, nhà cung cấp, nhóm và thẻ",
"Filter models...": "Lọc mô hình...",
- "Filter the model analytics view by time range and user.": "Lọc chế độ xem phân tích mô hình theo khoảng thời gian và người dùng.",
+ "Filter the model analytics view by time range, user and API key.": "Lọc chế độ xem phân tích mô hình theo khoảng thời gian, người dùng và Khóa API.",
"Filter the traffic flow view by time range and user.": "Lọc chế độ xem luồng lưu lượng theo khoảng thời gian và người dùng.",
"Filter...": "Lọc...",
"Filters": "Bộ lọc",
@@ -2844,6 +2846,7 @@
"No API routes configured": "Chưa có tuyến API nào được cấu hình",
"No API tokens": "Không có khóa API",
"No app usage data available for this model.": "Chưa có dữ liệu sử dụng ứng dụng cho mô hình này.",
+ "No API key found.": "Không tìm thấy Khóa API.",
"No apps match the selected filters": "Không có ứng dụng phù hợp bộ lọc",
"No Auth": "Không xác thực",
"No available models": "Không có mô hình khả dụng",
@@ -3984,6 +3987,7 @@
"Search": "Tìm kiếm",
"Search by name or URL...": "Tìm kiếm theo tên hoặc URL...",
"Search by order number...": "Tìm kiếm theo số đơn hàng...",
+ "Search API keys...": "Tìm kiếm Khóa API...",
"Search channel type...": "Tìm loại kênh...",
"Search chat presets...": "Tìm kiếm cài đặt sẵn trò chuyện...",
"Search colors...": "Tìm kiếm màu sắc...",
diff --git a/web/src/i18n/locales/zh.json b/web/src/i18n/locales/zh.json
index ee80b960bd2c..2471ea5a7acc 100644
--- a/web/src/i18n/locales/zh.json
+++ b/web/src/i18n/locales/zh.json
@@ -279,6 +279,7 @@
"Ali": "阿里百炼",
"Alipay": "支付宝",
"All": "全部",
+ "All API keys": "全部 API 密钥",
"All API tokens": "全部 API 密钥",
"All categories": "全部分类",
"All conditions must match before this tier is used.": "所有条件都匹配后才会使用此阶梯。",
@@ -381,6 +382,7 @@
"API info updated. Click \"Save Settings\" to apply.": "API 信息已更新。点击 \"保存设置\" 以应用。",
"API key": "API 密钥",
"API Key": "API 密钥",
+ "API Key Filter": "API 密钥筛选",
"API Key (one per line for batch mode)": "API 密钥(批量模式下每行一个)",
"API Key (Production)": "API 密钥(生产)",
"API Key (Sandbox)": "API 密钥(沙盒)",
@@ -1985,7 +1987,7 @@
"Filter models by provider, group, type, endpoint, and tags.": "按供应商、分组、类型、端点和标签筛选模型。",
"Filter models by type, endpoint, vendor, group and tags": "按类型、端点、供应商、分组和标签筛选模型",
"Filter models...": "筛选模型...",
- "Filter the model analytics view by time range and user.": "按时间范围和用户筛选模型分析视图。",
+ "Filter the model analytics view by time range, user and API key.": "按时间范围、用户和 API 密钥筛选模型分析视图。",
"Filter the traffic flow view by time range and user.": "按时间范围和用户筛选分流图视图。",
"Filter...": "筛选...",
"Filters": "筛选器",
@@ -2846,6 +2848,7 @@
"No app usage data available for this model.": "该模型暂无应用使用数据。",
"No apps match the selected filters": "没有匹配筛选条件的应用",
"No Auth": "无认证",
+ "No API key found.": "未找到 API 密钥。",
"No available models": "没有可用模型",
"No available Web chat links": "没有可用的 Web 聊天链接",
"No backup": "无备份",
@@ -3984,6 +3987,7 @@
"Search": "搜索",
"Search by name or URL...": "按名称或 URL 搜索...",
"Search by order number...": "按订单号搜索...",
+ "Search API keys...": "搜索 API 密钥...",
"Search channel type...": "搜索渠道类型...",
"Search chat presets...": "搜索聊天预设...",
"Search colors...": "搜索颜色...",