@@ -20,7 +20,13 @@ interface ReplicateOutput {
2020	output : string ; 
2121} 
2222
23- const  SUPPORTED_PROVIDERS  =  [ "fal-ai" ,  "replicate" ]  as  const  satisfies  readonly  InferenceProvider [ ] ; 
23+ interface  NovitaOutput  { 
24+ 	video : { 
25+ 		video_url : string ; 
26+ 	} ; 
27+ } 
28+ 
29+ const  SUPPORTED_PROVIDERS  =  [ "fal-ai" ,  "novita" ,  "replicate" ]  as  const  satisfies  readonly  InferenceProvider [ ] ; 
2430
2531export  async  function  textToVideo ( args : TextToVideoArgs ,  options ?: Options ) : Promise < TextToVideoOutput >  { 
2632	if  ( ! args . provider  ||  ! typedInclude ( SUPPORTED_PROVIDERS ,  args . provider ) )  { 
@@ -30,14 +36,13 @@ export async function textToVideo(args: TextToVideoArgs, options?: Options): Pro
3036	} 
3137
3238	const  payload  = 
33- 		args . provider  ===  "fal-ai"  ||  args . provider  ===  "replicate" 
39+ 		args . provider  ===  "fal-ai"  ||  args . provider  ===  "replicate"   ||   args . provider   ===   "novita" 
3440			? {  ...omit ( args ,  [ "inputs" ,  "parameters" ] ) ,  ...args . parameters ,  prompt : args . inputs  } 
3541			: args ; 
36- 	const  res  =  await  request < FalAiOutput  |  ReplicateOutput > ( payload ,  { 
42+ 	const  res  =  await  request < FalAiOutput  |  ReplicateOutput   |   NovitaOutput > ( payload ,  { 
3743		...options , 
3844		task : "text-to-video" , 
3945	} ) ; 
40- 
4146	if  ( args . provider  ===  "fal-ai" )  { 
4247		const  isValidOutput  = 
4348			typeof  res  ===  "object"  && 
@@ -51,7 +56,22 @@ export async function textToVideo(args: TextToVideoArgs, options?: Options): Pro
5156		if  ( ! isValidOutput )  { 
5257			throw  new  InferenceOutputError ( "Expected { video: { url: string } }" ) ; 
5358		} 
54- 		const  urlResponse  =  await  fetch ( res . video . url ) ; 
59+ 		const  urlResponse  =  await  fetch ( ( res  as  FalAiOutput ) . video . url ) ; 
60+ 		return  await  urlResponse . blob ( ) ; 
61+ 	}  else  if  ( args . provider  ===  "novita" )  { 
62+ 		const  isValidOutput  = 
63+ 			typeof  res  ===  "object"  && 
64+ 			! ! res  && 
65+ 			"video"  in  res  && 
66+ 			typeof  res . video  ===  "object"  && 
67+ 			! ! res . video  && 
68+ 			"video_url"  in  res . video  && 
69+ 			typeof  res . video . video_url  ===  "string"  && 
70+ 			isUrl ( res . video . video_url ) ; 
71+ 		if  ( ! isValidOutput )  { 
72+ 			throw  new  InferenceOutputError ( "Expected { video: { video_url: string } }" ) ; 
73+ 		} 
74+ 		const  urlResponse  =  await  fetch ( ( res  as  NovitaOutput ) . video . video_url ) ; 
5575		return  await  urlResponse . blob ( ) ; 
5676	}  else  { 
5777		/// TODO: Replicate: handle the case where the generation request "times out" / is async (ie output is null) 
0 commit comments