diff --git a/packages/db/src/schema-types.ts b/packages/db/src/schema-types.ts index 7e81f3225..e92f2fa1c 100644 --- a/packages/db/src/schema-types.ts +++ b/packages/db/src/schema-types.ts @@ -875,6 +875,17 @@ export const CustomLlmExtraHeadersSchema = z.record(z.string(), z.string()); export type CustomLlmExtraHeaders = z.infer; +// All price fields are in dollars per token (e.g. "0.000001" = $1 per million tokens), +// matching the OpenRouter pricing convention. +export const CustomLlmPricingSchema = z.object({ + prompt: z.string(), + completion: z.string(), + input_cache_read: z.string().optional(), + input_cache_write: z.string().optional(), +}); + +export type CustomLlmPricing = z.infer; + export const CustomLlmDefinitionSchema = z .object({ internal_id: z.string(), @@ -889,6 +900,7 @@ export const CustomLlmDefinitionSchema = z extra_body: CustomLlmExtraBodySchema.optional(), remove_from_body: z.array(z.string()).optional(), opencode_settings: OpenCodeSettingsSchema.optional(), + pricing: CustomLlmPricingSchema.optional(), }) .strict(); diff --git a/src/lib/custom-llm/listAvailableCustomLlms.ts b/src/lib/custom-llm/listAvailableCustomLlms.ts index bbef01f76..f2fda37c6 100644 --- a/src/lib/custom-llm/listAvailableCustomLlms.ts +++ b/src/lib/custom-llm/listAvailableCustomLlms.ts @@ -19,13 +19,14 @@ function convert(publicId: string, model: CustomLlmDefinition) { instruct_type: null, }, pricing: { - prompt: '0.0000000', - completion: '0.0000000', + prompt: model.pricing?.prompt ?? '0.0000000', + completion: model.pricing?.completion ?? '0.0000000', request: '0', image: '0', web_search: '0', internal_reasoning: '0', - input_cache_read: '0.00000000', + input_cache_read: model.pricing?.input_cache_read ?? '0.00000000', + input_cache_write: model.pricing?.input_cache_write ?? '0.00000000', }, top_provider: { context_length: model.context_length,