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

Function: createGatewayV3Middleware()

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

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

Returns

LanguageModelV3Middleware A V3 billing middleware instance for the AI Gateway.

Example

Same wiring as examples/dev-sandbox/app/api/gateway (createGatewayMiddleware is this function’s export alias from @ai-billing/gateway).