@ai-billing/google-vertex / createGoogleVertexV4Middleware
Function: createGoogleVertexV4Middleware()
createGoogleVertexV4Middleware<Defined in: google-vertex/src/ai-sdk/language-model-middleware/v4/language-model-v4-google-vertex-billing-middleware.ts:112 Creates a V4 billing middleware for the Google Vertex AI provider (TTags>(options):LanguageModelV4Middleware
@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
GoogleVertexV4MiddlewareOptions<TTags>
Billing options; see GoogleVertexV4MiddlewareOptions.
Returns
LanguageModelV4Middleware
A V4 billing middleware instance for Google Vertex AI.