Skip to main content
@ai-billing/xai
@ai-billing/xai / createXaiV3Middleware

Function: createXaiV3Middleware()

createXaiV3Middleware<TTags>(options): LanguageModelV3Middleware
Defined in: xai/src/ai-sdk/language-model-middleware/v3/language-model-v3-xai-billing-middleware.ts:98 Creates a V3 billing middleware for the xAI provider (@ai-sdk/xai). Deducts cache-read tokens from prompt tokens before billing — xAI 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

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

Returns

LanguageModelV3Middleware A V3 billing middleware instance for xAI.

Example