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

Function: createPerplexityV3Middleware()

createPerplexityV3Middleware<TTags>(options): LanguageModelV3Middleware
Defined in: perplexity/src/ai-sdk/language-model-middleware/v3/language-model-v3-perplexity-billing-middleware.ts:99 Creates a V3 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

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

Returns

LanguageModelV3Middleware A V3 billing middleware instance for Perplexity.

Example