mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-21 19:43:32 +00:00
zen: peak pricing
This commit is contained in:
parent
976c185172
commit
3fd77ae980
2 changed files with 8 additions and 4 deletions
|
|
@ -1032,11 +1032,14 @@ export async function handler(
|
|||
const { inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWrite5mTokens, cacheWrite1hTokens } =
|
||||
usageInfo
|
||||
|
||||
const hour = new Date().getUTCHours()
|
||||
const modelCost =
|
||||
modelInfo.cost200K &&
|
||||
inputTokens + (cacheReadTokens ?? 0) + (cacheWrite5mTokens ?? 0) + (cacheWrite1hTokens ?? 0) > 200_000
|
||||
? modelInfo.cost200K
|
||||
: modelInfo.cost
|
||||
modelInfo.costPeak && ((hour >= 1 && hour < 4) || (hour >= 6 && hour < 10))
|
||||
? modelInfo.costPeak
|
||||
: modelInfo.cost200K &&
|
||||
inputTokens + (cacheReadTokens ?? 0) + (cacheWrite5mTokens ?? 0) + (cacheWrite1hTokens ?? 0) > 200_000
|
||||
? modelInfo.cost200K
|
||||
: modelInfo.cost
|
||||
|
||||
const inputCost = modelCost.input * inputTokens * 100
|
||||
const outputCost = modelCost.output * outputTokens * 100
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ export namespace ZenData {
|
|||
cost: ModelCostSchema,
|
||||
costMultiplier: z.number().default(1),
|
||||
cost200K: ModelCostSchema.optional(),
|
||||
costPeak: ModelCostSchema.optional(),
|
||||
allowAnonymous: z.boolean().optional(),
|
||||
byokProvider: z.enum(["openai", "anthropic", "google"]).optional(),
|
||||
stickyProvider: z.enum(["strict", "prefer"]).optional(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue