Skip to main content
@ai-billing/gateway
@ai-billing/gateway / createGatewayV4Middleware

Function: createGatewayV4Middleware()

createGatewayV4Middleware<TTags>(options): LanguageModelV4Middleware
Defined in: gateway/src/ai-sdk/language-model-middleware/v4/language-model-v4-ai-gateway-billing-middleware.ts:102 Creates a V4 billing middleware configured for the Vercel AI Gateway provider. Extracts cost and usage data from gateway-specific provider metadata.

Type Parameters

TTags

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

Parameters

options

GatewayV4MiddlewareOptions<TTags> Shared billing options; see GatewayV4MiddlewareOptions for what you can pass and what is implied by the gateway provider.

Returns

LanguageModelV4Middleware A V4 billing middleware instance for the AI Gateway.

Example

Targets AI SDK v7 (LanguageModelV4Middleware).