@@ -8,11 +8,9 @@ import {
88 toImageDataUrl ,
99} from "openclaw/plugin-sdk/image-generation" ;
1010import { isProviderApiKeyConfigured } from "openclaw/plugin-sdk/provider-auth" ;
11- import { resolveApiKeyForProvider } from "openclaw/plugin-sdk/provider-auth-runtime" ;
1211import {
1312 assertOkOrThrowHttpError ,
1413 assertOkOrThrowProviderError ,
15- resolveProviderHttpRequestConfig ,
1614} from "openclaw/plugin-sdk/provider-http" ;
1715import {
1816 buildHostnameAllowlistPolicyFromSuffixAllowlist ,
@@ -26,8 +24,8 @@ import {
2624 normalizeLowercaseStringOrEmpty ,
2725 normalizeOptionalString ,
2826} from "openclaw/plugin-sdk/string-coerce-runtime" ;
27+ import { resolveFalHttpRequestConfig } from "./http-config.js" ;
2928
30- const DEFAULT_FAL_BASE_URL = "https://fal.run" ;
3129const DEFAULT_FAL_IMAGE_MODEL = "fal-ai/flux/dev" ;
3230const DEFAULT_FAL_EDIT_SUBPATH = "image-to-image" ;
3331const FAL_KREA_2_MODEL_PREFIX = "krea/v2/" ;
@@ -551,15 +549,6 @@ export function buildFalImageGenerationProvider(): ImageGenerationProvider {
551549 } ,
552550 } ,
553551 async generateImage ( req ) {
554- const auth = await resolveApiKeyForProvider ( {
555- provider : "fal" ,
556- cfg : req . cfg ,
557- agentDir : req . agentDir ,
558- store : req . authStore ,
559- } ) ;
560- if ( ! auth . apiKey ) {
561- throw new Error ( "fal API key missing" ) ;
562- }
563552 const inputImageCount = req . inputImages ?. length ?? 0 ;
564553 const hasInputImages = inputImageCount > 0 ;
565554 const requestedModel = req . model ?. trim ( ) || DEFAULT_FAL_IMAGE_MODEL ;
@@ -588,20 +577,8 @@ export function buildFalImageGenerationProvider(): ImageGenerationProvider {
588577 if ( ! schema . supportsOutputFormat && req . outputFormat ) {
589578 throw new Error ( `fal ${ requestedModel } does not support outputFormat overrides` ) ;
590579 }
591- const explicitBaseUrl = req . cfg ?. models ?. providers ?. fal ?. baseUrl ?. trim ( ) ;
592580 const { baseUrl, allowPrivateNetwork, headers, dispatcherPolicy } =
593- resolveProviderHttpRequestConfig ( {
594- baseUrl : explicitBaseUrl ,
595- defaultBaseUrl : DEFAULT_FAL_BASE_URL ,
596- allowPrivateNetwork : false ,
597- defaultHeaders : {
598- Authorization : `Key ${ auth . apiKey } ` ,
599- "Content-Type" : "application/json" ,
600- } ,
601- provider : "fal" ,
602- capability : "image" ,
603- transport : "http" ,
604- } ) ;
581+ await resolveFalHttpRequestConfig ( { req, capability : "image" } ) ;
605582 const networkPolicy = resolveFalNetworkPolicy ( { baseUrl, allowPrivateNetwork } ) ;
606583 const requestBody : Record < string , unknown > = {
607584 prompt : req . prompt ,
0 commit comments