Skip to main content
@ai-billing/perplexity
@ai-billing/perplexity / createPerplexityV4Middleware

Function: createPerplexityV4Middleware()

createPerplexityV4Middleware<TTags>(options): LanguageModelV4Middleware
Defined in: perplexity/src/ai-sdk/language-model-middleware/v4/language-model-v4-perplexity-billing-middleware.ts:99 Creates a V4 billing middleware for the Perplexity provider (@ai-sdk/perplexity). Perplexity has no prompt-caching feature, so cache-read/cache-write tokens are always reported as 0. All Perplexity sonar models are web-search-grounded and bill a flat per-request search fee (request_cost) on top of token costs — see calculatePerplexityCost for how that is modeled.

Type Parameters

TTags

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

Parameters

options

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

Returns

LanguageModelV4Middleware A V4 billing middleware instance for Perplexity.

Example