completionCost function
Future<double?>
completionCost({
- required String model,
- required PlatformInt64 promptTokens,
- required PlatformInt64 completionTokens,
Calculate the estimated cost of a completion given a model name and token counts.
Returns null if the model is not present in the embedded pricing registry.
Returns Some(cost_usd) otherwise, where the value is in US dollars.
When an exact model name match is not found, progressively shorter prefixes
are tried by stripping from the last - or . separator. For example,
gpt-4-0613 will match gpt-4 if no gpt-4-0613 entry exists.
Implementation
Future<double?> completionCost({
required String model,
required PlatformInt64 promptTokens,
required PlatformInt64 completionTokens,
}) => RustLib.instance.api.crateCompletionCost(
model: model,
promptTokens: promptTokens,
completionTokens: completionTokens,
);