Merge pull request #4385 from yardbirds0/feat/upstream-billing-probe

feat: 增加上游 Sub2API 计费倍率探测与账号展示
This commit is contained in:
Wesley Liddick
2026-07-16 10:27:45 +08:00
committed by GitHub
49 changed files with 5747 additions and 74 deletions
+41 -2
View File
@@ -20,7 +20,9 @@ import type {
CodexSessionImportResult,
OpenAICodexPATCreateRequest,
CheckMixedChannelRequest,
CheckMixedChannelResponse
CheckMixedChannelResponse,
UpstreamBillingProbeResult,
UpstreamBillingProbeSettings
} from '@/types'
/**
@@ -848,6 +850,38 @@ export async function createSparkShadow(parentId: number, payload: SparkShadowCr
return data
}
export async function getUpstreamBillingProbeSettings(): Promise<UpstreamBillingProbeSettings> {
const { data } = await apiClient.get<UpstreamBillingProbeSettings>('/admin/accounts/upstream-billing-probe/settings')
return data
}
export async function updateUpstreamBillingProbeSettings(
settings: UpstreamBillingProbeSettings
): Promise<UpstreamBillingProbeSettings> {
const { data } = await apiClient.put<UpstreamBillingProbeSettings>(
'/admin/accounts/upstream-billing-probe/settings',
settings
)
return data
}
export async function setUpstreamBillingProbeEnabled(id: number, enabled: boolean): Promise<void> {
await apiClient.put(`/admin/accounts/${id}/upstream-billing-probe`, { enabled })
}
export async function probeUpstreamBilling(id: number): Promise<UpstreamBillingProbeResult> {
const { data } = await apiClient.post<UpstreamBillingProbeResult>(`/admin/accounts/${id}/upstream-billing-probe`)
return data
}
export async function probeUpstreamBillingBatch(accountIds: number[]): Promise<UpstreamBillingProbeResult[]> {
const { data } = await apiClient.post<{ results: UpstreamBillingProbeResult[] }>(
'/admin/accounts/upstream-billing-probe/batch',
{ account_ids: accountIds }
)
return data.results
}
export const accountsAPI = {
list,
listWithEtag,
@@ -894,7 +928,12 @@ export const accountsAPI = {
revertProxyFallback,
queryOpenAIQuota,
resetOpenAIQuota,
createSparkShadow
createSparkShadow,
getUpstreamBillingProbeSettings,
updateUpstreamBillingProbeSettings,
setUpstreamBillingProbeEnabled,
probeUpstreamBilling,
probeUpstreamBillingBatch
}
export default accountsAPI