1- import { isFreeModel , kiloExclusiveModels , preferredModels } from '@/lib/ai-gateway/models' ;
1+ import {
2+ isFreeModel ,
3+ isPdfSupportingModel ,
4+ kiloExclusiveModels ,
5+ preferredModels ,
6+ } from '@/lib/ai-gateway/models' ;
27import PROVIDERS from '@/lib/ai-gateway/providers/provider-definitions' ;
38import type { OpenRouterModel } from '@/lib/organizations/organization-types' ;
49import {
@@ -19,35 +24,50 @@ import { AUTO_MODELS } from '@/lib/ai-gateway/kilo-auto';
1924export { normalizeModelId } from '@/lib/ai-gateway/model-utils' ;
2025
2126function buildAutoModels ( ) : OpenRouterModel [ ] {
22- return AUTO_MODELS . map ( m => ( {
23- id : m . id ,
24- name : m . name ,
25- created : 0 ,
26- description : m . description ,
27- architecture : {
28- input_modalities : m . supports_images ? [ 'text' , 'image' ] : [ 'text' ] ,
29- output_modalities : [ 'text' ] ,
30- tokenizer : 'Other' ,
31- } ,
32- top_provider : {
33- is_moderated : false ,
27+ return AUTO_MODELS . map ( m => {
28+ const input_modalities = [ 'text' ] ;
29+ if ( m . supports_images ) {
30+ input_modalities . push ( 'image' ) ;
31+ }
32+ if ( m . supports_pdf ) {
33+ input_modalities . push ( 'pdf' ) ;
34+ }
35+ return {
36+ id : m . id ,
37+ name : m . name ,
38+ created : 0 ,
39+ description : m . description ,
40+ architecture : {
41+ input_modalities : input_modalities ,
42+ output_modalities : [ 'text' ] ,
43+ tokenizer : 'Other' ,
44+ } ,
45+ top_provider : {
46+ is_moderated : false ,
47+ context_length : m . context_length ,
48+ max_completion_tokens : m . max_completion_tokens ,
49+ } ,
50+ pricing : {
51+ prompt : m . prompt_price ,
52+ completion : m . completion_price ,
53+ input_cache_read : m . input_cache_read_price ,
54+ input_cache_write : m . input_cache_write_price ,
55+ request : '0' ,
56+ image : '0' ,
57+ web_search : '0' ,
58+ internal_reasoning : '0' ,
59+ } ,
3460 context_length : m . context_length ,
35- max_completion_tokens : m . max_completion_tokens ,
36- } ,
37- pricing : {
38- prompt : m . prompt_price ,
39- completion : m . completion_price ,
40- input_cache_read : m . input_cache_read_price ,
41- input_cache_write : m . input_cache_write_price ,
42- request : '0' ,
43- image : '0' ,
44- web_search : '0' ,
45- internal_reasoning : '0' ,
46- } ,
47- context_length : m . context_length ,
48- supported_parameters : [ 'max_tokens' , 'temperature' , 'tools' , 'reasoning' , 'include_reasoning' ] ,
49- opencode : m . opencode_settings ,
50- } ) ) ;
61+ supported_parameters : [
62+ 'max_tokens' ,
63+ 'temperature' ,
64+ 'tools' ,
65+ 'reasoning' ,
66+ 'include_reasoning' ,
67+ ] ,
68+ opencode : m . opencode_settings ,
69+ } ;
70+ } ) ;
5171}
5272
5373function enhancedModelList ( models : OpenRouterModel [ ] ) {
@@ -68,13 +88,21 @@ function enhancedModelList(models: OpenRouterModel[]) {
6888 const ageDays = ( Date . now ( ) / 1_000 - model . created ) / ( 24 * 3600 ) ;
6989 const isNew = preferredIndex >= 0 && ageDays >= 0 && ageDays < 7 ;
7090 const skipSuffix = model . name . endsWith ( ')' ) ;
91+ const addPdf =
92+ isPdfSupportingModel ( model . id ) && ! model . architecture . input_modalities . includes ( 'pdf' ) ;
7193 return {
7294 ...model ,
7395 name : skipSuffix ? model . name : isNew ? model . name + ' (new)' : model . name ,
7496 preferredIndex : preferredIndex >= 0 ? preferredIndex : undefined ,
7597 isFree : isFreeModel ( model . id ) ,
7698 opencode : model . opencode ?? getOpenCodeSettings ( model . id ) ,
7799 openclaw : model . openclaw ?? getOpenClawSettings ( model . id ) ,
100+ architecture : addPdf
101+ ? {
102+ ...model . architecture ,
103+ input_modalities : model . architecture . input_modalities . concat ( [ 'pdf' ] ) ,
104+ }
105+ : model . architecture ,
78106 } ;
79107 } ) ;
80108 const sortedModels = enhancedModels . sort ( ( a , b ) => {
0 commit comments