mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-08 22:21:35 +00:00
Merge pull request #17966 from BerriAI/litellm_fix_gpt-1_image_cost_1
fix: cost calculation of gpt-image 1 model
This commit is contained in:
commit
8a6f6385ed
3 changed files with 37 additions and 2 deletions
|
|
@ -1555,7 +1555,7 @@ def default_image_cost_calculator(
|
|||
|
||||
# gpt-image-1 models use low, medium, high quality. If user did not specify quality, use medium fot gpt-image-1 model family
|
||||
model_name_with_v2_quality = (
|
||||
f"{ImageGenerationRequestQuality.MEDIUM.value}/{base_model_name}"
|
||||
f"{ImageGenerationRequestQuality.HIGH.value}/{base_model_name}"
|
||||
)
|
||||
|
||||
verbose_logger.debug(
|
||||
|
|
@ -1587,7 +1587,16 @@ def default_image_cost_calculator(
|
|||
f"Model not found in cost map. Tried checking {models_to_check}"
|
||||
)
|
||||
|
||||
return cost_info["input_cost_per_pixel"] * height * width * n
|
||||
# Priority 1: Use per-image pricing if available (for gpt-image-1 and similar models)
|
||||
if "input_cost_per_image" in cost_info and cost_info["input_cost_per_image"] is not None:
|
||||
return cost_info["input_cost_per_image"] * n
|
||||
# Priority 2: Fall back to per-pixel pricing for backward compatibility
|
||||
elif "input_cost_per_pixel" in cost_info and cost_info["input_cost_per_pixel"] is not None:
|
||||
return cost_info["input_cost_per_pixel"] * height * width * n
|
||||
else:
|
||||
raise Exception(
|
||||
f"No pricing information found for model {model}. Tried checking {models_to_check}"
|
||||
)
|
||||
|
||||
|
||||
def default_video_cost_calculator(
|
||||
|
|
|
|||
|
|
@ -17103,10 +17103,14 @@
|
|||
"supports_vision": true
|
||||
},
|
||||
"gpt-image-1": {
|
||||
"input_cost_per_image": 0.042,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"input_cost_per_token": 0.000005,
|
||||
"input_cost_per_image_token": 0.00001,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
"output_cost_per_pixel": 0.0,
|
||||
"output_cost_per_token": 0.00004,
|
||||
"supported_endpoints": [
|
||||
"/v1/images/generations"
|
||||
]
|
||||
|
|
@ -17925,6 +17929,7 @@
|
|||
"supports_tool_choice": true
|
||||
},
|
||||
"high/1024-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.167,
|
||||
"input_cost_per_pixel": 1.59263611e-07,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -17934,6 +17939,7 @@
|
|||
]
|
||||
},
|
||||
"high/1024-x-1536/gpt-image-1": {
|
||||
"input_cost_per_image": 0.25,
|
||||
"input_cost_per_pixel": 1.58945719e-07,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -17943,6 +17949,7 @@
|
|||
]
|
||||
},
|
||||
"high/1536-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.25,
|
||||
"input_cost_per_pixel": 1.58945719e-07,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18604,6 +18611,7 @@
|
|||
"supports_tool_choice": true
|
||||
},
|
||||
"low/1024-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.011,
|
||||
"input_cost_per_pixel": 1.0490417e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18613,6 +18621,7 @@
|
|||
]
|
||||
},
|
||||
"low/1024-x-1536/gpt-image-1": {
|
||||
"input_cost_per_image": 0.016,
|
||||
"input_cost_per_pixel": 1.0172526e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18622,6 +18631,7 @@
|
|||
]
|
||||
},
|
||||
"low/1536-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.016,
|
||||
"input_cost_per_pixel": 1.0172526e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18687,6 +18697,7 @@
|
|||
"output_cost_per_image": 0.072
|
||||
},
|
||||
"medium/1024-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.042,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18696,6 +18707,7 @@
|
|||
]
|
||||
},
|
||||
"medium/1024-x-1536/gpt-image-1": {
|
||||
"input_cost_per_image": 0.063,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18705,6 +18717,7 @@
|
|||
]
|
||||
},
|
||||
"medium/1536-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.063,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
|
|||
|
|
@ -17103,10 +17103,14 @@
|
|||
"supports_vision": true
|
||||
},
|
||||
"gpt-image-1": {
|
||||
"input_cost_per_image": 0.042,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"input_cost_per_token": 0.000005,
|
||||
"input_cost_per_image_token": 0.00001,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
"output_cost_per_pixel": 0.0,
|
||||
"output_cost_per_token": 0.00004,
|
||||
"supported_endpoints": [
|
||||
"/v1/images/generations"
|
||||
]
|
||||
|
|
@ -17925,6 +17929,7 @@
|
|||
"supports_tool_choice": true
|
||||
},
|
||||
"high/1024-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.167,
|
||||
"input_cost_per_pixel": 1.59263611e-07,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -17934,6 +17939,7 @@
|
|||
]
|
||||
},
|
||||
"high/1024-x-1536/gpt-image-1": {
|
||||
"input_cost_per_image": 0.25,
|
||||
"input_cost_per_pixel": 1.58945719e-07,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -17943,6 +17949,7 @@
|
|||
]
|
||||
},
|
||||
"high/1536-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.25,
|
||||
"input_cost_per_pixel": 1.58945719e-07,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18604,6 +18611,7 @@
|
|||
"supports_tool_choice": true
|
||||
},
|
||||
"low/1024-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.011,
|
||||
"input_cost_per_pixel": 1.0490417e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18613,6 +18621,7 @@
|
|||
]
|
||||
},
|
||||
"low/1024-x-1536/gpt-image-1": {
|
||||
"input_cost_per_image": 0.016,
|
||||
"input_cost_per_pixel": 1.0172526e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18622,6 +18631,7 @@
|
|||
]
|
||||
},
|
||||
"low/1536-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.016,
|
||||
"input_cost_per_pixel": 1.0172526e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18687,6 +18697,7 @@
|
|||
"output_cost_per_image": 0.072
|
||||
},
|
||||
"medium/1024-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.042,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18696,6 +18707,7 @@
|
|||
]
|
||||
},
|
||||
"medium/1024-x-1536/gpt-image-1": {
|
||||
"input_cost_per_image": 0.063,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
@ -18705,6 +18717,7 @@
|
|||
]
|
||||
},
|
||||
"medium/1536-x-1024/gpt-image-1": {
|
||||
"input_cost_per_image": 0.063,
|
||||
"input_cost_per_pixel": 4.0054321e-08,
|
||||
"litellm_provider": "openai",
|
||||
"mode": "image_generation",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue