File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ export async function chatCompletionsPost(params: {
4141
4242 try {
4343 // Parse request body
44- let body : unknown
44+ let body : { }
4545 try {
4646 body = await req . json ( )
4747 } catch ( error ) {
@@ -59,6 +59,9 @@ export async function chatCompletionsPost(params: {
5959 )
6060 }
6161
62+ const bodyStream = 'stream' in body && body . stream
63+ const runId = ( body as any ) ?. codebuff_metadata ?. run_id
64+
6265 // Extract and validate API key
6366 const apiKey = extractApiKeyFromHeader ( req )
6467 if ( ! apiKey ) {
@@ -101,8 +104,8 @@ export async function chatCompletionsPost(params: {
101104 event : AnalyticsEvent . CHAT_COMPLETIONS_REQUEST ,
102105 userId,
103106 properties : {
104- hasStream : ! ! ( body as any ) . stream ,
105- hasRunId : ! ! ( body as any ) . codebuff_metadata ?. run_id ,
107+ hasStream : ! ! bodyStream ,
108+ hasRunId : ! ! runId ,
106109 } ,
107110 logger,
108111 } )
@@ -191,7 +194,7 @@ export async function chatCompletionsPost(params: {
191194
192195 // Handle streaming vs non-streaming
193196 try {
194- if ( ( body as any ) . stream ) {
197+ if ( bodyStream ) {
195198 // Streaming request
196199 const stream = await handleOpenRouterStream ( {
197200 body,
@@ -252,7 +255,7 @@ export async function chatCompletionsPost(params: {
252255 properties : {
253256 error : error instanceof Error ? error . message : 'Unknown error' ,
254257 agentId,
255- streaming : ( body as any ) . stream ,
258+ streaming : bodyStream ,
256259 } ,
257260 logger,
258261 } )
You can’t perform that action at this time.
0 commit comments