Skip to main content
@ai-billing/google-vertex
@ai-billing/google-vertex / createGoogleVertexV3Middleware

Function: createGoogleVertexV3Middleware()

createGoogleVertexV3Middleware<TTags>(options): LanguageModelV3Middleware
Defined in: google-vertex/src/ai-sdk/language-model-middleware/v3/language-model-v3-google-vertex-billing-middleware.ts:112 Creates a V3 billing middleware for the Google Vertex AI provider (@ai-sdk/google-vertex). Maps Vertex’s Gemini-native usage into billing fields (adding thoughtsTokenCount back into the billed completion count) and resolves cost from pricing plus usage. Vertex’s trafficType (ON_DEMAND vs PROVISIONED) is surfaced on the emitted event’s usage.subProvider, but is not used to change the billed rate — provisioned-throughput calls are billed at the same resolved rate as on-demand calls. See calculateGoogleVertexCost.

Type Parameters

TTags

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

Parameters

options

GoogleVertexV3MiddlewareOptions<TTags> Billing options; see GoogleVertexV3MiddlewareOptions.

Returns

LanguageModelV3Middleware A V3 billing middleware instance for Google Vertex AI.

Example