-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat(provider/azure) : enable codeInterpreter and fileSearch for AzureOpenAI #8238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gr2m
merged 41 commits into
vercel:main
from
tsuzaki430:tsuz/azure-responsesapi-code-interpreter
Sep 26, 2025
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ef7b112
enabled built-in tools code_interpreter,file_search on Azure Response…
tsuzaki430 1f06809
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 9392e37
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 d248f7d
make changeset
tsuzaki430 3a54d82
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 99e1a07
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 d722639
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 558a887
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 d269ed4
document add file_search code_interpreter
tsuzaki430 40e43e2
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 69843d1
add test
tsuzaki430 78bbedd
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 06f0659
prettier-fix
tsuzaki430 bd8394a
Update packages/azure/src/azure-openai-provider.test.ts
tsuzaki430 e33c099
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 dfde373
fix changeset error
tsuzaki430 6473058
fix changeset 2
tsuzaki430 e3ac311
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 06e46d2
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 a197d9b
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 8722bf4
add example for file search
tsuzaki430 17ff6c0
add example for code interpreter
tsuzaki430 0071e4b
add example for openai code interpreter
tsuzaki430 76a5ec3
Merge branch 'tsuz/azure-responsesapi-code-interpreter' of https://gi…
tsuzaki430 6aeaee1
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 3756af2
prettier-fix
tsuzaki430 71db155
add example for file search to compare openai vs azure
tsuzaki430 cad907a
add filesearch example for streamText
tsuzaki430 264de2d
small fix
tsuzaki430 c857ab9
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 de2118e
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 eac571c
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 cc03a32
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 ee7b359
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 a8a851b
Merge branch 'vercel:main' into tsuz/azure-responsesapi-code-interpreter
tsuzaki430 b1dd6d0
Merge remote-tracking branch 'upstream/main' into tsuz/azure-response…
tsuzaki430 f4b787e
merge
tsuzaki430 051a171
fix type error
tsuzaki430 5f40e14
add test azure file search in ai-core
tsuzaki430 ebff7ee
prettier-fix
tsuzaki430 f7ac746
Merge branch 'main' into tsuz/azure-responsesapi-code-interpreter
gr2m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@ai-sdk/openai': patch | ||
| '@ai-sdk/azure': patch | ||
| --- | ||
|
|
||
| enables code_interpreter and file_search capabilities in the Azure provider through the Responses API |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
examples/ai-core/src/generate-text/azure-responses-code-interpreter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { azure } from '@ai-sdk/azure'; | ||
| import { generateText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| /** | ||
| * prepare | ||
| * Please add parameters in your .env file for initialize Azure OpenAI.. | ||
| * AZURE_RESOURCE_NAME="<your_resource_name>" | ||
| * AZURE_API_KEY="<your_api_key>" | ||
| */ | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const basicResult = await generateText({ | ||
| model: azure.responses('gpt-5-mini'), | ||
| prompt: | ||
| 'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results.', | ||
| tools: { | ||
| code_interpreter: azure.tools.codeInterpreter({}), | ||
| }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| console.log(basicResult.text); | ||
| console.log('\n=== Other Outputs ==='); | ||
| console.log(basicResult.toolCalls); | ||
| console.log(basicResult.toolResults); | ||
| } | ||
|
|
||
| main().catch(console.error); | ||
44 changes: 44 additions & 0 deletions
44
examples/ai-core/src/generate-text/azure-responses-file-search.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import { azure } from '@ai-sdk/azure'; | ||
| import { generateText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| /** | ||
| * prepare 1 | ||
| * Please add parameters in your .env file for initialize Azure OpenAI. | ||
| * AZURE_RESOURCE_NAME="<your_resource_name>" | ||
| * AZURE_API_KEY="<your_api_key>" | ||
| * | ||
| * prepare 2 | ||
| * Please create vector store and put file in your vector. | ||
| * URL:AOAI vector store portal | ||
| * https://oai.azure.com/resource/vectorstore | ||
| */ | ||
|
|
||
| const VectorStoreId = 'vs_xxxxxxxxxxxxxxxxxxxxxxxx'; // put your vector store id. | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const basicResult = await generateText({ | ||
| model: azure.responses('gpt-4.1-mini'), | ||
| prompt: 'What is quantum computing?', // please question about your documents. | ||
| tools: { | ||
| file_search: azure.tools.fileSearch({ | ||
| // optional configuration: | ||
| vectorStoreIds: [VectorStoreId], | ||
| maxNumResults: 10, | ||
| ranking: { | ||
| ranker: 'auto', | ||
| }, | ||
| }), | ||
| }, | ||
| // Force file search tool: | ||
| toolChoice: { type: 'tool', toolName: 'file_search' }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| console.log(basicResult.text); | ||
| console.log(basicResult.toolCalls); | ||
| console.log(basicResult.toolResults); | ||
| } | ||
|
|
||
| main().catch(console.error); |
23 changes: 23 additions & 0 deletions
23
examples/ai-core/src/generate-text/openai-responses-code-interpreter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { openai } from '@ai-sdk/openai'; | ||
| import { generateText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const basicResult = await generateText({ | ||
| model: openai.responses('gpt-4.1-mini'), | ||
| prompt: | ||
| 'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results.', | ||
| tools: { | ||
| code_interpreter: openai.tools.codeInterpreter({}), | ||
| }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| console.log(basicResult.text); | ||
| console.log('\n=== Other Outputs ==='); | ||
| console.log(basicResult.toolCalls); | ||
| console.log(basicResult.toolResults); | ||
| } | ||
|
|
||
| main().catch(console.error); |
39 changes: 39 additions & 0 deletions
39
examples/ai-core/src/generate-text/openai-responses-file-search.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { openai } from '@ai-sdk/openai'; | ||
| import { generateText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| /** | ||
| * prepare | ||
| * Please create vector store and put file in your vector. | ||
| * URL:openai vector store dashboard | ||
| * https://platform.openai.com/storage/vector_stores/ | ||
| */ | ||
|
|
||
| const VectorStoreId = 'vs_xxxxxxxxxxxxxxxxxxxxxxxx'; // put your vector store id. | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const basicResult = await generateText({ | ||
| model: openai.responses('gpt-4.1-mini'), | ||
| prompt: 'What is quantum computing?', // please question about your documents. | ||
| tools: { | ||
| file_search: openai.tools.fileSearch({ | ||
| // optional configuration: | ||
| vectorStoreIds: [VectorStoreId], | ||
| maxNumResults: 10, | ||
| ranking: { | ||
| ranker: 'auto', | ||
| }, | ||
| }), | ||
| }, | ||
| // Force file search tool: | ||
| toolChoice: { type: 'tool', toolName: 'file_search' }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| console.log(basicResult.text); | ||
| console.dir(basicResult.toolCalls, { depth: null }); | ||
| console.dir(basicResult.toolResults, { depth: null }); | ||
| } | ||
|
|
||
| main().catch(console.error); |
32 changes: 32 additions & 0 deletions
32
examples/ai-core/src/stream-text/azure-responses-code-interpreter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { azure } from '@ai-sdk/azure'; | ||
| import { streamText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| /** | ||
| * prepare | ||
| * Please add parameters in your .env file for initialize Azure OpenAI.. | ||
| * AZURE_RESOURCE_NAME="<your_resource_name>" | ||
| * AZURE_API_KEY="<your_api_key>" | ||
| */ | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const result = streamText({ | ||
| model: azure.responses('gpt-5-mini'), | ||
| prompt: | ||
| 'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results.', | ||
| tools: { | ||
| code_interpreter: azure.tools.codeInterpreter({}), | ||
| }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| for await (const textPart of result.textStream) { | ||
| process.stdout.write(textPart); | ||
| } | ||
| console.log('\n=== Other Outputs ==='); | ||
| console.log(await result.toolCalls); | ||
| console.log(await result.toolResults); | ||
| } | ||
|
|
||
| main().catch(console.error); |
48 changes: 48 additions & 0 deletions
48
examples/ai-core/src/stream-text/azure-responses-file-search.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { azure } from '@ai-sdk/azure'; | ||
| import { streamText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| /** | ||
| * prepare 1 | ||
| * Please add parameters in your .env file for initialize Azure OpenAI. | ||
| * AZURE_RESOURCE_NAME="<your_resource_name>" | ||
| * AZURE_API_KEY="<your_api_key>" | ||
| * | ||
| * prepare 2 | ||
| * Please create vector store and put file in your vector. | ||
| * URL:AOAI vector store portal | ||
| * https://oai.azure.com/resource/vectorstore | ||
| */ | ||
|
|
||
| const VectorStoreId = 'vs_xxxxxxxxxxxxxxxxxxxxxxxx'; // put your vector store id. | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const result = await streamText({ | ||
| model: azure.responses('gpt-4.1-mini'), | ||
| prompt: 'What is quantum computing?', // please question about your documents. | ||
| tools: { | ||
| file_search: azure.tools.fileSearch({ | ||
| // optional configuration: | ||
| vectorStoreIds: [VectorStoreId], | ||
| maxNumResults: 10, | ||
| ranking: { | ||
| ranker: 'auto', | ||
| }, | ||
| }), | ||
| }, | ||
| // Force file search tool: | ||
| toolChoice: { type: 'tool', toolName: 'file_search' }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| for await (const textPart of result.textStream) { | ||
| process.stdout.write(textPart); | ||
| } | ||
| console.log('\n=== Other Outputs ==='); | ||
| console.dir(await result.toolCalls, { depth: Infinity }); | ||
| console.dir(await result.toolResults, { depth: Infinity }); | ||
| console.dir(await result.sources, { depth: Infinity }); | ||
| } | ||
|
|
||
| main().catch(console.error); |
25 changes: 25 additions & 0 deletions
25
examples/ai-core/src/stream-text/openai-responses-code-interpreter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { openai } from '@ai-sdk/openai'; | ||
| import { streamText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const result = streamText({ | ||
| model: openai.responses('gpt-4.1-mini'), | ||
| prompt: | ||
| 'Create a program that generates five random numbers between 1 and 100 with two decimal places, and show me the execution results.', | ||
| tools: { | ||
| code_interpreter: openai.tools.codeInterpreter({}), | ||
| }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| for await (const textPart of result.textStream) { | ||
| process.stdout.write(textPart); | ||
| } | ||
| console.log('\n=== Other Outputs ==='); | ||
| console.log(await result.toolCalls); | ||
| console.log(await result.toolResults); | ||
| } | ||
|
|
||
| main().catch(console.error); |
42 changes: 42 additions & 0 deletions
42
examples/ai-core/src/stream-text/openai-responses-file-search.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { openai } from '@ai-sdk/openai'; | ||
| import { streamText } from 'ai'; | ||
| import 'dotenv/config'; | ||
|
|
||
| /** | ||
| * prepare | ||
| * Please create vector store and put file in your vector. | ||
| * URL:openai vector store dashboard | ||
| * https://platform.openai.com/storage/vector_stores/ | ||
| */ | ||
|
|
||
| const VectorStoreId = 'vs_xxxxxxxxxxxxxxxxxxxxxxxx'; // put your vector store id. | ||
|
|
||
| async function main() { | ||
| // Basic text generation | ||
| const result = await streamText({ | ||
| model: openai.responses('gpt-4.1-mini'), | ||
| prompt: 'What is quantum computing?', // please question about your documents. | ||
| tools: { | ||
| file_search: openai.tools.fileSearch({ | ||
| // optional configuration: | ||
| vectorStoreIds: [VectorStoreId], | ||
| maxNumResults: 10, | ||
| ranking: { | ||
| ranker: 'auto', | ||
| }, | ||
| }), | ||
| }, | ||
| // Force file search tool: | ||
| toolChoice: { type: 'tool', toolName: 'file_search' }, | ||
| }); | ||
|
|
||
| console.log('\n=== Basic Text Generation ==='); | ||
| for await (const textPart of result.textStream) { | ||
| process.stdout.write(textPart); | ||
| } | ||
| console.log('\n=== Other Outputs ==='); | ||
| console.dir(await result.toolCalls, { depth: null }); | ||
| console.dir(await result.toolResults, { depth: null }); | ||
| } | ||
|
|
||
| main().catch(console.error); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.