@@ -143,6 +143,9 @@ export async function handler(
143143 // Store sticky provider
144144 await stickyTracker ?. set ( providerInfo . id )
145145
146+ // Temporarily change 404 to 400 status code b/c solid start automatically override 404 response
147+ const resStatus = res . status === 404 ? 400 : res . status
148+
146149 // Scrub response headers
147150 const resHeaders = new Headers ( )
148151 const keepHeaders = [ "content-type" , "cache-control" ]
@@ -153,7 +156,7 @@ export async function handler(
153156 }
154157 logger . debug ( "STATUS: " + res . status + " " + res . statusText )
155158
156- // Handle non-streaming response for non-stream request
159+ // Handle non-streaming response
157160 if ( ! isStream ) {
158161 const responseConverter = createResponseConverter ( providerInfo . format , opts . format )
159162 const json = await res . json ( )
@@ -168,23 +171,7 @@ export async function handler(
168171 await trackUsage ( authInfo , modelInfo , providerInfo , tokensInfo )
169172 await reload ( authInfo )
170173 return new Response ( body , {
171- status : res . status ,
172- statusText : res . statusText ,
173- headers : resHeaders ,
174- } )
175- }
176-
177- // Handle non-streaming response for stream request
178- const contentType = res . headers . get ( "content-type" ) ?? ""
179- if ( ! contentType . includes ( "text/event-stream" ) ) {
180- const body = await res . text ( )
181- logger . metric ( { response_length : body . length } )
182- logger . debug ( "RESPONSE: " + body )
183- dataDumper ?. provideResponse ( body )
184- dataDumper ?. flush ( )
185- await rateLimiter ?. track ( )
186- return new Response ( body , {
187- status : res . status ,
174+ status : resStatus ,
188175 statusText : res . statusText ,
189176 headers : resHeaders ,
190177 } )
@@ -262,7 +249,7 @@ export async function handler(
262249 } )
263250
264251 return new Response ( stream , {
265- status : res . status ,
252+ status : resStatus ,
266253 statusText : res . statusText ,
267254 headers : resHeaders ,
268255 } )
0 commit comments