@@ -78,10 +78,7 @@ export async function textToImage(args: TextToImageArgs, options?: TextToImageOp
78
78
79
79
if ( res && typeof res === "object" ) {
80
80
if ( args . provider === "black-forest-labs" && "polling_url" in res && typeof res . polling_url === "string" ) {
81
- if ( options ?. outputType === "url" ) {
82
- return res . polling_url ;
83
- }
84
- return await pollBflResponse ( res . polling_url ) ;
81
+ return await pollBflResponse ( res . polling_url , options ?. outputType ) ;
85
82
}
86
83
if ( args . provider === "fal-ai" && "images" in res && Array . isArray ( res . images ) && res . images [ 0 ] . url ) {
87
84
if ( options ?. outputType === "url" ) {
@@ -132,7 +129,7 @@ export async function textToImage(args: TextToImageArgs, options?: TextToImageOp
132
129
return res ;
133
130
}
134
131
135
- async function pollBflResponse ( url : string ) : Promise < Blob > {
132
+ async function pollBflResponse ( url : string , outputType ?: "url" | "blob" ) : Promise < Blob > {
136
133
const urlObj = new URL ( url ) ;
137
134
for ( let step = 0 ; step < 5 ; step ++ ) {
138
135
await delay ( 1000 ) ;
@@ -155,6 +152,9 @@ async function pollBflResponse(url: string): Promise<Blob> {
155
152
"sample" in payload . result &&
156
153
typeof payload . result . sample === "string"
157
154
) {
155
+ if ( outputType === "url" ) {
156
+ return payload . result . sample ;
157
+ }
158
158
const image = await fetch ( payload . result . sample ) ;
159
159
return await image . blob ( ) ;
160
160
}
0 commit comments