@ai-billing/xai / createXaiV3Middleware
Function: createXaiV3Middleware()
createXaiV3Middleware<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 (TTags>(options):LanguageModelV3Middleware
@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.