Skip to main content
@ai-billing/deepinfra
@ai-billing/deepinfra / createDeepinfraV4Middleware

Function: createDeepinfraV4Middleware()

createDeepinfraV4Middleware<TTags>(options): LanguageModelV4Middleware
Defined in: deepinfra/src/ai-sdk/language-model-middleware/v4/language-model-v4-deepinfra-billing-middleware.ts:105 Creates a V4 billing middleware for the DeepInfra provider (@ai-sdk/deepinfra). Deducts cache-read tokens from prompt tokens before billing — DeepInfra charges only non-cached input at the prompt rate, and cached tokens separately at the cache-read rate. DeepInfra’s raw usage payload may include its own estimated_cost (a USD estimate). That value is never used as the billed cost — cost is always computed from the resolved ModelPricing table — but when present and numeric it is additionally surfaced as usage.rawProviderCost for informational purposes.

Type Parameters

TTags

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

Parameters

options

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

Returns

LanguageModelV4Middleware A V4 billing middleware instance for DeepInfra.

Example