Files
one-api-workers/type.d.ts
T
dreamhunter2333andClaude Opus 4.5 bdb4825cdc feat: 修复 Codex 缓存 token 计费并优化代码结构
- 修复 Codex API 缓存 token 重复计费问题 (input_tokens 包含 cached_tokens)
- 提取共享代码到 src/providers/shared/usage-utils.ts,消除重复
- 前端定价页面增加缓存倍率配置列
- 修复 var 为 const,favicon 改为云图标

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 21:06:44 +08:00

91 lines
1.6 KiB
TypeScript

type Variables = {
lang: string | undefined | null
}
type CloudflareBindings = {
DB: D1Database;
ASSETS: Fetcher;
ADMIN_TOKEN: string;
}
type HonoCustomType = {
"Bindings": CloudflareBindings;
"Variables": Variables;
}
// 数据库表行的基础结构
type BaseDbRow = {
created_at: string;
updated_at: string;
}
// channel_config 表的行结构
type ChannelConfigRow = BaseDbRow & {
key: string;
value: string; // JSON 字符串,解析后为 ChannelConfig 类型
}
// api_token 表的行结构
type ApiTokenRow = BaseDbRow & {
key: string;
value: string; // JSON 字符串,解析后为 ApiTokenData 类型
usage: number;
}
type ChannelType =
| "azure-openai"
| "openai"
| "claude"
| "openai-responses"
| "azure-openai-responses"
| undefined
| null;
type ChannelConfig = {
name: string;
type: ChannelType;
endpoint: string;
api_key: string;
api_version?: string;
deployment_mapper: Record<string, string>;
model_pricing?: Record<string, ModelPricing>;
}
type ChannelConfigMap = {
[key: string]: ChannelConfig;
}
type OpenAIResponse = {
usage?: Usage
}
type Usage = {
prompt_tokens?: number,
completion_tokens?: number,
total_tokens?: number,
cached_tokens?: number,
}
type AwslKeyPayload = {
channel_key: string;
multipler: number | undefined | null;
}
type CommonResponse = {
success?: boolean;
message?: string;
data?: any;
}
type ModelPricing = {
input: number;
output: number;
cache?: number;
}
type ApiTokenData = {
name: string;
channel_keys: string[];
total_quota: number;
}