Skip to content

[Bug]: Response cost not reported for fine-tuned OpenAI models with custom pricing in config #13790

Description

@TeddyAmkie
### What happened?

**Summary**  
When using fine-tuned OpenAI models and specifying `input_cost_per_token` / `output_cost_per_token` in the `model_info` section of the config YAML, LiteLLM does not report `response_cost` in logs or in the `x-litellm-response-cost` header. Instead, it either shows `0.0` or picks the cost from the `base_model` rather than the overridden custom pricing.

---

### Minimal Repro Setup

1. **Config (`config.yaml`)**

```yaml
model_list:
  - model_name: openai/ft:gpt-4.1-2025-04-14:*
    litellm_params:
      model: openai/ft:gpt-4.1-2025-04-14:*
      api_key: os.environ/OPENAI_DEFAULT_API_KEY
    model_info:
      id: openai-fine-tuned
      input_cost_per_token:  0.000003
      output_cost_per_token: 0.000012

litellm_settings:
  json_logs: true
  1. Run LiteLLM proxy
litellm --config config.yaml
  1. Send a test request
curl http://localhost:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-<proxy-key>" \
  -d '{
    "model": "openai/ft:gpt-4.1-2025-04-14:my-org:example",
    "messages": [{"role": "user", "content": "Hello!"}]
  }' -i

Expected Behavior

  • LiteLLM should calculate response cost using the configured input_cost_per_token / output_cost_per_token.
  • response_cost should be present in logs.
  • x-litellm-response-cost header should match the calculated value.

Actual Behavior

  • response_cost is logged as 0.0 (or absent).
  • No x-litellm-response-cost header is returned.
  • If base_model is set, LiteLLM falls back to base model pricing instead of the custom values.
  • Example:
    • Configured: 0.000003 * 26 + 0.000012 * 165 = 0.002058
    • Reported: 0.0025725 (base model pricing).

Additional Context

  • Works correctly with non-fine-tuned models (e.g. bedrock/anthropic.claude-3-5-haiku-20241022-v1:0).
  • @ishaan-jaff confirmed repro on Jul 30.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions