< Summary

Information
Class: OpenAiIntegration.CostBreakdown
Assembly: OpenAiIntegration
File(s): /home/runner/work/KicktippAi/KicktippAi/src/OpenAiIntegration/ICostCalculationService.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 41
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Input()100%210%
set_Input(...)100%210%
get_CachedInput()100%210%
set_CachedInput(...)100%210%
get_Output()100%210%
set_Output(...)100%210%
get_Total()100%11100%
set_Total(...)100%210%
.ctor(...)100%210%

File(s)

/home/runner/work/KicktippAi/KicktippAi/src/OpenAiIntegration/ICostCalculationService.cs

#LineLine coverage
 1using OpenAI.Chat;
 2
 3namespace OpenAiIntegration;
 4
 5/// <summary>
 6/// Service for calculating and logging OpenAI API costs
 7/// </summary>
 8public interface ICostCalculationService
 9{
 10    /// <summary>
 11    /// Calculates and logs the cost breakdown for an OpenAI chat completion
 12    /// </summary>
 13    /// <param name="model">The model used for the completion</param>
 14    /// <param name="usage">The token usage information from the response</param>
 15    void LogCostBreakdown(string model, ChatTokenUsage usage);
 16
 17    /// <summary>
 18    /// Calculates the cost for a specific model and usage
 19    /// </summary>
 20    /// <param name="model">The model to calculate costs for</param>
 21    /// <param name="usage">The token usage information</param>
 22    /// <returns>The calculated cost, or null if pricing is not available for the model</returns>
 23    decimal? CalculateCost(string model, ChatTokenUsage usage);
 24
 25    /// <summary>
 26    /// Calculates a detailed cost breakdown for a specific model and usage.
 27    /// </summary>
 28    /// <param name="model">The model to calculate costs for</param>
 29    /// <param name="usage">The token usage information</param>
 30    /// <returns>A <see cref="CostBreakdown"/> with per-component costs, or null if pricing is not available for the mod
 31    CostBreakdown? CalculateCostBreakdown(string model, ChatTokenUsage usage);
 32}
 33
 34/// <summary>
 35/// Detailed cost breakdown for an OpenAI API call, with per-component costs in USD.
 36/// </summary>
 37/// <param name="Input">Cost for uncached input tokens</param>
 38/// <param name="CachedInput">Cost for cached input tokens</param>
 39/// <param name="Output">Cost for output tokens</param>
 40/// <param name="Total">Total cost (input + cached input + output)</param>
 141public record CostBreakdown(decimal Input, decimal CachedInput, decimal Output, decimal Total);