> ## Documentation Index
> Fetch the complete documentation index at: https://narev.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# CreateAzureV3Middleware

[**@ai-billing/azure**](../index)

***

[@ai-billing/azure](/docs/sdk/ai-billing/reference/azure/typedoc/index) / createAzureV3Middleware

# Function: createAzureV3Middleware()

> **createAzureV3Middleware**\<`TTags`>(`options`): `LanguageModelV3Middleware`

Defined in: [azure/src/ai-sdk/language-model-middleware/v3/language-model-v3-azure-billing-middleware.ts:99](https://github.com/narevai/ai-billing/blob/main/packages/azure/src/ai-sdk/language-model-middleware/v3/language-model-v3-azure-billing-middleware.ts#L99)

Creates a V3 billing middleware for the Azure provider (`@ai-sdk/azure`), specifically Azure AI Foundry
(`*.services.ai.azure.com`), which the AI SDK routes through the Responses API (`azure.responses`).
Prefers the raw Responses-API usage field names (`input_tokens`/`output_tokens` and their `_details`
subfields) and falls back to the AI SDK's normalized usage fields when `usage.raw` is absent.

## Type Parameters

### TTags

`TTags` *extends* `JSONObject`

The shape of the tags object, extending DefaultTags.

## Parameters

### options

[`AzureV3MiddlewareOptions`](/docs/sdk/ai-billing/reference/azure/typedoc/interfaces/AzureV3MiddlewareOptions)\<`TTags`>

Billing options; see [AzureV3MiddlewareOptions](/docs/sdk/ai-billing/reference/azure/typedoc/interfaces/AzureV3MiddlewareOptions). A `priceResolver` is required.

## Returns

`LanguageModelV3Middleware`

A V3 billing middleware instance for Azure.

## Example

```ts theme={null}
import { createAzure } from '@ai-sdk/azure';
import { wrapLanguageModel } from 'ai';
import { createAzureV3Middleware } from '@ai-billing/azure';
import {
  consoleDestination,
  createObjectPriceResolver,
  type ModelPricing,
} from '@ai-billing/core';

const azure = createAzure({
  apiKey: process.env.AZURE_API_KEY,
  baseURL: `${process.env.AZURE_URL?.replace(//+$/, '')}/openai/v1`,
  apiVersion: 'preview',
});

const deployment = process.env.AZURE_DEPLOYMENT ?? 'DeepSeek-V4-Pro';

const customPricingMap: Record<string, ModelPricing> = {
  [deployment]: {
    promptTokens: 2.0 / 1_000_000,
    completionTokens: 6.0 / 1_000_000,
  },
};

const priceResolver = createObjectPriceResolver(customPricingMap);

const billingMiddleware = createAzureV3Middleware({
  destinations: [consoleDestination()],
  priceResolver,
});

const wrappedModel = wrapLanguageModel({
  model: azure(deployment),
  middleware: billingMiddleware,
});
```
