fix(fal_ai): prevent double fal-ai/ prefix in generic model URL construction

When model is configured as fal_ai/fal-ai/model-name, the provider prefix
stripping leaves fal-ai/ intact, causing get_complete_url() to produce
fal-ai/fal-ai/model-name. Use removeprefix() to strip it before re-adding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Albert Sebastian 2026-04-14 09:56:09 +05:30
parent d90af8c8bc
commit e3cda5f919
2 changed files with 7 additions and 5 deletions

View file

@ -99,7 +99,9 @@ class FalAIImageEditConfig(BaseImageEditConfig):
base_url = base_url.rstrip("/")
# model arrives without provider prefix (e.g. "nano-banana-2/edit")
# FAL API expects fal-ai/ prefix in the URL path
return f"{base_url}/fal-ai/{model}"
# Strip fal-ai/ if already present to avoid double prefix
model_path = model.removeprefix("fal-ai/")
return f"{base_url}/fal-ai/{model_path}"
def _read_image_bytes(
self,
@ -220,9 +222,7 @@ class FalAIImageEditConfig(BaseImageEditConfig):
image_objects.append(ImageObject(url=single_image))
if not image_objects:
raise ValueError(
f"No images in Fal AI response: {response_data}"
)
raise ValueError(f"No images in Fal AI response: {response_data}")
return ImageResponse(
created=int(time.time()),

View file

@ -53,7 +53,9 @@ class FalAIBaseConfig(BaseImageGenerationConfig):
else:
# Generic models need the model name in the URL path
# model arrives without provider prefix (e.g. "nano-banana-2/edit")
complete_url = f"{complete_url}/fal-ai/{model}"
# Strip fal-ai/ if already present to avoid double prefix
model_path = model.removeprefix("fal-ai/")
complete_url = f"{complete_url}/fal-ai/{model_path}"
return complete_url
def validate_environment(