ModelPricing class
Per-token price for a single model variant, expressed in USD per token.
Provider price sheets are usually quoted per 1M tokens. The factory ModelPricing.perMillion converts that to the per-token unit this package uses internally.
- Annotations
Constructors
- ModelPricing({required double inputRate, required double outputRate, double? cachedInputRate})
-
Build pricing where rates are already in USD-per-token.
const
- ModelPricing.perMillion({required double inputPerMillion, required double outputPerMillion, double? cachedInputPerMillion})
-
Build pricing from provider-style "USD per 1M tokens" numbers.
const
Properties
- cachedInputRate → double?
-
USD per cached input token.
null⇒ no separate cache rate (falls back to inputRate).final - hashCode → int
-
The hash code for this object.
no setteroverride
- inputRate → double
-
USD per input token (non-cached).
final
- outputRate → double
-
USD per output token.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
cost(
{required int tokensIn, required int tokensOut, int cachedTokensIn = 0}) → double - Calculate the total billed cost for a single call.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Constants
- free → const ModelPricing
- Free-tier pricing (everything is $0).