@ai-sdk/azure 3.0.15 → 3.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/04-azure.mdx +976 -0
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,976 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Azure OpenAI
|
|
3
|
+
description: Learn how to use the Azure OpenAI provider for the AI SDK.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Azure OpenAI Provider
|
|
7
|
+
|
|
8
|
+
The [Azure OpenAI](https://azure.microsoft.com/en-us/products/ai-services/openai-service) provider contains language model support for the Azure OpenAI chat API.
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
The Azure OpenAI provider is available in the `@ai-sdk/azure` module. You can install it with
|
|
13
|
+
|
|
14
|
+
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}>
|
|
15
|
+
<Tab>
|
|
16
|
+
<Snippet text="pnpm add @ai-sdk/azure" dark />
|
|
17
|
+
</Tab>
|
|
18
|
+
<Tab>
|
|
19
|
+
<Snippet text="npm install @ai-sdk/azure" dark />
|
|
20
|
+
</Tab>
|
|
21
|
+
<Tab>
|
|
22
|
+
<Snippet text="yarn add @ai-sdk/azure" dark />
|
|
23
|
+
</Tab>
|
|
24
|
+
|
|
25
|
+
<Tab>
|
|
26
|
+
<Snippet text="bun add @ai-sdk/azure" dark />
|
|
27
|
+
</Tab>
|
|
28
|
+
</Tabs>
|
|
29
|
+
|
|
30
|
+
## Provider Instance
|
|
31
|
+
|
|
32
|
+
You can import the default provider instance `azure` from `@ai-sdk/azure`:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { azure } from '@ai-sdk/azure';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If you need a customized setup, you can import `createAzure` from `@ai-sdk/azure` and create a provider instance with your settings:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { createAzure } from '@ai-sdk/azure';
|
|
42
|
+
|
|
43
|
+
const azure = createAzure({
|
|
44
|
+
resourceName: 'your-resource-name', // Azure resource name
|
|
45
|
+
apiKey: 'your-api-key',
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You can use the following optional settings to customize the OpenAI provider instance:
|
|
50
|
+
|
|
51
|
+
- **resourceName** _string_
|
|
52
|
+
|
|
53
|
+
Azure resource name.
|
|
54
|
+
It defaults to the `AZURE_RESOURCE_NAME` environment variable.
|
|
55
|
+
|
|
56
|
+
The resource name is used in the assembled URL: `https://{resourceName}.openai.azure.com/openai/v1{path}`.
|
|
57
|
+
You can use `baseURL` instead to specify the URL prefix.
|
|
58
|
+
|
|
59
|
+
- **apiKey** _string_
|
|
60
|
+
|
|
61
|
+
API key that is being sent using the `api-key` header.
|
|
62
|
+
It defaults to the `AZURE_API_KEY` environment variable.
|
|
63
|
+
|
|
64
|
+
- **apiVersion** _string_
|
|
65
|
+
|
|
66
|
+
Sets a custom [api version](https://learn.microsoft.com/en-us/azure/ai-services/openai/api-version-deprecation).
|
|
67
|
+
Defaults to `v1`.
|
|
68
|
+
|
|
69
|
+
- **baseURL** _string_
|
|
70
|
+
|
|
71
|
+
Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
72
|
+
|
|
73
|
+
Either this or `resourceName` can be used.
|
|
74
|
+
When a baseURL is provided, the resourceName is ignored.
|
|
75
|
+
|
|
76
|
+
With a baseURL, the resolved URL is `{baseURL}/v1{path}`.
|
|
77
|
+
|
|
78
|
+
- **headers** _Record<string,string>_
|
|
79
|
+
|
|
80
|
+
Custom headers to include in the requests.
|
|
81
|
+
|
|
82
|
+
- **fetch** _(input: RequestInfo, init?: RequestInit) => Promise<Response>_
|
|
83
|
+
|
|
84
|
+
Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
|
|
85
|
+
Defaults to the global `fetch` function.
|
|
86
|
+
You can use it as a middleware to intercept requests,
|
|
87
|
+
or to provide a custom fetch implementation for e.g. testing.
|
|
88
|
+
|
|
89
|
+
- **useDeploymentBasedUrls** _boolean_
|
|
90
|
+
|
|
91
|
+
Use deployment-based URLs for API calls. Set to `true` to use the legacy deployment format:
|
|
92
|
+
`{baseURL}/deployments/{deploymentId}{path}?api-version={apiVersion}` instead of
|
|
93
|
+
`{baseURL}/v1{path}?api-version={apiVersion}`.
|
|
94
|
+
Defaults to `false`.
|
|
95
|
+
|
|
96
|
+
This option is useful for compatibility with certain Azure OpenAI models or deployments
|
|
97
|
+
that require the legacy endpoint format.
|
|
98
|
+
|
|
99
|
+
## Language Models
|
|
100
|
+
|
|
101
|
+
The Azure OpenAI provider instance is a function that you can invoke to create a language model:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
const model = azure('your-deployment-name');
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
You need to pass your deployment name as the first argument.
|
|
108
|
+
|
|
109
|
+
### Reasoning Models
|
|
110
|
+
|
|
111
|
+
Azure exposes the thinking of `DeepSeek-R1` in the generated text using the `<think>` tag.
|
|
112
|
+
You can use the `extractReasoningMiddleware` to extract this reasoning and expose it as a `reasoning` property on the result:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
import { azure } from '@ai-sdk/azure';
|
|
116
|
+
import { wrapLanguageModel, extractReasoningMiddleware } from 'ai';
|
|
117
|
+
|
|
118
|
+
const enhancedModel = wrapLanguageModel({
|
|
119
|
+
model: azure('your-deepseek-r1-deployment-name'),
|
|
120
|
+
middleware: extractReasoningMiddleware({ tagName: 'think' }),
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
You can then use that enhanced model in functions like `generateText` and `streamText`.
|
|
125
|
+
|
|
126
|
+
<Note>
|
|
127
|
+
The Azure provider calls the Responses API by default (unless you specify e.g.
|
|
128
|
+
`azure.chat`).
|
|
129
|
+
</Note>
|
|
130
|
+
|
|
131
|
+
### Example
|
|
132
|
+
|
|
133
|
+
You can use OpenAI language models to generate text with the `generateText` function:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
import { azure } from '@ai-sdk/azure';
|
|
137
|
+
import { generateText } from 'ai';
|
|
138
|
+
|
|
139
|
+
const { text } = await generateText({
|
|
140
|
+
model: azure('your-deployment-name'),
|
|
141
|
+
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
OpenAI language models can also be used in the `streamText`, `generateObject`, and `streamObject` functions
|
|
146
|
+
(see [AI SDK Core](/docs/ai-sdk-core)).
|
|
147
|
+
|
|
148
|
+
<Note>
|
|
149
|
+
Azure OpenAI sends larger chunks than OpenAI. This can lead to the perception
|
|
150
|
+
that the response is slower. See [Troubleshooting: Azure OpenAI Slow To
|
|
151
|
+
Stream](/docs/troubleshooting/common-issues/azure-stream-slow)
|
|
152
|
+
</Note>
|
|
153
|
+
|
|
154
|
+
### Provider Options
|
|
155
|
+
|
|
156
|
+
When using OpenAI language models on Azure, you can configure provider-specific options using `providerOptions.openai`. More information on available configuration options are on [the OpenAI provider page](/providers/ai-sdk-providers/openai#language-models).
|
|
157
|
+
|
|
158
|
+
```ts highlight="12-14,22-24"
|
|
159
|
+
const messages = [
|
|
160
|
+
{
|
|
161
|
+
role: 'user',
|
|
162
|
+
content: [
|
|
163
|
+
{
|
|
164
|
+
type: 'text',
|
|
165
|
+
text: 'What is the capital of the moon?',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
type: 'image',
|
|
169
|
+
image: 'https://example.com/image.png',
|
|
170
|
+
providerOptions: {
|
|
171
|
+
openai: { imageDetail: 'low' },
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
const { text } = await generateText({
|
|
179
|
+
model: azure('your-deployment-name'),
|
|
180
|
+
providerOptions: {
|
|
181
|
+
openai: {
|
|
182
|
+
reasoningEffort: 'low',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
});
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Chat Models
|
|
189
|
+
|
|
190
|
+
<Note>
|
|
191
|
+
The URL for calling Azure chat models will be constructed as follows:
|
|
192
|
+
`https://RESOURCE_NAME.openai.azure.com/openai/v1/chat/completions?api-version=v1`
|
|
193
|
+
</Note>
|
|
194
|
+
|
|
195
|
+
You can create models that call the Azure OpenAI chat completions API using the `.chat()` factory method:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const model = azure.chat('your-deployment-name');
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Azure OpenAI chat models support also some model specific settings that are not part of the [standard call settings](/docs/ai-sdk-core/settings).
|
|
202
|
+
You can pass them as an options argument:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { azure } from '@ai-sdk/azure';
|
|
206
|
+
import { generateText } from 'ai';
|
|
207
|
+
|
|
208
|
+
const result = await generateText({
|
|
209
|
+
model: azure.chat('your-deployment-name'),
|
|
210
|
+
prompt: 'Write a short story about a robot.',
|
|
211
|
+
providerOptions: {
|
|
212
|
+
openai: {
|
|
213
|
+
logitBias: {
|
|
214
|
+
// optional likelihood for specific tokens
|
|
215
|
+
'50256': -100,
|
|
216
|
+
},
|
|
217
|
+
user: 'test-user', // optional unique user identifier
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The following optional provider options are available for OpenAI chat models:
|
|
224
|
+
|
|
225
|
+
- **logitBias** _Record<number, number>_
|
|
226
|
+
|
|
227
|
+
Modifies the likelihood of specified tokens appearing in the completion.
|
|
228
|
+
|
|
229
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
230
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
231
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
232
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
233
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
234
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
235
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
236
|
+
|
|
237
|
+
As an example, you can pass `{"50256": -100}` to prevent the token from being generated.
|
|
238
|
+
|
|
239
|
+
- **logprobs** _boolean | number_
|
|
240
|
+
|
|
241
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
242
|
+
the response size and can slow down response times. However, it can
|
|
243
|
+
be useful to better understand how the model is behaving.
|
|
244
|
+
|
|
245
|
+
Setting to true will return the log probabilities of the tokens that
|
|
246
|
+
were generated.
|
|
247
|
+
|
|
248
|
+
Setting to a number will return the log probabilities of the top n
|
|
249
|
+
tokens that were generated.
|
|
250
|
+
|
|
251
|
+
- **parallelToolCalls** _boolean_
|
|
252
|
+
|
|
253
|
+
Whether to enable parallel function calling during tool use. Default to true.
|
|
254
|
+
|
|
255
|
+
- **user** _string_
|
|
256
|
+
|
|
257
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
258
|
+
monitor and detect abuse. Learn more.
|
|
259
|
+
|
|
260
|
+
### Responses Models
|
|
261
|
+
|
|
262
|
+
Azure OpenAI uses responses API as default with the `azure(deploymentName)` factory method.
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
const model = azure('your-deployment-name');
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
Further configuration can be done using OpenAI provider options.
|
|
269
|
+
You can validate the provider options using the `OpenAIResponsesProviderOptions` type.
|
|
270
|
+
|
|
271
|
+
<Note>
|
|
272
|
+
In the Responses API, use `azure` as the provider name in `providerOptions`
|
|
273
|
+
instead of `openai`. The `openai` key is still supported for `providerOptions`
|
|
274
|
+
input.
|
|
275
|
+
</Note>
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
import { azure, OpenAIResponsesProviderOptions } from '@ai-sdk/azure';
|
|
279
|
+
import { generateText } from 'ai';
|
|
280
|
+
|
|
281
|
+
const result = await generateText({
|
|
282
|
+
model: azure('your-deployment-name'),
|
|
283
|
+
providerOptions: {
|
|
284
|
+
azure: {
|
|
285
|
+
parallelToolCalls: false,
|
|
286
|
+
store: false,
|
|
287
|
+
user: 'user_123',
|
|
288
|
+
// ...
|
|
289
|
+
} satisfies OpenAIResponsesProviderOptions,
|
|
290
|
+
},
|
|
291
|
+
// ...
|
|
292
|
+
});
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
The following provider options are available:
|
|
296
|
+
|
|
297
|
+
- **parallelToolCalls** _boolean_
|
|
298
|
+
Whether to use parallel tool calls. Defaults to `true`.
|
|
299
|
+
|
|
300
|
+
- **store** _boolean_
|
|
301
|
+
Whether to store the generation. Defaults to `true`.
|
|
302
|
+
|
|
303
|
+
- **metadata** _Record<string, string>_
|
|
304
|
+
Additional metadata to store with the generation.
|
|
305
|
+
|
|
306
|
+
- **previousResponseId** _string_
|
|
307
|
+
The ID of the previous response. You can use it to continue a conversation. Defaults to `undefined`.
|
|
308
|
+
|
|
309
|
+
- **instructions** _string_
|
|
310
|
+
Instructions for the model.
|
|
311
|
+
They can be used to change the system or developer message when continuing a conversation using the `previousResponseId` option.
|
|
312
|
+
Defaults to `undefined`.
|
|
313
|
+
|
|
314
|
+
- **user** _string_
|
|
315
|
+
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Defaults to `undefined`.
|
|
316
|
+
|
|
317
|
+
- **reasoningEffort** _'low' | 'medium' | 'high'_
|
|
318
|
+
Reasoning effort for reasoning models. Defaults to `medium`. If you use `providerOptions` to set the `reasoningEffort` option, this model setting will be ignored.
|
|
319
|
+
|
|
320
|
+
- **strictJsonSchema** _boolean_
|
|
321
|
+
Whether to use strict JSON schema validation. Defaults to `false`.
|
|
322
|
+
|
|
323
|
+
The Azure OpenAI provider also returns provider-specific metadata:
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
const { providerMetadata } = await generateText({
|
|
327
|
+
model: azure('your-deployment-name'),
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const openaiMetadata = providerMetadata?.openai;
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
The following OpenAI-specific metadata is returned:
|
|
334
|
+
|
|
335
|
+
- **responseId** _string_
|
|
336
|
+
The ID of the response. Can be used to continue a conversation.
|
|
337
|
+
|
|
338
|
+
- **cachedPromptTokens** _number_
|
|
339
|
+
The number of prompt tokens that were a cache hit.
|
|
340
|
+
|
|
341
|
+
- **reasoningTokens** _number_
|
|
342
|
+
The number of reasoning tokens that the model generated.
|
|
343
|
+
|
|
344
|
+
<Note>
|
|
345
|
+
The providerMetadata is only returned with the default responses API, and is
|
|
346
|
+
not supported when using 'azure.chat' or 'azure.completion'
|
|
347
|
+
</Note>
|
|
348
|
+
|
|
349
|
+
#### Web Search Tool
|
|
350
|
+
|
|
351
|
+
The Azure OpenAI responses API supports web search(preview) through the `azure.tools.webSearchPreview` tool.
|
|
352
|
+
|
|
353
|
+
```ts
|
|
354
|
+
const result = await generateText({
|
|
355
|
+
model: azure('gpt-4.1-mini'),
|
|
356
|
+
prompt: 'What happened in San Francisco last week?',
|
|
357
|
+
tools: {
|
|
358
|
+
web_search_preview: azure.tools.webSearchPreview({
|
|
359
|
+
// optional configuration:
|
|
360
|
+
searchContextSize: 'low',
|
|
361
|
+
userLocation: {
|
|
362
|
+
type: 'approximate',
|
|
363
|
+
city: 'San Francisco',
|
|
364
|
+
region: 'California',
|
|
365
|
+
},
|
|
366
|
+
}),
|
|
367
|
+
},
|
|
368
|
+
// Force web search tool (optional):
|
|
369
|
+
toolChoice: { type: 'tool', toolName: 'web_search_preview' },
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
console.log(result.text);
|
|
373
|
+
|
|
374
|
+
// URL sources directly from `results`
|
|
375
|
+
const sources = result.sources;
|
|
376
|
+
for (const source of sources) {
|
|
377
|
+
console.log('source:', source);
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
<Note>
|
|
382
|
+
The tool must be named `web_search_preview` when using Azure OpenAI's web
|
|
383
|
+
search(preview) functionality. This name is required by Azure OpenAI's API
|
|
384
|
+
specification and cannot be customized.
|
|
385
|
+
</Note>
|
|
386
|
+
|
|
387
|
+
<Note>
|
|
388
|
+
The 'web_search_preview' tool is only supported with the default responses
|
|
389
|
+
API, and is not supported when using 'azure.chat' or 'azure.completion'
|
|
390
|
+
</Note>
|
|
391
|
+
|
|
392
|
+
#### File Search Tool
|
|
393
|
+
|
|
394
|
+
The Azure OpenAI provider supports file search through the `azure.tools.fileSearch` tool.
|
|
395
|
+
|
|
396
|
+
You can force the use of the file search tool by setting the `toolChoice` parameter to `{ type: 'tool', toolName: 'file_search' }`.
|
|
397
|
+
|
|
398
|
+
```ts
|
|
399
|
+
const result = await generateText({
|
|
400
|
+
model: azure('gpt-5'),
|
|
401
|
+
prompt: 'What does the document say about user authentication?',
|
|
402
|
+
tools: {
|
|
403
|
+
file_search: azure.tools.fileSearch({
|
|
404
|
+
// optional configuration:
|
|
405
|
+
vectorStoreIds: ['vs_123', 'vs_456'],
|
|
406
|
+
maxNumResults: 10,
|
|
407
|
+
ranking: {
|
|
408
|
+
ranker: 'auto',
|
|
409
|
+
},
|
|
410
|
+
}),
|
|
411
|
+
},
|
|
412
|
+
// Force file search tool:
|
|
413
|
+
toolChoice: { type: 'tool', toolName: 'file_search' },
|
|
414
|
+
});
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
<Note>
|
|
418
|
+
The tool must be named `file_search` when using Azure OpenAI's file search
|
|
419
|
+
functionality. This name is required by Azure OpenAI's API specification and
|
|
420
|
+
cannot be customized.
|
|
421
|
+
</Note>
|
|
422
|
+
|
|
423
|
+
<Note>
|
|
424
|
+
The 'file_search' tool is only supported with the default responses API, and
|
|
425
|
+
is not supported when using 'azure.chat' or 'azure.completion'
|
|
426
|
+
</Note>
|
|
427
|
+
|
|
428
|
+
#### Image Generation Tool
|
|
429
|
+
|
|
430
|
+
Azure OpenAI's Responses API supports multi-modal image generation as a provider-defined tool.
|
|
431
|
+
Availability is restricted to specific models (for example, `gpt-5` variants).
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
import { createAzure } from '@ai-sdk/azure';
|
|
435
|
+
import { generateText } from 'ai';
|
|
436
|
+
|
|
437
|
+
const azure = createAzure({
|
|
438
|
+
headers: {
|
|
439
|
+
'x-ms-oai-image-generation-deployment': 'gpt-image-1', // use your own image model deployment
|
|
440
|
+
},
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
const result = await generateText({
|
|
444
|
+
model: azure('gpt-5'),
|
|
445
|
+
prompt:
|
|
446
|
+
'Generate an image of an echidna swimming across the Mozambique channel.',
|
|
447
|
+
tools: {
|
|
448
|
+
image_generation: azure.tools.imageGeneration({ outputFormat: 'png' }),
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
for (const toolResult of result.staticToolResults) {
|
|
453
|
+
if (toolResult.toolName === 'image_generation') {
|
|
454
|
+
const base64Image = toolResult.output.result;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
<Note>
|
|
460
|
+
The tool must be named `image_generation` when using Azure OpenAI's image
|
|
461
|
+
generation functionality. This name is required by Azure OpenAI's API
|
|
462
|
+
specification and cannot be customized.
|
|
463
|
+
</Note>
|
|
464
|
+
|
|
465
|
+
<Note>
|
|
466
|
+
The 'image_generation' tool is only supported with the default responses API,
|
|
467
|
+
and is not supported when using 'azure.chat' or 'azure.completion'
|
|
468
|
+
</Note>
|
|
469
|
+
|
|
470
|
+
<Note>
|
|
471
|
+
To use image_generation, you must first create an image generation model. You
|
|
472
|
+
must add a deployment specification to the header
|
|
473
|
+
`x-ms-oai-image-generation-deployment`. Please note that the Responses API
|
|
474
|
+
model and the image generation model must be in the same resource.
|
|
475
|
+
</Note>
|
|
476
|
+
|
|
477
|
+
<Note>
|
|
478
|
+
When you set `store: false`, then previously generated images will not be
|
|
479
|
+
accessible by the model. We recommend using the image generation tool without
|
|
480
|
+
setting `store: false`.
|
|
481
|
+
</Note>
|
|
482
|
+
|
|
483
|
+
#### Code Interpreter Tool
|
|
484
|
+
|
|
485
|
+
The Azure OpenAI provider supports the code interpreter tool through the `azure.tools.codeInterpreter` tool. This allows models to write and execute Python code.
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
import { azure } from '@ai-sdk/azure';
|
|
489
|
+
import { generateText } from 'ai';
|
|
490
|
+
|
|
491
|
+
const result = await generateText({
|
|
492
|
+
model: azure('gpt-5'),
|
|
493
|
+
prompt: 'Write and run Python code to calculate the factorial of 10',
|
|
494
|
+
tools: {
|
|
495
|
+
code_interpreter: azure.tools.codeInterpreter({
|
|
496
|
+
// optional configuration:
|
|
497
|
+
container: {
|
|
498
|
+
fileIds: ['assistant-123', 'assistant-456'], // optional file IDs to make available
|
|
499
|
+
},
|
|
500
|
+
}),
|
|
501
|
+
},
|
|
502
|
+
});
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
The code interpreter tool can be configured with:
|
|
506
|
+
|
|
507
|
+
- **container**: Either a container ID string or an object with `fileIds` to specify uploaded files that should be available to the code interpreter
|
|
508
|
+
|
|
509
|
+
<Note>
|
|
510
|
+
The tool must be named `code_interpreter` when using Azure OpenAI's code
|
|
511
|
+
interpreter functionality. This name is required by Azure OpenAI's API
|
|
512
|
+
specification and cannot be customized.
|
|
513
|
+
</Note>
|
|
514
|
+
|
|
515
|
+
<Note>
|
|
516
|
+
The 'code_interpreter' tool is only supported with the default responses API,
|
|
517
|
+
and is not supported when using 'azure.chat' or 'azure.completion'
|
|
518
|
+
</Note>
|
|
519
|
+
|
|
520
|
+
<Note>
|
|
521
|
+
When working with files generated by the Code Interpreter, reference
|
|
522
|
+
information can be obtained from both [annotations in Text
|
|
523
|
+
Parts](#typed-providermetadata-in-text-parts) and [`providerMetadata` in
|
|
524
|
+
Source Document Parts](#typed-providermetadata-in-source-document-parts).
|
|
525
|
+
</Note>
|
|
526
|
+
|
|
527
|
+
#### PDF support
|
|
528
|
+
|
|
529
|
+
The Azure OpenAI provider supports reading PDF files.
|
|
530
|
+
You can pass PDF files as part of the message content using the `file` type:
|
|
531
|
+
|
|
532
|
+
```ts
|
|
533
|
+
const result = await generateText({
|
|
534
|
+
model: azure('your-deployment-name'),
|
|
535
|
+
messages: [
|
|
536
|
+
{
|
|
537
|
+
role: 'user',
|
|
538
|
+
content: [
|
|
539
|
+
{
|
|
540
|
+
type: 'text',
|
|
541
|
+
text: 'What is an embedding model?',
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
type: 'file',
|
|
545
|
+
data: fs.readFileSync('./data/ai.pdf'),
|
|
546
|
+
mediaType: 'application/pdf',
|
|
547
|
+
filename: 'ai.pdf', // optional
|
|
548
|
+
},
|
|
549
|
+
],
|
|
550
|
+
},
|
|
551
|
+
],
|
|
552
|
+
});
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
The model will have access to the contents of the PDF file and
|
|
556
|
+
respond to questions about it.
|
|
557
|
+
The PDF file should be passed using the `data` field,
|
|
558
|
+
and the `mediaType` should be set to `'application/pdf'`.
|
|
559
|
+
|
|
560
|
+
<Note>
|
|
561
|
+
Reading PDF files are only supported with the default responses API, and is
|
|
562
|
+
not supported when using 'azure.chat' or 'azure.completion'
|
|
563
|
+
</Note>
|
|
564
|
+
|
|
565
|
+
#### Typed providerMetadata in Text Parts
|
|
566
|
+
|
|
567
|
+
When using the Azure OpenAI Responses API, the SDK attaches Azure OpenAI-specific metadata to output parts via `providerMetadata`.
|
|
568
|
+
|
|
569
|
+
This metadata can be used on the client side for tasks such as rendering citations or downloading files generated by the Code Interpreter.
|
|
570
|
+
To enable type-safe handling of this metadata, the AI SDK exports dedicated TypeScript types.
|
|
571
|
+
|
|
572
|
+
For text parts, when `part.type === 'text'`, the `providerMetadata` is provided in the form of `AzureResponsesTextProviderMetadata`.
|
|
573
|
+
|
|
574
|
+
This metadata includes the following fields:
|
|
575
|
+
|
|
576
|
+
- `itemId`
|
|
577
|
+
The ID of the output item in the Responses API.
|
|
578
|
+
- `annotations` (optional)
|
|
579
|
+
An array of annotation objects generated by the model.
|
|
580
|
+
If no annotations are present, this property itself may be omitted (`undefined`).
|
|
581
|
+
|
|
582
|
+
Each element in `annotations` is a discriminated union with a required `type` field. Supported types include, for example:
|
|
583
|
+
|
|
584
|
+
- `url_citation`
|
|
585
|
+
- `file_citation`
|
|
586
|
+
- `container_file_citation`
|
|
587
|
+
- `file_path`
|
|
588
|
+
|
|
589
|
+
These annotations directly correspond to the annotation objects defined by the Responses API and can be used for inline reference rendering or output analysis.
|
|
590
|
+
For details, see the official OpenAI documentation:
|
|
591
|
+
[Responses API – output text annotations](https://platform.openai.com/docs/api-reference/responses/object?lang=javascript#responses-object-output-output_message-content-output_text-annotations).
|
|
592
|
+
|
|
593
|
+
```ts
|
|
594
|
+
import { azure, type AzureResponsesTextProviderMetadata } from '@ai-sdk/azure';
|
|
595
|
+
import { generateText } from 'ai';
|
|
596
|
+
|
|
597
|
+
const result = await generateText({
|
|
598
|
+
model: azure('gpt-4.1-mini'),
|
|
599
|
+
prompt:
|
|
600
|
+
'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results. Also save the result to a file.',
|
|
601
|
+
tools: {
|
|
602
|
+
code_interpreter: azure.tools.codeInterpreter(),
|
|
603
|
+
web_search_preview: azure.tools.webSearchPreview({}),
|
|
604
|
+
file_search: azure.tools.fileSearch({ vectorStoreIds: ['vs_1234'] }), // requires a configured vector store
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
|
|
608
|
+
for (const part of result.content) {
|
|
609
|
+
if (part.type === 'text') {
|
|
610
|
+
const providerMetadata = part.providerMetadata as
|
|
611
|
+
| AzureResponsesTextProviderMetadata
|
|
612
|
+
| undefined;
|
|
613
|
+
if (!providerMetadata) continue;
|
|
614
|
+
const { itemId: _itemId, annotations } = providerMetadata.azure;
|
|
615
|
+
|
|
616
|
+
if (!annotations) continue;
|
|
617
|
+
for (const annotation of annotations) {
|
|
618
|
+
switch (annotation.type) {
|
|
619
|
+
case 'url_citation':
|
|
620
|
+
// url_citation is returned from web_search and provides:
|
|
621
|
+
// properties: type, url, title, start_index and end_index
|
|
622
|
+
break;
|
|
623
|
+
case 'file_citation':
|
|
624
|
+
// file_citation is returned from file_search and provides:
|
|
625
|
+
// properties: type, file_id, filename and index
|
|
626
|
+
break;
|
|
627
|
+
case 'container_file_citation':
|
|
628
|
+
// container_file_citation is returned from code_interpreter and provides:
|
|
629
|
+
// properties: type, container_id, file_id, filename, start_index and end_index
|
|
630
|
+
break;
|
|
631
|
+
case 'file_path':
|
|
632
|
+
// file_path provides:
|
|
633
|
+
// properties: type, file_id and index
|
|
634
|
+
break;
|
|
635
|
+
default: {
|
|
636
|
+
const _exhaustiveCheck: never = annotation;
|
|
637
|
+
throw new Error(
|
|
638
|
+
`Unhandled annotation: ${JSON.stringify(_exhaustiveCheck)}`,
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
<Note>
|
|
648
|
+
When implementing file downloads for files generated by the Code Interpreter,
|
|
649
|
+
the `container_id` and `file_id` available in `providerMetadata` can be used
|
|
650
|
+
to retrieve the file content. For details, see the [Retrieve container file
|
|
651
|
+
content](https://platform.openai.com/docs/api-reference/container-files/retrieveContainerFileContent)
|
|
652
|
+
API.
|
|
653
|
+
</Note>
|
|
654
|
+
|
|
655
|
+
#### Typed providerMetadata in Source Document Parts
|
|
656
|
+
|
|
657
|
+
For source document parts, when `part.type === 'source'` and `sourceType === 'document'`, the `providerMetadata` is provided as `AzureResponsesSourceDocumentProviderMetadata`.
|
|
658
|
+
|
|
659
|
+
This metadata is also a discriminated union with a required `type` field. Supported types include:
|
|
660
|
+
|
|
661
|
+
- `file_citation`
|
|
662
|
+
- `container_file_citation`
|
|
663
|
+
- `file_path`
|
|
664
|
+
|
|
665
|
+
Each type includes the identifiers required to work with the referenced resource, such as `fileId` and `containerId`.
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
import {
|
|
669
|
+
azure,
|
|
670
|
+
type AzureResponsesSourceDocumentProviderMetadata,
|
|
671
|
+
} from '@ai-sdk/azure';
|
|
672
|
+
import { generateText } from 'ai';
|
|
673
|
+
|
|
674
|
+
const result = await generateText({
|
|
675
|
+
model: azure('gpt-4.1-mini'),
|
|
676
|
+
prompt:
|
|
677
|
+
'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results. Also save the result to a file.',
|
|
678
|
+
tools: {
|
|
679
|
+
code_interpreter: azure.tools.codeInterpreter(),
|
|
680
|
+
web_search_preview: azure.tools.webSearchPreview({}),
|
|
681
|
+
file_search: azure.tools.fileSearch({ vectorStoreIds: ['vs_1234'] }), // requires a configured vector store
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
for (const part of result.content) {
|
|
686
|
+
if (part.type === 'source') {
|
|
687
|
+
if (part.sourceType === 'document') {
|
|
688
|
+
const providerMetadata = part.providerMetadata as
|
|
689
|
+
| AzureResponsesSourceDocumentProviderMetadata
|
|
690
|
+
| undefined;
|
|
691
|
+
if (!providerMetadata) continue;
|
|
692
|
+
const annotation = providerMetadata.azure;
|
|
693
|
+
switch (annotation.type) {
|
|
694
|
+
case 'file_citation':
|
|
695
|
+
// file_citation is returned from file_search and provides:
|
|
696
|
+
// properties: type, fileId and index
|
|
697
|
+
// The filename can be accessed via part.filename.
|
|
698
|
+
break;
|
|
699
|
+
case 'container_file_citation':
|
|
700
|
+
// container_file_citation is returned from code_interpreter and provides:
|
|
701
|
+
// properties: type, containerId and fileId
|
|
702
|
+
// The filename can be accessed via part.filename.
|
|
703
|
+
break;
|
|
704
|
+
case 'file_path':
|
|
705
|
+
// file_path provides:
|
|
706
|
+
// properties: type, fileId and index
|
|
707
|
+
break;
|
|
708
|
+
default: {
|
|
709
|
+
const _exhaustiveCheck: never = annotation;
|
|
710
|
+
throw new Error(
|
|
711
|
+
`Unhandled annotation: ${JSON.stringify(_exhaustiveCheck)}`,
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
<Note>
|
|
721
|
+
Annotations in text parts follow the OpenAI Responses API specification and
|
|
722
|
+
therefore use snake_case properties (e.g. `file_id`, `container_id`). In
|
|
723
|
+
contrast, `providerMetadata` for source document parts is normalized by the
|
|
724
|
+
SDK to camelCase (e.g. `fileId`, `containerId`). Fields that depend on the
|
|
725
|
+
original text content, such as `start_index` and `end_index`, are omitted, as
|
|
726
|
+
are fields like `filename` that are directly available on the source object.
|
|
727
|
+
</Note>
|
|
728
|
+
|
|
729
|
+
### Completion Models
|
|
730
|
+
|
|
731
|
+
You can create models that call the completions API using the `.completion()` factory method.
|
|
732
|
+
The first argument is the model id.
|
|
733
|
+
Currently only `gpt-35-turbo-instruct` is supported.
|
|
734
|
+
|
|
735
|
+
```ts
|
|
736
|
+
const model = azure.completion('your-gpt-35-turbo-instruct-deployment');
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
OpenAI completion models support also some model specific settings that are not part of the [standard call settings](/docs/ai-sdk-core/settings).
|
|
740
|
+
You can pass them as an options argument:
|
|
741
|
+
|
|
742
|
+
```ts
|
|
743
|
+
import { azure } from '@ai-sdk/azure';
|
|
744
|
+
import { generateText } from 'ai';
|
|
745
|
+
|
|
746
|
+
const result = await generateText({
|
|
747
|
+
model: azure.completion('your-gpt-35-turbo-instruct-deployment'),
|
|
748
|
+
prompt: 'Write a haiku about coding.',
|
|
749
|
+
providerOptions: {
|
|
750
|
+
openai: {
|
|
751
|
+
echo: true, // optional, echo the prompt in addition to the completion
|
|
752
|
+
logitBias: {
|
|
753
|
+
// optional likelihood for specific tokens
|
|
754
|
+
'50256': -100,
|
|
755
|
+
},
|
|
756
|
+
suffix: 'some text', // optional suffix that comes after a completion of inserted text
|
|
757
|
+
user: 'test-user', // optional unique user identifier
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
});
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
The following optional provider options are available for Azure OpenAI completion models:
|
|
764
|
+
|
|
765
|
+
- **echo**: _boolean_
|
|
766
|
+
|
|
767
|
+
Echo back the prompt in addition to the completion.
|
|
768
|
+
|
|
769
|
+
- **logitBias** _Record<number, number>_
|
|
770
|
+
|
|
771
|
+
Modifies the likelihood of specified tokens appearing in the completion.
|
|
772
|
+
|
|
773
|
+
Accepts a JSON object that maps tokens (specified by their token ID in
|
|
774
|
+
the GPT tokenizer) to an associated bias value from -100 to 100. You
|
|
775
|
+
can use this tokenizer tool to convert text to token IDs. Mathematically,
|
|
776
|
+
the bias is added to the logits generated by the model prior to sampling.
|
|
777
|
+
The exact effect will vary per model, but values between -1 and 1 should
|
|
778
|
+
decrease or increase likelihood of selection; values like -100 or 100
|
|
779
|
+
should result in a ban or exclusive selection of the relevant token.
|
|
780
|
+
|
|
781
|
+
As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|>
|
|
782
|
+
token from being generated.
|
|
783
|
+
|
|
784
|
+
- **logprobs** _boolean | number_
|
|
785
|
+
|
|
786
|
+
Return the log probabilities of the tokens. Including logprobs will increase
|
|
787
|
+
the response size and can slow down response times. However, it can
|
|
788
|
+
be useful to better understand how the model is behaving.
|
|
789
|
+
|
|
790
|
+
Setting to true will return the log probabilities of the tokens that
|
|
791
|
+
were generated.
|
|
792
|
+
|
|
793
|
+
Setting to a number will return the log probabilities of the top n
|
|
794
|
+
tokens that were generated.
|
|
795
|
+
|
|
796
|
+
- **suffix** _string_
|
|
797
|
+
|
|
798
|
+
The suffix that comes after a completion of inserted text.
|
|
799
|
+
|
|
800
|
+
- **user** _string_
|
|
801
|
+
|
|
802
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
803
|
+
monitor and detect abuse. Learn more.
|
|
804
|
+
|
|
805
|
+
## Embedding Models
|
|
806
|
+
|
|
807
|
+
You can create models that call the Azure OpenAI embeddings API
|
|
808
|
+
using the `.embedding()` factory method.
|
|
809
|
+
|
|
810
|
+
```ts
|
|
811
|
+
const model = azure.embedding('your-embedding-deployment');
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
Azure OpenAI embedding models support several additional settings.
|
|
815
|
+
You can pass them as an options argument:
|
|
816
|
+
|
|
817
|
+
```ts
|
|
818
|
+
import { azure } from '@ai-sdk/azure';
|
|
819
|
+
import { embed } from 'ai';
|
|
820
|
+
|
|
821
|
+
const { embedding } = await embed({
|
|
822
|
+
model: azure.embedding('your-embedding-deployment'),
|
|
823
|
+
value: 'sunny day at the beach',
|
|
824
|
+
providerOptions: {
|
|
825
|
+
openai: {
|
|
826
|
+
dimensions: 512, // optional, number of dimensions for the embedding
|
|
827
|
+
user: 'test-user', // optional unique user identifier
|
|
828
|
+
},
|
|
829
|
+
},
|
|
830
|
+
});
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
The following optional provider options are available for Azure OpenAI embedding models:
|
|
834
|
+
|
|
835
|
+
- **dimensions**: _number_
|
|
836
|
+
|
|
837
|
+
The number of dimensions the resulting output embeddings should have.
|
|
838
|
+
Only supported in text-embedding-3 and later models.
|
|
839
|
+
|
|
840
|
+
- **user** _string_
|
|
841
|
+
|
|
842
|
+
A unique identifier representing your end-user, which can help OpenAI to
|
|
843
|
+
monitor and detect abuse. Learn more.
|
|
844
|
+
|
|
845
|
+
## Image Models
|
|
846
|
+
|
|
847
|
+
You can create models that call the Azure OpenAI image generation API (DALL-E) using the `.image()` factory method. The first argument is your deployment name for the DALL-E model.
|
|
848
|
+
|
|
849
|
+
```ts
|
|
850
|
+
const model = azure.image('your-dalle-deployment-name');
|
|
851
|
+
```
|
|
852
|
+
|
|
853
|
+
Azure OpenAI image models support several additional settings. You can pass them as `providerOptions.openai` when generating the image:
|
|
854
|
+
|
|
855
|
+
```ts
|
|
856
|
+
await generateImage({
|
|
857
|
+
model: azure.image('your-dalle-deployment-name'),
|
|
858
|
+
prompt: 'A photorealistic image of a cat astronaut floating in space',
|
|
859
|
+
size: '1024x1024', // '1024x1024', '1792x1024', or '1024x1792' for DALL-E 3
|
|
860
|
+
providerOptions: {
|
|
861
|
+
openai: {
|
|
862
|
+
user: 'test-user', // optional unique user identifier
|
|
863
|
+
responseFormat: 'url', // 'url' or 'b64_json', defaults to 'url'
|
|
864
|
+
},
|
|
865
|
+
},
|
|
866
|
+
});
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
### Example
|
|
870
|
+
|
|
871
|
+
You can use Azure OpenAI image models to generate images with the `generateImage` function:
|
|
872
|
+
|
|
873
|
+
```ts
|
|
874
|
+
import { azure } from '@ai-sdk/azure';
|
|
875
|
+
import { generateImage } from 'ai';
|
|
876
|
+
|
|
877
|
+
const { image } = await generateImage({
|
|
878
|
+
model: azure.image('your-dalle-deployment-name'),
|
|
879
|
+
prompt: 'A photorealistic image of a cat astronaut floating in space',
|
|
880
|
+
size: '1024x1024', // '1024x1024', '1792x1024', or '1024x1792' for DALL-E 3
|
|
881
|
+
});
|
|
882
|
+
|
|
883
|
+
// image contains the URL or base64 data of the generated image
|
|
884
|
+
console.log(image);
|
|
885
|
+
```
|
|
886
|
+
|
|
887
|
+
### Model Capabilities
|
|
888
|
+
|
|
889
|
+
Azure OpenAI supports DALL-E 2 and DALL-E 3 models through deployments. The capabilities depend on which model version your deployment is using:
|
|
890
|
+
|
|
891
|
+
| Model Version | Sizes |
|
|
892
|
+
| ------------- | ------------------------------- |
|
|
893
|
+
| DALL-E 3 | 1024x1024, 1792x1024, 1024x1792 |
|
|
894
|
+
| DALL-E 2 | 256x256, 512x512, 1024x1024 |
|
|
895
|
+
|
|
896
|
+
<Note>
|
|
897
|
+
DALL-E models do not support the `aspectRatio` parameter. Use the `size`
|
|
898
|
+
parameter instead.
|
|
899
|
+
</Note>
|
|
900
|
+
|
|
901
|
+
<Note>
|
|
902
|
+
When creating your Azure OpenAI deployment, make sure to set the DALL-E model
|
|
903
|
+
version you want to use.
|
|
904
|
+
</Note>
|
|
905
|
+
|
|
906
|
+
## Transcription Models
|
|
907
|
+
|
|
908
|
+
You can create models that call the Azure OpenAI transcription API using the `.transcription()` factory method.
|
|
909
|
+
|
|
910
|
+
The first argument is the model id e.g. `whisper-1`.
|
|
911
|
+
|
|
912
|
+
```ts
|
|
913
|
+
const model = azure.transcription('whisper-1');
|
|
914
|
+
```
|
|
915
|
+
|
|
916
|
+
<Note>
|
|
917
|
+
If you encounter a "DeploymentNotFound" error with transcription models,
|
|
918
|
+
try enabling deployment-based URLs:
|
|
919
|
+
|
|
920
|
+
```ts
|
|
921
|
+
const azure = createAzure({
|
|
922
|
+
useDeploymentBasedUrls: true,
|
|
923
|
+
apiVersion: '2025-04-01-preview',
|
|
924
|
+
});
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
This uses the legacy endpoint format which may be required for certain Azure OpenAI deployments.
|
|
928
|
+
When using useDeploymentBasedUrls, the default api-version is not valid. You must set it to `2025-04-01-preview` or an earlier value.
|
|
929
|
+
|
|
930
|
+
</Note>
|
|
931
|
+
|
|
932
|
+
You can also pass additional provider-specific options using the `providerOptions` argument. For example, supplying the input language in ISO-639-1 (e.g. `en`) format will improve accuracy and latency.
|
|
933
|
+
|
|
934
|
+
```ts highlight="6"
|
|
935
|
+
import { experimental_transcribe as transcribe } from 'ai';
|
|
936
|
+
import { azure } from '@ai-sdk/azure';
|
|
937
|
+
import { readFile } from 'fs/promises';
|
|
938
|
+
|
|
939
|
+
const result = await transcribe({
|
|
940
|
+
model: azure.transcription('whisper-1'),
|
|
941
|
+
audio: await readFile('audio.mp3'),
|
|
942
|
+
providerOptions: { openai: { language: 'en' } },
|
|
943
|
+
});
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
The following provider options are available:
|
|
947
|
+
|
|
948
|
+
- **timestampGranularities** _string[]_
|
|
949
|
+
The granularity of the timestamps in the transcription.
|
|
950
|
+
Defaults to `['segment']`.
|
|
951
|
+
Possible values are `['word']`, `['segment']`, and `['word', 'segment']`.
|
|
952
|
+
Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.
|
|
953
|
+
|
|
954
|
+
- **language** _string_
|
|
955
|
+
The language of the input audio. Supplying the input language in ISO-639-1 format (e.g. 'en') will improve accuracy and latency.
|
|
956
|
+
Optional.
|
|
957
|
+
|
|
958
|
+
- **prompt** _string_
|
|
959
|
+
An optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language.
|
|
960
|
+
Optional.
|
|
961
|
+
|
|
962
|
+
- **temperature** _number_
|
|
963
|
+
The sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
|
|
964
|
+
Defaults to 0.
|
|
965
|
+
Optional.
|
|
966
|
+
|
|
967
|
+
- **include** _string[]_
|
|
968
|
+
Additional information to include in the transcription response.
|
|
969
|
+
|
|
970
|
+
### Model Capabilities
|
|
971
|
+
|
|
972
|
+
| Model | Transcription | Duration | Segments | Language |
|
|
973
|
+
| ------------------------ | ------------------- | ------------------- | ------------------- | ------------------- |
|
|
974
|
+
| `whisper-1` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
975
|
+
| `gpt-4o-mini-transcribe` | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
|
|
976
|
+
| `gpt-4o-transcribe` | <Check size={18} /> | <Cross size={18} /> | <Cross size={18} /> | <Cross size={18} /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/azure",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.16",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
11
|
+
"docs/**/*",
|
|
11
12
|
"src",
|
|
12
13
|
"CHANGELOG.md",
|
|
13
14
|
"README.md"
|
|
14
15
|
],
|
|
16
|
+
"directories": {
|
|
17
|
+
"doc": "./docs"
|
|
18
|
+
},
|
|
15
19
|
"exports": {
|
|
16
20
|
"./package.json": "./package.json",
|
|
17
21
|
".": {
|
|
@@ -21,7 +25,7 @@
|
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"dependencies": {
|
|
24
|
-
"@ai-sdk/openai": "3.0.
|
|
28
|
+
"@ai-sdk/openai": "3.0.16",
|
|
25
29
|
"@ai-sdk/provider": "3.0.4",
|
|
26
30
|
"@ai-sdk/provider-utils": "4.0.8"
|
|
27
31
|
},
|
|
@@ -56,7 +60,7 @@
|
|
|
56
60
|
"scripts": {
|
|
57
61
|
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
|
58
62
|
"build:watch": "pnpm clean && tsup --watch",
|
|
59
|
-
"clean": "del-cli dist *.tsbuildinfo",
|
|
63
|
+
"clean": "del-cli dist docs *.tsbuildinfo",
|
|
60
64
|
"lint": "eslint \"./**/*.ts*\"",
|
|
61
65
|
"type-check": "tsc --build",
|
|
62
66
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|