File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import {
10
10
generateErrorResponse ,
11
11
generateInvalidProviderResponseError ,
12
12
} from '../utils' ;
13
+ import { transformReasoningParams } from './utils' ;
13
14
14
15
export const OpenrouterChatCompleteConfig : ProviderConfig = {
15
16
model : {
@@ -48,6 +49,15 @@ export const OpenrouterChatCompleteConfig: ProviderConfig = {
48
49
} ,
49
50
reasoning : {
50
51
param : 'reasoning' ,
52
+ transform : ( params : Params ) => {
53
+ return transformReasoningParams ( params ) ;
54
+ } ,
55
+ } ,
56
+ reasoning_effort : {
57
+ param : 'reasoning' ,
58
+ transform : ( params : Params ) => {
59
+ return transformReasoningParams ( params ) ;
60
+ } ,
51
61
} ,
52
62
top_p : {
53
63
param : 'top_p' ,
@@ -77,6 +87,17 @@ export const OpenrouterChatCompleteConfig: ProviderConfig = {
77
87
param : 'stream' ,
78
88
default : false ,
79
89
} ,
90
+ stream_options : {
91
+ param : 'usage' ,
92
+ transform : ( params : Params ) => {
93
+ if ( params . stream_options ?. include_usage ) {
94
+ return {
95
+ include : params . stream_options ?. include_usage ,
96
+ } ;
97
+ }
98
+ return null ;
99
+ } ,
100
+ } ,
80
101
response_format : {
81
102
param : 'response_format' ,
82
103
} ,
Original file line number Diff line number Diff line change
1
+ import { Params } from '../../types/requestBody' ;
2
+
3
+ interface OpenRouterParams extends Params {
4
+ reasoning ?: OpenrouterReasoningParam ;
5
+ }
6
+
7
+ type OpenrouterReasoningParam = {
8
+ effort ?: 'low' | 'medium' | 'high' | string ;
9
+ max_tokens ?: number ;
10
+ exclude ?: boolean ;
11
+ } ;
12
+
13
+ export const transformReasoningParams = ( params : OpenRouterParams ) => {
14
+ let reasoning : OpenrouterReasoningParam = { ...params . reasoning } ;
15
+ if ( params . reasoning_effort ) {
16
+ reasoning . effort = params . reasoning_effort ;
17
+ }
18
+ return Object . keys ( reasoning ) . length > 0 ? reasoning : null ;
19
+ } ;
You can’t perform that action at this time.
0 commit comments