@ai-billing/openai-compatible / OpenAICompatibleV3MiddlewareOptions
Interface: OpenAICompatibleV3MiddlewareOptions<TTags>
Defined in: openai-compatible/src/ai-sdk/language-model-middleware/v3/language-model-v3-openai-compatible-billing-middleware.ts:29 Configuration for createOpenAICompatibleV3Middleware. Extends BaseBillingMiddlewareOptions (destinations, defaultTags, waitUntil, onError) and
adds priceResolver plus providerId. Usage comes from the AI SDK’s normalized usage fields for
OpenAI-compatible responses; cost is computed from that usage and the resolved ModelPricing using
the same rules as the package’s cost helper.
providerId must match the name you pass to createOpenAICompatible from @ai-sdk/openai-compatible
so PriceResolver calls and emitted provider on events stay aligned.
Extends
BaseBillingMiddlewareOptions<TTags>
Type Parameters
TTags
TTags extends DefaultTags
The shape of the tags object, extending DefaultTags.
Properties
destinations?
Defined in: core/dist/index.d.ts:30 One or more billing destinations that receive each emitted BillingEvent.optionaldestinations?:Destination<TTags>[]
Inherited from
BaseBillingMiddlewareOptions.destinations
defaultTags?
Defined in: core/dist/index.d.ts:32 Tags merged into every emitted event.optionaldefaultTags?:TTags
Inherited from
BaseBillingMiddlewareOptions.defaultTags
waitUntil?
Defined in: core/dist/index.d.ts:37 Edge-runtime hook (e.g.optionalwaitUntil?: (promise) =>void
ctx.waitUntil) used to keep the process alive
while billing events are flushed asynchronously.
Parameters
promise
Promise<unknown>
Returns
void
Inherited from
BaseBillingMiddlewareOptions.waitUntil
onError?
Defined in: core/dist/index.d.ts:39 Called when an error occurs during event extraction or dispatch. Defaults to a silent no-op.optionalonError?: (error) =>void
Parameters
error
unknown
Returns
void
Inherited from
BaseBillingMiddlewareOptions.onError
priceResolver
priceResolver: PriceResolver
Defined in: openai-compatible/src/ai-sdk/language-model-middleware/v3/language-model-v3-openai-compatible-billing-middleware.ts:32
providerId
providerId: string
Defined in: openai-compatible/src/ai-sdk/language-model-middleware/v3/language-model-v3-openai-compatible-billing-middleware.ts:33