Skip to content

🚨 CRITICAL: Models without cost configuration provide free service #768

@nickna

Description

@nickna

Problem

When a model has no associated cost configuration, the system returns 0 cost and continues processing - effectively providing free service. This occurs for:

  • New models not yet configured
  • Misconfigured model mappings
  • Models with inactive cost mappings

Evidence

  • CostCalculationService.cs:87-90: Returns 0 when no model cost found
  • UsageTrackingMiddleware.cs:216-220: Skips billing when cost is 0
  • ModelCostService.cs:67-69: Caches null cost result for 1 hour

Impact

  • Severity: CRITICAL
  • Revenue Impact: 100% loss for unconfigured models
  • Current State: Any model without explicit cost config runs free

Solution Requirements

Per your decision: "Effectively a model mapping is disabled until it has a cost record, even if the cost is free."

  1. Enforce Cost Configuration:

    • Models MUST have an active cost configuration
    • Even free models need explicit $0 cost config
    • Reject requests for unconfigured models
  2. Implementation Points:

    • Check cost availability BEFORE processing request
    • Return 503 Service Unavailable for unconfigured models
    • Clear error message indicating model configuration issue

Implementation Details

1. Update Conduit.cs or request pipeline:

public async Task<ChatCompletionResponse> CreateChatCompletionAsync(
    ChatCompletionRequest request, ...)
{
    // Validate model has cost configuration
    var modelCost = await _modelCostService.GetCostForModelAsync(request.Model);
    if (modelCost == null)
    {
        throw new ServiceUnavailableException(
            $"Model '{request.Model}' is not available. Cost configuration pending.");
    }
    
    // Continue with normal processing...
}

2. Update ModelProviderMappingService:

public async Task<bool> IsModelAvailableAsync(string modelAlias)
{
    var mapping = await GetByModelNameAsync(modelAlias);
    if (mapping == null) return false;
    
    // Check if model has active cost configuration
    var hasCost = await _modelCostRepository.HasActiveCostAsync(mapping.Id);
    return hasCost;
}

3. Add health check:

  • Monitor models without cost configuration
  • Alert operations team when new models lack costs

4. Migration for existing data:

  • Audit all current model mappings
  • Ensure all active models have cost records
  • Add $0 cost records where intentionally free

Testing

  • Unit tests for cost enforcement
  • Integration tests with missing costs
  • Verify proper error messages
  • Test free models with $0 config work correctly

Breaking Change Notice

⚠️ This is a breaking change that will reject previously working requests for unconfigured models. Requires:

  1. Audit of all existing models
  2. Add cost configs before deployment
  3. Clear communication to operations team

Priority

P0 - CRITICAL: Direct revenue impact, implement immediately

Related Issues

  • Depends on model cost configuration UI/API
  • Part of billing guarantee system

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions