@ai-billing/huggingface / createHuggingfaceV4Middleware
Function: createHuggingfaceV4Middleware()
createHuggingfaceV4Middleware<Defined in: huggingface/src/ai-sdk/language-model-middleware/v4/language-model-v4-huggingface-billing-middleware.ts:92 Creates a V4 billing middleware for the Hugging Face provider (TTags>(options):LanguageModelV4Middleware
@ai-sdk/huggingface).
Deducts cache-read tokens from prompt tokens before billing — Hugging Face charges only non-cached input
at the prompt rate, and cached tokens separately at the cache-read rate.
Type Parameters
TTags
TTags extends JSONObject
The shape of the tags object, extending DefaultTags.
Parameters
options
HuggingfaceV4MiddlewareOptions<TTags>
Billing options; see HuggingfaceV4MiddlewareOptions. A priceResolver is required.
Returns
LanguageModelV4Middleware
A V4 billing middleware instance for Hugging Face.