feat(pricing): add input_cost_per_reference_pixel cost key

Azure meters FLUX.2 image edits twice: once for the generated pixels and once
for every pixel of the reference images sent with the edit. input_cost_per_pixel
already means the generated image's pixels in default_image_cost_calculator, so
the reference meter gets its own key. The Flex row carries it at the same
0.05 per 1024x1024 megapixel as its output rate, per the Azure retail prices
API rows for 'Azure BFL Flux Models' (Flex Megapixel and Flex Ref Megapixel,
checked 2026-09-23). Declared everywhere a deployment can set a price: the
cost map and its regenerated schema, CustomPricingLiteLLMParams, the Rust
catalog, the Terraform provider, and the dashboard's OpenAPI types
This commit is contained in:
Shreshth Kharbanda 2026-09-23 13:50:30 -07:00
parent 4ad18797ab
commit 10323380cf
12 changed files with 27 additions and 0 deletions

View file

@ -222,6 +222,7 @@ COST_DESCRIPTIONS: dict[str, str] = {
"cache_read_input_token_cost": "USD per prompt token served from the provider's prompt cache.",
"input_cost_per_token_batches": "USD per prompt token via the provider's batch API.",
"output_cost_per_token_batches": "USD per generated token via the provider's batch API.",
"input_cost_per_reference_pixel": "USD per pixel of each reference image sent with an image edit.",
}

View file

@ -345,6 +345,8 @@ pub struct ModelInfo {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub input_cost_per_pixel: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub input_cost_per_reference_pixel: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub input_cost_per_query: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub input_cost_per_request: Option<f64>,

View file

@ -10964,6 +10964,7 @@
},
"azure_ai/FLUX.2-flex": {
"input_cost_per_pixel": 4.76837158203125e-08,
"input_cost_per_reference_pixel": 4.76837158203125e-08,
"litellm_provider": "azure_ai",
"max_input_tokens": 32000,
"max_tokens": 32000,

View file

@ -3702,6 +3702,7 @@ class CustomPricingLiteLLMParams(MirroredPricingParams):
output_cost_per_image_1024: float | None = None
output_cost_per_image_1536: float | None = None
input_cost_per_pixel: float | None = None
input_cost_per_reference_pixel: float | None = None
output_cost_per_pixel: float | None = None
# Include all ModelInfoBase fields as optional

View file

@ -10964,6 +10964,7 @@
},
"azure_ai/FLUX.2-flex": {
"input_cost_per_pixel": 4.76837158203125e-08,
"input_cost_per_reference_pixel": 4.76837158203125e-08,
"litellm_provider": "azure_ai",
"max_input_tokens": 32000,
"max_tokens": 32000,

View file

@ -318,6 +318,11 @@
"type": "number",
"minimum": 0
},
"input_cost_per_reference_pixel": {
"type": "number",
"minimum": 0,
"description": "USD per pixel of each reference image sent with an image edit."
},
"input_cost_per_request": {
"type": "number",
"minimum": 0

View file

@ -157,6 +157,8 @@ The following arguments are supported:
* `input_cost_per_pixel` - (Optional) float. Cost applied per input pixel for models that charge by image size.
* `input_cost_per_reference_pixel` - (Optional) float. Cost applied per pixel of each reference image sent with an image edit, for models that meter reference images separately.
* `output_cost_per_pixel` - (Optional) float. Cost applied per output pixel for image-generation models.
* `input_cost_per_second` - (Optional) float. Cost applied per input second for audio/transcription models.

View file

@ -119,6 +119,10 @@ func resourceLiteLLMModel() *schema.Resource {
Type: schema.TypeFloat,
Optional: true,
},
"input_cost_per_reference_pixel": {
Type: schema.TypeFloat,
Optional: true,
},
"output_cost_per_pixel": {
Type: schema.TypeFloat,
Optional: true,

View file

@ -124,6 +124,9 @@ func createOrUpdateModel(d *schema.ResourceData, m interface{}, isUpdate bool) e
if inputCostPerPixel := d.Get("input_cost_per_pixel").(float64); inputCostPerPixel > 0 {
litellmParams["input_cost_per_pixel"] = inputCostPerPixel
}
if inputCostPerReferencePixel := d.Get("input_cost_per_reference_pixel").(float64); inputCostPerReferencePixel > 0 {
litellmParams["input_cost_per_reference_pixel"] = inputCostPerReferencePixel
}
if outputCostPerPixel := d.Get("output_cost_per_pixel").(float64); outputCostPerPixel > 0 {
litellmParams["output_cost_per_pixel"] = outputCostPerPixel
}

View file

@ -93,6 +93,7 @@ type LiteLLMParams struct {
InputCostPerToken float64 `json:"input_cost_per_token,omitempty"`
OutputCostPerToken float64 `json:"output_cost_per_token,omitempty"`
InputCostPerPixel float64 `json:"input_cost_per_pixel,omitempty"`
InputCostPerReferencePixel float64 `json:"input_cost_per_reference_pixel,omitempty"`
OutputCostPerPixel float64 `json:"output_cost_per_pixel,omitempty"`
InputCostPerSecond float64 `json:"input_cost_per_second,omitempty"`
OutputCostPerSecond float64 `json:"output_cost_per_second,omitempty"`

View file

@ -643,6 +643,7 @@ def validate_model_cost_values(model_data, exceptions=None):
"output_cost_per_image_1024",
"output_cost_per_image_1536",
"input_cost_per_pixel",
"input_cost_per_reference_pixel",
"output_cost_per_pixel",
"input_cost_per_second",
"output_cost_per_second",
@ -814,6 +815,7 @@ def test_aaamodel_prices_and_context_window_json_is_valid():
"regional_processing_uplift_multiplier_eu": {"type": "number"},
"regional_processing_uplift_multiplier_us": {"type": "number"},
"input_cost_per_pixel": {"type": "number"},
"input_cost_per_reference_pixel": {"type": "number"},
"input_cost_per_query": {"type": "number"},
"input_cost_per_request": {"type": "number"},
"input_cost_per_second": {"type": "number"},

View file

@ -31409,6 +31409,8 @@ export interface components {
input_cost_per_pixel?: number | null;
/** Input Cost Per Query */
input_cost_per_query?: number | null;
/** Input Cost Per Reference Pixel */
input_cost_per_reference_pixel?: number | null;
/** Input Cost Per Second */
input_cost_per_second?: number | null;
/** Input Cost Per Token */
@ -42304,6 +42306,8 @@ export interface components {
input_cost_per_pixel?: number | null;
/** Input Cost Per Query */
input_cost_per_query?: number | null;
/** Input Cost Per Reference Pixel */
input_cost_per_reference_pixel?: number | null;
/** Input Cost Per Second */
input_cost_per_second?: number | null;
/** Input Cost Per Token */