Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
beceb45d
Unverified
Commit
beceb45d
authored
Feb 18, 2026
by
Wesley Liddick
Committed by
GitHub
Feb 18, 2026
Browse files
Merge pull request #591 from miraserver/main
feat: add Cache TTL Override per account
parents
9450edf4
3d1f03c2
Changes
25
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/admin/usage/UsageTable.vue
View file @
beceb45d
...
...
@@ -71,6 +71,7 @@
<svg
class=
"h-3.5 w-3.5 text-amber-500"
fill=
"none"
stroke=
"currentColor"
viewBox=
"0 0 24 24"
><path
stroke-linecap=
"round"
stroke-linejoin=
"round"
stroke-width=
"2"
d=
"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"
/></svg>
<span
class=
"font-medium text-amber-600 dark:text-amber-400"
>
{{
formatCacheTokens
(
row
.
cache_creation_tokens
)
}}
</span>
<span
v-if=
"row.cache_creation_1h_tokens > 0"
class=
"inline-flex items-center rounded px-1 py-px text-[10px] font-medium leading-tight bg-orange-100 text-orange-600 ring-1 ring-inset ring-orange-200 dark:bg-orange-500/20 dark:text-orange-400 dark:ring-orange-500/30"
>
1h
</span>
<span
v-if=
"row.cache_ttl_overridden"
:title=
"t('usage.cacheTtlOverriddenHint')"
class=
"inline-flex items-center rounded px-1 py-px text-[10px] font-medium leading-tight bg-rose-100 text-rose-600 ring-1 ring-inset ring-rose-200 dark:bg-rose-500/20 dark:text-rose-400 dark:ring-rose-500/30 cursor-help"
>
R
</span>
</div>
</div>
</div>
...
...
@@ -182,6 +183,13 @@
<span
class=
"font-medium text-white"
>
{{ tokenTooltipData.cache_creation_tokens.toLocaleString() }}
</span>
</div>
</div>
<div
v-if=
"tokenTooltipData && tokenTooltipData.cache_ttl_overridden"
class=
"flex items-center justify-between gap-4"
>
<span
class=
"text-gray-400 flex items-center gap-1.5"
>
{{ t('usage.cacheTtlOverriddenLabel') }}
<span
class=
"inline-flex items-center rounded px-1 py-px text-[10px] font-medium leading-tight bg-rose-500/20 text-rose-400 ring-1 ring-inset ring-rose-500/30"
>
R-{{ tokenTooltipData.cache_creation_1h_tokens > 0 ? '5m' : '1H' }}
</span>
</span>
<span
class=
"font-medium text-rose-400"
>
{{ tokenTooltipData.cache_creation_1h_tokens > 0 ? t('usage.cacheTtlOverridden1h') : t('usage.cacheTtlOverridden5m') }}
</span>
</div>
<div
v-if=
"tokenTooltipData && tokenTooltipData.cache_read_tokens > 0"
class=
"flex items-center justify-between gap-4"
>
<span
class=
"text-gray-400"
>
{{ t('admin.usage.cacheReadTokens') }}
</span>
<span
class=
"font-medium text-white"
>
{{ tokenTooltipData.cache_read_tokens.toLocaleString() }}
</span>
...
...
frontend/src/i18n/locales/en.ts
View file @
beceb45d
...
...
@@ -576,6 +576,10 @@ export default {
description
:
'
View and analyze your API usage history
'
,
costDetails
:
'
Cost Breakdown
'
,
tokenDetails
:
'
Token Breakdown
'
,
cacheTtlOverriddenHint
:
'
Cache TTL Override enabled
'
,
cacheTtlOverriddenLabel
:
'
TTL Override
'
,
cacheTtlOverridden5m
:
'
Billed as 5m
'
,
cacheTtlOverridden1h
:
'
Billed as 1h
'
,
totalRequests
:
'
Total Requests
'
,
totalTokens
:
'
Total Tokens
'
,
totalCost
:
'
Total Cost
'
,
...
...
@@ -1595,6 +1599,12 @@ export default {
sessionIdMasking
:
{
label
:
'
Session ID Masking
'
,
hint
:
'
When enabled, fixes the session ID in metadata.user_id for 15 minutes, making upstream think requests come from the same session
'
},
cacheTTLOverride
:
{
label
:
'
Cache TTL Override
'
,
hint
:
'
Force all cache creation tokens to be billed as the selected TTL tier (5m or 1h)
'
,
target
:
'
Target TTL
'
,
targetHint
:
'
Select the TTL tier for billing
'
}
},
expired
:
'
Expired
'
,
...
...
frontend/src/i18n/locales/zh.ts
View file @
beceb45d
...
...
@@ -582,6 +582,10 @@ export default {
description
:
'
查看和分析您的 API 使用历史
'
,
costDetails
:
'
成本明细
'
,
tokenDetails
:
'
Token 明细
'
,
cacheTtlOverriddenHint
:
'
缓存 TTL Override 已启用
'
,
cacheTtlOverriddenLabel
:
'
TTL 替换
'
,
cacheTtlOverridden5m
:
'
按 5m 计费
'
,
cacheTtlOverridden1h
:
'
按 1h 计费
'
,
totalRequests
:
'
总请求数
'
,
totalTokens
:
'
总 Token
'
,
totalCost
:
'
总消费
'
,
...
...
@@ -1741,6 +1745,12 @@ export default {
sessionIdMasking
:
{
label
:
'
会话 ID 伪装
'
,
hint
:
'
启用后将在 15 分钟内固定 metadata.user_id 中的 session ID,使上游认为请求来自同一会话
'
},
cacheTTLOverride
:
{
label
:
'
缓存 TTL 强制替换
'
,
hint
:
'
将所有缓存创建 token 强制按指定的 TTL 类型(5分钟或1小时)计费
'
,
target
:
'
目标 TTL
'
,
targetHint
:
'
选择计费使用的 TTL 类型
'
}
},
expired
:
'
已过期
'
,
...
...
frontend/src/types/index.ts
View file @
beceb45d
...
...
@@ -614,6 +614,10 @@ export interface Account {
// 启用后将在15分钟内固定 metadata.user_id 中的 session ID
session_id_masking_enabled
?:
boolean
|
null
// 缓存 TTL 强制替换(仅 Anthropic OAuth/SetupToken 账号有效)
cache_ttl_override_enabled
?:
boolean
|
null
cache_ttl_override_target
?:
string
|
null
// 运行时状态(仅当启用对应限制时返回)
current_window_cost
?:
number
|
null
// 当前窗口费用
active_sessions
?:
number
|
null
// 当前活跃会话数
...
...
@@ -827,6 +831,9 @@ export interface UsageLog {
// User-Agent
user_agent
:
string
|
null
// Cache TTL Override
cache_ttl_overridden
:
boolean
created_at
:
string
user
?:
User
...
...
frontend/src/views/user/UsageView.vue
View file @
beceb45d
...
...
@@ -234,6 +234,7 @@
formatCacheTokens
(
row
.
cache_creation_tokens
)
}}
</span>
<span
v-if=
"row.cache_creation_1h_tokens > 0"
class=
"inline-flex items-center rounded px-1 py-px text-[10px] font-medium leading-tight bg-orange-100 text-orange-600 ring-1 ring-inset ring-orange-200 dark:bg-orange-500/20 dark:text-orange-400 dark:ring-orange-500/30"
>
1h
</span>
<span
v-if=
"row.cache_ttl_overridden"
:title=
"t('usage.cacheTtlOverriddenHint')"
class=
"inline-flex items-center rounded px-1 py-px text-[10px] font-medium leading-tight bg-rose-100 text-rose-600 ring-1 ring-inset ring-rose-200 dark:bg-rose-500/20 dark:text-rose-400 dark:ring-rose-500/30 cursor-help"
>
R
</span>
</div>
</div>
</div>
...
...
@@ -375,6 +376,13 @@
<span
class=
"font-medium text-white"
>
{{ tokenTooltipData.cache_creation_tokens.toLocaleString() }}
</span>
</div>
</div>
<div
v-if=
"tokenTooltipData && tokenTooltipData.cache_ttl_overridden"
class=
"flex items-center justify-between gap-4"
>
<span
class=
"text-gray-400 flex items-center gap-1.5"
>
{{ t('usage.cacheTtlOverriddenLabel') }}
<span
class=
"inline-flex items-center rounded px-1 py-px text-[10px] font-medium leading-tight bg-rose-500/20 text-rose-400 ring-1 ring-inset ring-rose-500/30"
>
R-{{ tokenTooltipData.cache_creation_1h_tokens > 0 ? '5m' : '1H' }}
</span>
</span>
<span
class=
"font-medium text-rose-400"
>
{{ tokenTooltipData.cache_creation_1h_tokens > 0 ? t('usage.cacheTtlOverridden1h') : t('usage.cacheTtlOverridden5m') }}
</span>
</div>
<div
v-if=
"tokenTooltipData && tokenTooltipData.cache_read_tokens > 0"
class=
"flex items-center justify-between gap-4"
>
<span
class=
"text-gray-400"
>
{{ t('admin.usage.cacheReadTokens') }}
</span>
<span
class=
"font-medium text-white"
>
{{ tokenTooltipData.cache_read_tokens.toLocaleString() }}
</span>
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment