From 41604e75a2b6eaa76b5e7776e0d841da2fe3b486 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:21:25 +0000 Subject: [PATCH 1/2] feat(db): add optional pricing field to CustomLlmDefinitionSchema --- packages/db/src/schema-types.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/db/src/schema-types.ts b/packages/db/src/schema-types.ts index 7e81f3225..19f51e829 100644 --- a/packages/db/src/schema-types.ts +++ b/packages/db/src/schema-types.ts @@ -875,6 +875,13 @@ export const CustomLlmExtraHeadersSchema = z.record(z.string(), z.string()); export type CustomLlmExtraHeaders = z.infer; +export const CustomLlmPricingSchema = z.object({ + prompt: z.string(), + completion: z.string(), +}); + +export type CustomLlmPricing = z.infer; + export const CustomLlmDefinitionSchema = z .object({ internal_id: z.string(), @@ -889,6 +896,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(); From 0159fe826c0ec38a02aa6ffa6b689582bd439e82 Mon Sep 17 00:00:00 2001 From: "kiloconnect[bot]" <240665456+kiloconnect[bot]@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:25:56 +0000 Subject: [PATCH 2/2] feat(db): add cache read/write pricing fields and wire up conversion --- packages/db/src/schema-types.ts | 4 ++++ src/lib/custom-llm/listAvailableCustomLlms.ts | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/db/src/schema-types.ts b/packages/db/src/schema-types.ts index 19f51e829..e92f2fa1c 100644 --- a/packages/db/src/schema-types.ts +++ b/packages/db/src/schema-types.ts @@ -875,9 +875,13 @@ 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; 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,