@ai-billing/togetherai / createTogetheraiV4Middleware
Function: createTogetheraiV4Middleware()
createTogetheraiV4Middleware<Defined in: togetherai/src/ai-sdk/language-model-middleware/v4/language-model-v4-togetherai-billing-middleware.ts:88 Creates a V4 billing middleware for the Together AI provider (TTags>(options):LanguageModelV4Middleware
@ai-sdk/togetherai).
Together AI’s usage payload does not report any cache fields, so cache-read/cache-write tokens are
always billed as zero; reasoning_tokens is read as a flat top-level field (not nested, unlike some
other OpenAI-compatible providers in this repo) and deducted from completion tokens before billing.
Type Parameters
TTags
TTags extends JSONObject
The shape of the tags object, extending DefaultTags.
Parameters
options
TogetheraiV4MiddlewareOptions<TTags>
Billing options; see TogetheraiV4MiddlewareOptions. A priceResolver is required.
Returns
LanguageModelV4Middleware
A V4 billing middleware instance for Together AI.