@ai-billing/zai / createZaiV4Middleware
Function: createZaiV4Middleware()
createZaiV4Middleware<Defined in: zai/src/ai-sdk/language-model-middleware/v4/language-model-v4-zai-billing-middleware.ts:87 Creates a V4 billing middleware for the Z.ai provider (TTags>(options):LanguageModelV4Middleware
@ai-sdk/zai).
Deducts cache-read tokens from prompt tokens and reasoning tokens from completion tokens before
billing — reasoning tokens are a subset of completion_tokens (GLM has no separate reasoning rate), and
cached tokens are billed separately at the cache-read rate.
Type Parameters
TTags
TTags extends JSONObject
The shape of the tags object, extending DefaultTags.
Parameters
options
ZaiV4MiddlewareOptions<TTags>
Billing options; see ZaiV4MiddlewareOptions. A priceResolver is required.
Returns
LanguageModelV4Middleware
A V4 billing middleware instance for Z.ai.