// ReSharper disable ClassNeverInstantiated.Global
namespace AIStudio.Provider.OpenAI;
///
/// What an OpenAI-compatible provider reports a chat completion cost.
///
///
/// Every number is optional because this is somebody else's JSON: the block arrives only when the
/// request asked for it, and the providers which follow the shape loosely leave fields out. Reading
/// it is one thing, believing it another -- TokenUsage.OfReported decides that.
///
public sealed record ChatCompletionUsage
{
///
/// What everything sent to the model cost.
///
public int? PromptTokens { get; init; }
///
/// What the model wrote in answer.
///
public int? CompletionTokens { get; init; }
///
/// States what this block reports, as far as it can be believed.
///
///
/// The one way from the wire to a usage, shared by every stream line which carries this block,
/// so that what counts as believable is decided in a single place.
///
/// The usage, or TokenUsage.UNKNOWN when the block states nothing usable.
public TokenUsage ToTokenUsage() => TokenUsage.OfReported(this.PromptTokens, this.CompletionTokens);
}