@ai-sdk/azure 4.0.116 → 4.0.118
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 +43 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +137 -28
- package/dist/index.js.map +1 -1
- package/docs/04-azure.mdx +401 -20
- package/package.json +6 -6
- package/src/azure-deployment-model-catalog.ts +21 -0
- package/src/azure-image-model-options.ts +2 -10
- package/src/azure-model-catalog.ts +166 -0
- package/src/azure-openai-tools.ts +9 -0
- package/src/azure-speech-model-options.ts +2 -9
- package/src/azure-speech-transcription-model.ts +50 -3
- package/src/azure-transcription-model-options.ts +8 -12
package/docs/04-azure.mdx
CHANGED
|
@@ -734,7 +734,21 @@ const result = await generateText({
|
|
|
734
734
|
|
|
735
735
|
The code interpreter tool can be configured with:
|
|
736
736
|
|
|
737
|
-
- **container**: Either
|
|
737
|
+
- **container**: Either:
|
|
738
|
+
- a container ID (`string`) to reuse an existing container, or
|
|
739
|
+
- a configuration `object` to create and configure a new container.
|
|
740
|
+
|
|
741
|
+
- **container configuration object**
|
|
742
|
+
- **fileIds** _string[]_ — File IDs to make available in the container at startup
|
|
743
|
+
- **memoryLimit** _'1g' | '4g' | '16g' | '64g'_ — Memory limit for the container
|
|
744
|
+
|
|
745
|
+
<Note type="warning">
|
|
746
|
+
The shared `networkPolicy` container option is exposed by
|
|
747
|
+
`azure.tools.codeInterpreter`, but outbound networking availability is
|
|
748
|
+
controlled by Azure OpenAI. Check the supported options for your deployment
|
|
749
|
+
and API version in the [Azure Responses API
|
|
750
|
+
documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/openai/how-to/responses).
|
|
751
|
+
</Note>
|
|
738
752
|
|
|
739
753
|
<Note>
|
|
740
754
|
The tool must be named `code_interpreter` when using Azure OpenAI's code
|
|
@@ -754,6 +768,319 @@ The code interpreter tool can be configured with:
|
|
|
754
768
|
Source Document Parts](#typed-providermetadata-in-source-document-parts).
|
|
755
769
|
</Note>
|
|
756
770
|
|
|
771
|
+
#### Custom Tool
|
|
772
|
+
|
|
773
|
+
Use `azure.tools.customTool` to send OpenAI-style
|
|
774
|
+
[custom tools](https://developers.openai.com/api/docs/guides/function-calling/#custom-tools)
|
|
775
|
+
with Azure Responses models. Availability depends on your Azure model deployment
|
|
776
|
+
and API version; see Microsoft's [reasoning model documentation](https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/reasoning).
|
|
777
|
+
Custom tool calls contain a raw string input instead of JSON, optionally constrained
|
|
778
|
+
to a regex or Lark grammar. This is useful for SQL queries, code snippets, or other
|
|
779
|
+
text that must match a specific pattern.
|
|
780
|
+
|
|
781
|
+
<Note>
|
|
782
|
+
Replace `your-deployment-name` below with an Azure deployment that supports
|
|
783
|
+
custom tools. These tools use the Responses API, rather than `azure.chat` or
|
|
784
|
+
`azure.completion`.
|
|
785
|
+
</Note>
|
|
786
|
+
|
|
787
|
+
```ts
|
|
788
|
+
import { azure } from '@ai-sdk/azure';
|
|
789
|
+
import { generateText, isStepCount } from 'ai';
|
|
790
|
+
|
|
791
|
+
const result = await generateText({
|
|
792
|
+
model: azure.responses('your-deployment-name'),
|
|
793
|
+
tools: {
|
|
794
|
+
write_sql: azure.tools.customTool({
|
|
795
|
+
description: 'Write a SQL SELECT query to answer the user question.',
|
|
796
|
+
format: {
|
|
797
|
+
type: 'grammar',
|
|
798
|
+
syntax: 'regex',
|
|
799
|
+
definition: 'SELECT .+',
|
|
800
|
+
},
|
|
801
|
+
execute: async input => {
|
|
802
|
+
// input is a raw string matching the grammar, e.g. "SELECT * FROM users WHERE age > 25"
|
|
803
|
+
const rows = await db.query(input);
|
|
804
|
+
return JSON.stringify(rows);
|
|
805
|
+
},
|
|
806
|
+
}),
|
|
807
|
+
},
|
|
808
|
+
toolChoice: 'required',
|
|
809
|
+
prompt: 'Write a SQL query to get all users older than 25.',
|
|
810
|
+
stopWhen: isStepCount(3),
|
|
811
|
+
});
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
Custom tools also work with `streamText`:
|
|
815
|
+
|
|
816
|
+
```ts
|
|
817
|
+
import { azure } from '@ai-sdk/azure';
|
|
818
|
+
import { streamText } from 'ai';
|
|
819
|
+
|
|
820
|
+
const result = streamText({
|
|
821
|
+
model: azure.responses('your-deployment-name'),
|
|
822
|
+
tools: {
|
|
823
|
+
write_sql: azure.tools.customTool({
|
|
824
|
+
description: 'Write a SQL SELECT query to answer the user question.',
|
|
825
|
+
format: {
|
|
826
|
+
type: 'grammar',
|
|
827
|
+
syntax: 'regex',
|
|
828
|
+
definition: 'SELECT .+',
|
|
829
|
+
},
|
|
830
|
+
}),
|
|
831
|
+
},
|
|
832
|
+
toolChoice: 'required',
|
|
833
|
+
prompt: 'Write a SQL query to get all users older than 25.',
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
for await (const chunk of result.stream) {
|
|
837
|
+
if (chunk.type === 'tool-call') {
|
|
838
|
+
console.log(`Tool: ${chunk.toolName}`);
|
|
839
|
+
console.log(`Input: ${chunk.input}`);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
The key in the `tools` object (`write_sql` above) names the tool.
|
|
845
|
+
The custom tool can be configured with:
|
|
846
|
+
|
|
847
|
+
- **description** _string_ (optional) - A description of what the tool does, to help the model understand when to use it.
|
|
848
|
+
- **format** _object_ (optional) - The output format constraint. Omit for unconstrained text output.
|
|
849
|
+
- **type** _'grammar' | 'text'_ - The format type. Use `'grammar'` for constrained output or `'text'` for explicit unconstrained text.
|
|
850
|
+
- **syntax** _'regex' | 'lark'_ - (grammar only) The grammar syntax. Use `'regex'` for regular expression patterns or `'lark'` for [Lark parser grammar](https://lark-parser.readthedocs.io/).
|
|
851
|
+
- **definition** _string_ - (grammar only) The grammar definition string (a regex pattern or Lark grammar).
|
|
852
|
+
- **execute** _function_ (optional) - An async function that receives the raw string input and returns the tool result. Enables multi-turn tool calling.
|
|
853
|
+
|
|
854
|
+
#### Apply Patch Tool
|
|
855
|
+
|
|
856
|
+
Use `azure.tools.applyPatch` to configure the OpenAI apply patch tool for Azure Responses models.
|
|
857
|
+
Availability depends on your model deployment, region, and API version; see the
|
|
858
|
+
[Azure Responses API documentation](https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/responses).
|
|
859
|
+
The apply patch tool lets the model create, update, and delete files in your codebase using structured diffs.
|
|
860
|
+
Instead of just suggesting edits, the model emits patch operations that your application applies and reports back on,
|
|
861
|
+
enabling iterative, multi-step code editing workflows.
|
|
862
|
+
|
|
863
|
+
Register this tool with the `apply_patch` key so patch results are returned in the
|
|
864
|
+
format expected by the Responses API.
|
|
865
|
+
|
|
866
|
+
```ts
|
|
867
|
+
import { azure } from '@ai-sdk/azure';
|
|
868
|
+
import { generateText, isStepCount } from 'ai';
|
|
869
|
+
|
|
870
|
+
const result = await generateText({
|
|
871
|
+
// Use your Azure deployment name with apply-patch support.
|
|
872
|
+
model: azure.responses('your-deployment-name'),
|
|
873
|
+
tools: {
|
|
874
|
+
apply_patch: azure.tools.applyPatch({
|
|
875
|
+
execute: async ({ callId, operation }) => {
|
|
876
|
+
// ... your implementation for applying the diffs.
|
|
877
|
+
return { status: 'completed' };
|
|
878
|
+
},
|
|
879
|
+
}),
|
|
880
|
+
},
|
|
881
|
+
prompt: 'Create a python file that calculates the factorial of a number',
|
|
882
|
+
stopWhen: isStepCount(5),
|
|
883
|
+
});
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
Your execute function must return:
|
|
887
|
+
|
|
888
|
+
- **status** _'completed' | 'failed'_ - Whether the patch was applied successfully
|
|
889
|
+
- **output** _string_ (optional) - Human-readable log text (e.g., results or error messages)
|
|
890
|
+
|
|
891
|
+
#### Shell Tool
|
|
892
|
+
|
|
893
|
+
Configure the shell tool for Azure Responses models with `azure.tools.shell`.
|
|
894
|
+
Availability of shell execution, hosted containers, container references, and skills
|
|
895
|
+
depends on your model deployment, region, and API version. See the
|
|
896
|
+
[Azure Responses API documentation](https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/responses).
|
|
897
|
+
The shell tool allows running bash commands and interacting with a command line.
|
|
898
|
+
The model proposes shell commands; your application executes them in local mode,
|
|
899
|
+
while the Azure OpenAI service executes them in hosted mode.
|
|
900
|
+
|
|
901
|
+
<Note type="warning">
|
|
902
|
+
Running arbitrary shell commands can be dangerous. Always sandbox execution or
|
|
903
|
+
add strict allow-/deny-lists before forwarding a command to the system shell.
|
|
904
|
+
</Note>
|
|
905
|
+
|
|
906
|
+
The shell tool supports three environment modes that control where commands are executed:
|
|
907
|
+
|
|
908
|
+
##### Local Execution (default)
|
|
909
|
+
|
|
910
|
+
When no `environment` is specified (or `type: 'local'` is used), commands are executed locally via your `execute` callback.
|
|
911
|
+
Connect it to your sandbox; the placeholder below returns a failed result without executing commands:
|
|
912
|
+
|
|
913
|
+
```ts
|
|
914
|
+
import { azure } from '@ai-sdk/azure';
|
|
915
|
+
import { generateText, isStepCount } from 'ai';
|
|
916
|
+
|
|
917
|
+
const result = await generateText({
|
|
918
|
+
model: azure.responses('your-deployment-name'),
|
|
919
|
+
tools: {
|
|
920
|
+
shell: azure.tools.shell({
|
|
921
|
+
execute: async ({ action }) => {
|
|
922
|
+
// Replace this placeholder with your sandbox integration.
|
|
923
|
+
return {
|
|
924
|
+
output: action.commands.map(() => ({
|
|
925
|
+
stdout: '',
|
|
926
|
+
stderr: 'No sandbox executor configured.',
|
|
927
|
+
outcome: { type: 'exit' as const, exitCode: 1 },
|
|
928
|
+
})),
|
|
929
|
+
};
|
|
930
|
+
},
|
|
931
|
+
}),
|
|
932
|
+
},
|
|
933
|
+
prompt: 'List the files in the current directory and show disk usage.',
|
|
934
|
+
stopWhen: isStepCount(5),
|
|
935
|
+
});
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
##### Hosted Container (auto)
|
|
939
|
+
|
|
940
|
+
Set `environment.type` to `'containerAuto'` to run commands in a container hosted by the Azure OpenAI service. No `execute` callback is needed — Azure OpenAI handles execution server-side:
|
|
941
|
+
|
|
942
|
+
<Note type="warning">
|
|
943
|
+
The Azure OpenAI Responses API shell tool currently does not support
|
|
944
|
+
`networkPolicy`. The shared factory accepts and forwards this option, so check
|
|
945
|
+
your deployment's service support before using it.
|
|
946
|
+
</Note>
|
|
947
|
+
|
|
948
|
+
```ts
|
|
949
|
+
import { azure } from '@ai-sdk/azure';
|
|
950
|
+
import { generateText } from 'ai';
|
|
951
|
+
|
|
952
|
+
const result = await generateText({
|
|
953
|
+
model: azure.responses('your-deployment-name'),
|
|
954
|
+
tools: {
|
|
955
|
+
shell: azure.tools.shell({
|
|
956
|
+
environment: {
|
|
957
|
+
type: 'containerAuto',
|
|
958
|
+
// optional configuration:
|
|
959
|
+
memoryLimit: '4g',
|
|
960
|
+
fileIds: ['assistant-abc123'],
|
|
961
|
+
},
|
|
962
|
+
}),
|
|
963
|
+
},
|
|
964
|
+
prompt: 'Install numpy and compute the eigenvalues of a 3x3 matrix.',
|
|
965
|
+
});
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
The `containerAuto` environment supports:
|
|
969
|
+
|
|
970
|
+
- **fileIds** _string[]_ - File IDs to make available in the container
|
|
971
|
+
- **memoryLimit** _'1g' | '4g' | '16g' | '64g'_ - Memory limit for the container
|
|
972
|
+
|
|
973
|
+
##### Existing Container Reference
|
|
974
|
+
|
|
975
|
+
Set `environment.type` to `'containerReference'` to use an existing container by ID:
|
|
976
|
+
|
|
977
|
+
```ts
|
|
978
|
+
import { azure } from '@ai-sdk/azure';
|
|
979
|
+
import { generateText } from 'ai';
|
|
980
|
+
|
|
981
|
+
const result = await generateText({
|
|
982
|
+
model: azure.responses('your-deployment-name'),
|
|
983
|
+
tools: {
|
|
984
|
+
shell: azure.tools.shell({
|
|
985
|
+
environment: {
|
|
986
|
+
type: 'containerReference',
|
|
987
|
+
containerId: 'cntr_abc123',
|
|
988
|
+
},
|
|
989
|
+
}),
|
|
990
|
+
},
|
|
991
|
+
prompt: 'Check the status of running processes.',
|
|
992
|
+
});
|
|
993
|
+
```
|
|
994
|
+
|
|
995
|
+
##### Execute Callback
|
|
996
|
+
|
|
997
|
+
For local execution (default or `type: 'local'`), your execute function must return an output array with results for each command:
|
|
998
|
+
|
|
999
|
+
- **stdout** _string_ - Standard output from the command
|
|
1000
|
+
- **stderr** _string_ - Standard error from the command
|
|
1001
|
+
- **outcome** - Either `{ type: 'timeout' }` or `{ type: 'exit', exitCode: number }`
|
|
1002
|
+
|
|
1003
|
+
##### Skills
|
|
1004
|
+
|
|
1005
|
+
[Skills](https://platform.openai.com/docs/guides/tools-skills) are versioned bundles of files with a `SKILL.md` manifest that extend the shell tool's capabilities. They can be attached to both `containerAuto` and `local` environments.
|
|
1006
|
+
|
|
1007
|
+
<Note type="warning">
|
|
1008
|
+
Azure skill-ID resolution is not implemented by the shared shell adapter. Use
|
|
1009
|
+
local skill directories or inline archives instead of OpenAI platform skill
|
|
1010
|
+
references.
|
|
1011
|
+
</Note>
|
|
1012
|
+
|
|
1013
|
+
**Local skills** point to a directory on disk containing a `SKILL.md` file:
|
|
1014
|
+
|
|
1015
|
+
```ts
|
|
1016
|
+
import { azure } from '@ai-sdk/azure';
|
|
1017
|
+
import { generateText, isStepCount } from 'ai';
|
|
1018
|
+
import { resolve } from 'node:path';
|
|
1019
|
+
|
|
1020
|
+
const result = await generateText({
|
|
1021
|
+
model: azure.responses('your-deployment-name'),
|
|
1022
|
+
tools: {
|
|
1023
|
+
shell: azure.tools.shell({
|
|
1024
|
+
execute: async ({ action }) => {
|
|
1025
|
+
// Replace this placeholder with your sandbox integration.
|
|
1026
|
+
return {
|
|
1027
|
+
output: action.commands.map(() => ({
|
|
1028
|
+
stdout: '',
|
|
1029
|
+
stderr: 'No sandbox executor configured.',
|
|
1030
|
+
outcome: { type: 'exit' as const, exitCode: 1 },
|
|
1031
|
+
})),
|
|
1032
|
+
};
|
|
1033
|
+
},
|
|
1034
|
+
environment: {
|
|
1035
|
+
type: 'local',
|
|
1036
|
+
skills: [
|
|
1037
|
+
{
|
|
1038
|
+
name: 'my-skill',
|
|
1039
|
+
description: 'What this skill does',
|
|
1040
|
+
path: resolve('path/to/skill-directory'),
|
|
1041
|
+
},
|
|
1042
|
+
],
|
|
1043
|
+
},
|
|
1044
|
+
}),
|
|
1045
|
+
},
|
|
1046
|
+
prompt: 'Use the skill to solve this problem.',
|
|
1047
|
+
stopWhen: isStepCount(5),
|
|
1048
|
+
});
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
**Inline container skills** provide a ZIP archive containing the skill's `SKILL.md`
|
|
1052
|
+
and supporting files. For a deployment that supports hosted shell skills:
|
|
1053
|
+
|
|
1054
|
+
```ts
|
|
1055
|
+
import { azure } from '@ai-sdk/azure';
|
|
1056
|
+
import { generateText } from 'ai';
|
|
1057
|
+
import { readFileSync } from 'node:fs';
|
|
1058
|
+
|
|
1059
|
+
const result = await generateText({
|
|
1060
|
+
model: azure.responses('your-deployment-name'),
|
|
1061
|
+
tools: {
|
|
1062
|
+
shell: azure.tools.shell({
|
|
1063
|
+
environment: {
|
|
1064
|
+
type: 'containerAuto',
|
|
1065
|
+
skills: [
|
|
1066
|
+
{
|
|
1067
|
+
type: 'inline',
|
|
1068
|
+
name: 'my-skill',
|
|
1069
|
+
description: 'What this skill does',
|
|
1070
|
+
source: {
|
|
1071
|
+
type: 'base64',
|
|
1072
|
+
mediaType: 'application/zip',
|
|
1073
|
+
data: readFileSync('my-skill.zip').toString('base64'),
|
|
1074
|
+
},
|
|
1075
|
+
},
|
|
1076
|
+
],
|
|
1077
|
+
},
|
|
1078
|
+
}),
|
|
1079
|
+
},
|
|
1080
|
+
prompt: 'Use the skill to solve this problem.',
|
|
1081
|
+
});
|
|
1082
|
+
```
|
|
1083
|
+
|
|
757
1084
|
#### Tool Search Tool
|
|
758
1085
|
|
|
759
1086
|
The Azure OpenAI provider supports [tool search](https://learn.microsoft.com/en-us/azure/foundry/openai/how-to/tool-search) through the `azure.tools.toolSearch` tool.
|
|
@@ -1198,12 +1525,21 @@ console.log(image);
|
|
|
1198
1525
|
|
|
1199
1526
|
### Model Capabilities
|
|
1200
1527
|
|
|
1201
|
-
|
|
1528
|
+
The table lists supported DALL-E backing models and Azure MAI image IDs. For OpenAI-backed deployments, the supported sizes depend on the model version behind your deployment.
|
|
1529
|
+
|
|
1530
|
+
{/* model-capabilities:azure-image:start */}
|
|
1531
|
+
|
|
1532
|
+
| Model | Sizes |
|
|
1533
|
+
| --------------------- | ------------------------------------------------------ |
|
|
1534
|
+
| `dall-e-3` | 1024x1024, 1792x1024, 1024x1792 |
|
|
1535
|
+
| `dall-e-2` | 256x256, 512x512, 1024x1024 |
|
|
1536
|
+
| `mai-image-2.5` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1537
|
+
| `mai-image-2.5-flash` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1538
|
+
| `mai-image-2.5-pro` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1539
|
+
| `mai-image-2.6` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1540
|
+
| `mai-image-2.6-flash` | Sides must be multiples of 16 and at least 768 pixels. |
|
|
1202
1541
|
|
|
1203
|
-
|
|
1204
|
-
| ------------- | ------------------------------- |
|
|
1205
|
-
| DALL-E 3 | 1024x1024, 1792x1024, 1024x1792 |
|
|
1206
|
-
| DALL-E 2 | 256x256, 512x512, 1024x1024 |
|
|
1542
|
+
{/* model-capabilities:azure-image:end */}
|
|
1207
1543
|
|
|
1208
1544
|
Azure deployment names are user-defined and do not identify the backing model.
|
|
1209
1545
|
Consequently, `supportsFileInputs` and `supportsMaskInputs` are `undefined`
|
|
@@ -1387,6 +1723,15 @@ Options that a model does not support, such as `timestamps: 'word'` with
|
|
|
1387
1723
|
MAI-Transcribe-1.5, are sent unchanged, and Azure rejects the request with an
|
|
1388
1724
|
error that names the option.
|
|
1389
1725
|
|
|
1726
|
+
For Azure Speech, the shared `timestampGranularities: ['word', 'segment']`
|
|
1727
|
+
setting requests word timestamps, which also include phrase timing.
|
|
1728
|
+
`providerOptions.azure.timestamps` takes precedence. Requests for timings that
|
|
1729
|
+
are disabled by that override or unsupported by the model produce a warning.
|
|
1730
|
+
MAI-Transcribe-2 exposes normalized word timing in `result.words` and phrase
|
|
1731
|
+
timing in `result.segments`, both in seconds. MAI-Transcribe-1.5 does not support
|
|
1732
|
+
timestamp requests. Azure OpenAI models use the OpenAI timing settings and
|
|
1733
|
+
precedence instead.
|
|
1734
|
+
|
|
1390
1735
|
Results include transcript text, timed segments, duration, and an ISO-639-1
|
|
1391
1736
|
language code when the reported phrase locales identify one language. Mixed-language
|
|
1392
1737
|
results, and languages without an ISO-639-1 code such as Filipino (`fil`) or
|
|
@@ -1526,14 +1871,18 @@ The following provider options are available:
|
|
|
1526
1871
|
|
|
1527
1872
|
### Model Capabilities
|
|
1528
1873
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
|
1532
|
-
|
|
|
1533
|
-
| `
|
|
1534
|
-
| `
|
|
1535
|
-
| `
|
|
1536
|
-
| `mai-transcribe-2
|
|
1874
|
+
{/* model-capabilities:azure-transcription:start */}
|
|
1875
|
+
|
|
1876
|
+
| Model | Transcription | Streaming | Duration | Segments | Language |
|
|
1877
|
+
| ---------------------------- | ------------- | --------- | ------------------------------------------------------------- | --------- | -------------------------------------------------- |
|
|
1878
|
+
| `whisper-1` | <Check /> | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
1879
|
+
| `gpt-4o-mini-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
|
|
1880
|
+
| `gpt-4o-transcribe` | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
|
|
1881
|
+
| `mai-transcribe-2` | <Check /> | <Cross /> | <Check /> | <Check /> | <Check /> |
|
|
1882
|
+
| `mai-transcribe-1.5` | <Check /> | <Cross /> | <Check /> | <Cross /> | <Check /> |
|
|
1883
|
+
| `mai-transcribe-2-streaming` | <Cross /> | <Check /> | Conditional: Requires an audio format with a known byte rate. | <Cross /> | Conditional: Reports the configured language hint. |
|
|
1884
|
+
|
|
1885
|
+
{/* model-capabilities:azure-transcription:end */}
|
|
1537
1886
|
|
|
1538
1887
|
## Speech Models
|
|
1539
1888
|
|
|
@@ -1592,13 +1941,21 @@ The following provider options are available:
|
|
|
1592
1941
|
|
|
1593
1942
|
### Model Capabilities
|
|
1594
1943
|
|
|
1595
|
-
|
|
1944
|
+
The table lists OpenAI TTS backing models and Azure MAI voice IDs. For OpenAI-backed deployments, instruction support depends on the model version behind your deployment.
|
|
1945
|
+
|
|
1946
|
+
{/* model-capabilities:azure-speech:start */}
|
|
1596
1947
|
|
|
1597
|
-
| Model
|
|
1598
|
-
|
|
|
1599
|
-
| `tts-1`
|
|
1600
|
-
| `tts-1-hd`
|
|
1601
|
-
| `gpt-4o-mini-tts`
|
|
1948
|
+
| Model | Instructions |
|
|
1949
|
+
| --------------------- | ------------ |
|
|
1950
|
+
| `tts-1` | <Cross /> |
|
|
1951
|
+
| `tts-1-hd` | <Cross /> |
|
|
1952
|
+
| `gpt-4o-mini-tts` | <Check /> |
|
|
1953
|
+
| `mai-voice-2.1-flash` | <Cross /> |
|
|
1954
|
+
| `mai-voice-2.1` | <Cross /> |
|
|
1955
|
+
| `mai-voice-2-flash` | <Cross /> |
|
|
1956
|
+
| `mai-voice-2` | <Cross /> |
|
|
1957
|
+
|
|
1958
|
+
{/* model-capabilities:azure-speech:end */}
|
|
1602
1959
|
|
|
1603
1960
|
### MAI-Voice
|
|
1604
1961
|
|
|
@@ -1673,3 +2030,27 @@ The following options are available through `providerOptions.azure`:
|
|
|
1673
2030
|
|
|
1674
2031
|
Text is always spoken as plain text; SSML input is not supported.
|
|
1675
2032
|
The models are in public preview. AI Gateway forwards these provider options, including `azure.api`.
|
|
2033
|
+
|
|
2034
|
+
## Provider Option Reference
|
|
2035
|
+
|
|
2036
|
+
The following option definitions are generated from the provider catalog.
|
|
2037
|
+
|
|
2038
|
+
{/* model-capabilities:azure-provider-options:start */}
|
|
2039
|
+
|
|
2040
|
+
| Operation | Option | Description |
|
|
2041
|
+
| ------------- | ----------------- | ----------------------------------------------- |
|
|
2042
|
+
| image | `api` | Select the OpenAI or MAI image API. |
|
|
2043
|
+
| image | `autoAspectRatio` | Choose the aspect ratio automatically. |
|
|
2044
|
+
| image | `webGrounding` | Ground image generation in web search. |
|
|
2045
|
+
| speech | `api` | Select the OpenAI or Azure Speech API. |
|
|
2046
|
+
| speech | `style` | Speaking style supported by the selected voice. |
|
|
2047
|
+
| speech | `styleDegree` | Intensity of the speaking style. |
|
|
2048
|
+
| transcription | `api` | Select the OpenAI, Azure Speech, or MAI API. |
|
|
2049
|
+
| transcription | `language` | Language hint for MAI streaming transcription. |
|
|
2050
|
+
| transcription | `timestamps` | Word, segment, or no timestamps. |
|
|
2051
|
+
| transcription | `transcribeStyle` | Verbatim or cleaned transcription. |
|
|
2052
|
+
| transcription | `locales` | Language to use for transcription. |
|
|
2053
|
+
| transcription | `diarization` | Enable speaker diarization. |
|
|
2054
|
+
| transcription | `phraseList` | Phrases to bias transcription toward. |
|
|
2055
|
+
|
|
2056
|
+
{/* model-capabilities:azure-provider-options:end */}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/azure",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.118",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/deepseek": "3.0.
|
|
33
|
-
"@ai-sdk/openai": "4.0.
|
|
34
|
-
"@ai-sdk/provider": "4.0.
|
|
35
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
32
|
+
"@ai-sdk/deepseek": "3.0.80",
|
|
33
|
+
"@ai-sdk/openai": "4.0.110",
|
|
34
|
+
"@ai-sdk/provider": "4.0.36",
|
|
35
|
+
"@ai-sdk/provider-utils": "5.0.75"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@ai-sdk/test-server": "2.0.4",
|
|
39
39
|
"@types/node": "22.19.19",
|
|
40
40
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
41
41
|
"@vercel/ai-tsdown-config": "0.0.0",
|
|
42
|
-
"ai": "7.0.
|
|
42
|
+
"ai": "7.0.164",
|
|
43
43
|
"tsdown": "^0.23.0",
|
|
44
44
|
"typescript": "6.0.3",
|
|
45
45
|
"zod": "3.25.76"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { openaiModelCatalog } from '@ai-sdk/openai/internal';
|
|
2
|
+
import { azureModelCatalog } from './azure-model-catalog';
|
|
3
|
+
export { azureProviderOptions } from './azure-model-catalog';
|
|
4
|
+
|
|
5
|
+
/** Backing-model metadata for documented Azure OpenAI deployments and MAI IDs.
|
|
6
|
+
* Deployment names remain opaque at runtime; OpenAI adapters own their policies. */
|
|
7
|
+
export const azureDeploymentModelCatalog = {
|
|
8
|
+
...Object.fromEntries(
|
|
9
|
+
[
|
|
10
|
+
'dall-e-3',
|
|
11
|
+
'dall-e-2',
|
|
12
|
+
'tts-1',
|
|
13
|
+
'tts-1-hd',
|
|
14
|
+
'gpt-4o-mini-tts',
|
|
15
|
+
'whisper-1',
|
|
16
|
+
'gpt-4o-mini-transcribe',
|
|
17
|
+
'gpt-4o-transcribe',
|
|
18
|
+
].map(id => [id, openaiModelCatalog[id]]),
|
|
19
|
+
),
|
|
20
|
+
...azureModelCatalog,
|
|
21
|
+
};
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type InferSchema,
|
|
5
5
|
} from '@ai-sdk/provider-utils';
|
|
6
6
|
import { z } from 'zod/v4';
|
|
7
|
+
import { getAzureModelEntry } from './azure-model-catalog';
|
|
7
8
|
import { azureMaiImageModelOptionsShape } from './azure-mai-image-model-options';
|
|
8
9
|
|
|
9
10
|
export const azureImageModelOptions = lazySchema(() =>
|
|
@@ -20,15 +21,6 @@ export const azureImageModelOptions = lazySchema(() =>
|
|
|
20
21
|
|
|
21
22
|
export type AzureImageModelOptions = InferSchema<typeof azureImageModelOptions>;
|
|
22
23
|
|
|
23
|
-
// Lowercase model IDs served by the MAI image API.
|
|
24
|
-
const maiImageModels = new Set([
|
|
25
|
-
'mai-image-2.5',
|
|
26
|
-
'mai-image-2.5-flash',
|
|
27
|
-
'mai-image-2.5-pro',
|
|
28
|
-
'mai-image-2.6',
|
|
29
|
-
'mai-image-2.6-flash',
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
24
|
export function isMAIImageModel(modelId: string) {
|
|
33
|
-
return
|
|
25
|
+
return getAzureModelEntry(modelId)?.requestConfig?.image?.api === 'mai';
|
|
34
26
|
}
|