Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/db/src/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,17 @@ export const CustomLlmExtraHeadersSchema = z.record(z.string(), z.string());

export type CustomLlmExtraHeaders = z.infer<typeof CustomLlmExtraHeadersSchema>;

// 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<typeof CustomLlmPricingSchema>;

export const CustomLlmDefinitionSchema = z
.object({
internal_id: z.string(),
Expand All @@ -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();

Expand Down
7 changes: 4 additions & 3 deletions src/lib/custom-llm/listAvailableCustomLlms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading