Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(fal_ai): price gpt-image-2 unprefixed alias and edit endpoint

Devin AI618d907d5ae5
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 20d47bdb839..429e859e242 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -17410,6 +17410,32 @@
],
"supports_vision": true
},
+ "fal_ai/gpt-image-2": {
+ "litellm_provider": "fal_ai",
+ "metadata": {
+ "notes": "Alias of fal_ai/openai/gpt-image-2, which litellm also accepts without the openai/ prefix. Same rate, see that entry for the size and quality caveat"
+ },
+ "mode": "image_generation",
+ "output_cost_per_image": 0.145,
+ "source": "https://fal.ai/models/openai/gpt-image-2",
+ "supported_endpoints": [
+ "/v1/images/generations"
+ ],
+ "supports_vision": true
+ },
+ "fal_ai/openai/gpt-image-2/edit": {
+ "litellm_provider": "fal_ai",
+ "metadata": {
+ "notes": "Editing endpoint of gpt-image-2 on fal.ai. Same rate as fal_ai/openai/gpt-image-2, see that entry for the size and quality caveat"
+ },
+ "mode": "image_generation",
+ "output_cost_per_image": 0.145,
+ "source": "https://fal.ai/models/openai/gpt-image-2/edit",
+ "supported_endpoints": [
+ "/v1/images/edits"
+ ],
+ "supports_vision": true
+ },
"featherless_ai/featherless-ai/Qwerky-72B": {
"litellm_provider": "featherless_ai",
"max_input_tokens": 32768,
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index 20d47bdb839..429e859e242 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -17410,6 +17410,32 @@
],
"supports_vision": true
},
+ "fal_ai/gpt-image-2": {
+ "litellm_provider": "fal_ai",
+ "metadata": {
+ "notes": "Alias of fal_ai/openai/gpt-image-2, which litellm also accepts without the openai/ prefix. Same rate, see that entry for the size and quality caveat"
+ },
+ "mode": "image_generation",
+ "output_cost_per_image": 0.145,
+ "source": "https://fal.ai/models/openai/gpt-image-2",
+ "supported_endpoints": [
+ "/v1/images/generations"
+ ],
+ "supports_vision": true
+ },
+ "fal_ai/openai/gpt-image-2/edit": {
+ "litellm_provider": "fal_ai",
+ "metadata": {
+ "notes": "Editing endpoint of gpt-image-2 on fal.ai. Same rate as fal_ai/openai/gpt-image-2, see that entry for the size and quality caveat"
+ },
+ "mode": "image_generation",
+ "output_cost_per_image": 0.145,
+ "source": "https://fal.ai/models/openai/gpt-image-2/edit",
+ "supported_endpoints": [
+ "/v1/images/edits"
+ ],
+ "supports_vision": true
+ },
"featherless_ai/featherless-ai/Qwerky-72B": {
"litellm_provider": "featherless_ai",
"max_input_tokens": 32768,
diff --git a/tests/test_litellm/llms/fal_ai/image_generation/test_fal_ai_gpt_image_2_transformation.py b/tests/test_litellm/llms/fal_ai/image_generation/test_fal_ai_gpt_image_2_transformation.py
index 3baa39c758f..3c8cf9f9e0a 100644
--- a/tests/test_litellm/llms/fal_ai/image_generation/test_fal_ai_gpt_image_2_transformation.py
+++ b/tests/test_litellm/llms/fal_ai/image_generation/test_fal_ai_gpt_image_2_transformation.py
@@ -127,7 +127,15 @@ def test_transform_image_generation_request():
) == {"prompt": "a red bicycle", "quality": "high", "num_images": 2}
-def test_cost_calculator_uses_registry_price(monkeypatch: pytest.MonkeyPatch):
+ "model",
+ [
+ "openai/gpt-image-2",
+ "gpt-image-2",
+ "openai/gpt-image-2/edit",
+ ],
+)
+def test_cost_calculator_uses_registry_price(model, monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
response = ImageResponse(
data=[
@@ -135,4 +143,4 @@ def test_cost_calculator_uses_registry_price(monkeypatch: pytest.MonkeyPatch):
ImageObject(url="https://v3b.fal.media/files/b/two.png"),
]
)
- assert cost_calculator(model="openai/gpt-image-2", image_response=response) == pytest.approx(0.29)
+ assert cost_calculator(model=model, image_response=response) == pytest.approx(0.29)