Skip to main content
@ai-billing/cerebras
@ai-billing/cerebras / createCerebrasV4Middleware

Function: createCerebrasV4Middleware()

createCerebrasV4Middleware<TTags>(options): LanguageModelV4Middleware
Defined in: cerebras/src/ai-sdk/language-model-middleware/v4/language-model-v4-cerebras-billing-middleware.ts:95 Creates a V4 billing middleware for the Cerebras provider (@ai-sdk/cerebras). Deducts cache-read tokens from prompt tokens and reasoning tokens from completion tokens before billing the base rates — Cerebras charges only non-cached input at the prompt rate, cached input separately at the cache-read rate, and reasoning tokens (a subset of completion_tokens) at the completion rate.

Type Parameters

TTags

TTags extends JSONObject The shape of the tags object, extending DefaultTags.

Parameters

options

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

Returns

LanguageModelV4Middleware A V4 billing middleware instance for Cerebras.

Example