import { z } from "zod/v4"; import { FeatureUsageType } from "../featureEnums"; export const CreditSchemaItemSchema = z.object({ metered_feature_id: z.string(), feature_amount: z.number().optional(), credit_amount: z.number(), }); const MarkupEntrySchema = z.object({ markup: z.number().min(-100), // percentage markup, e.g. 20 for 20%, -100 for free }); export const ProviderMarkupsSchema = z .record( z.string(), // Provider key from the model name, e.g. "openrouter" in "openrouter/anthropic/claude" MarkupEntrySchema, ) .nullish(); export const CreditSystemConfigSchema = z.object({ schema: z.array( z.object({ metered_feature_id: z.string(), credit_amount: z.number(), }), ), usage_type: z.nativeEnum(FeatureUsageType), default_markup: z.number().min(-100).optional(), provider_markups: ProviderMarkupsSchema, }); export const ModelMarkupsSchema = z .record( z.string(), // Represents the model name in "provider/model" format, e.g. "anthropic/claude-2" MarkupEntrySchema.extend({ markup: z.number().min(-100).optional(), // Omit to inherit provider/global markup input_cost: z.number().min(0).optional(), // $/M tokens, required for custom/ models output_cost: z.number().min(0).optional(), // $/M tokens, required for custom/ models }), ) .nullish(); export type CreditSystemConfig = z.infer; export type CreditSchemaItem = z.infer; export type ModelMarkups = z.infer; export type ProviderMarkups = z.infer;