Skip to main content
@ai-billing/alibaba
@ai-billing/alibaba / createAlibabaV4Middleware

Function: createAlibabaV4Middleware()

createAlibabaV4Middleware<TTags>(options): LanguageModelV4Middleware
Defined in: alibaba/src/ai-sdk/language-model-middleware/v4/language-model-v4-alibaba-billing-middleware.ts:98 Creates a V4 billing middleware for the Alibaba provider (@ai-sdk/alibaba). Deducts cache-read tokens from prompt tokens before billing — Alibaba 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

AlibabaV4MiddlewareOptions<TTags> Billing options; see AlibabaV4MiddlewareOptions. A priceResolver is required.

Returns

LanguageModelV4Middleware A V4 billing middleware instance for Alibaba.

Example