File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
packages/inference/src/providers Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -95,11 +95,17 @@ abstract class WavespeedAITask extends TaskProviderHelper {
9595 url ?: string ,
9696 headers ?: Record < string , string >
9797 ) : Promise < Blob > {
98- if ( ! headers ) {
98+ if ( ! url || ! headers ) {
9999 throw new InferenceClientInputError ( "Headers are required for WaveSpeed AI API calls" ) ;
100100 }
101101
102- const resultUrl = response . data . urls . get ;
102+ const parsedUrl = new URL ( url ) ;
103+ const resultPath = new URL ( response . data . urls . get ) . pathname ;
104+ /// override the base url to use the router.huggingface.co if going through huggingface router
105+ const baseUrl = `${ parsedUrl . protocol } //${ parsedUrl . host } ${
106+ parsedUrl . host === "router.huggingface.co" ? "/wavespeed" : ""
107+ } `;
108+ const resultUrl = `${ baseUrl } ${ resultPath } ` ;
103109
104110 // Poll for results until completion
105111 while ( true ) {
You can’t perform that action at this time.
0 commit comments