Skip to content

Comments

feat (provider/azure): add OpenAI responses API support#5461

Merged
lgrammel merged 9 commits intovercel:mainfrom
AVtheking:feat/azure-responses-api
Apr 6, 2025
Merged

feat (provider/azure): add OpenAI responses API support#5461
lgrammel merged 9 commits intovercel:mainfrom
AVtheking:feat/azure-responses-api

Conversation

@AVtheking
Copy link
Contributor

Fixes #5346 & #5454

@lgrammel
Copy link
Collaborator

@AVtheking have you tested this end-to-end with an Azure setup?

@AVtheking
Copy link
Contributor Author

AVtheking commented Mar 31, 2025

no actually I don't have subscription at azure 😞 , Let me see If I can make some arrangements

@AVtheking
Copy link
Contributor Author

Hi @lgrammel I have tested now with azure setup and it is working fine , also added an example for the responses api. PTAL

@AVtheking
Copy link
Contributor Author

@lgrammel could you please take a look and let me know any changes required whenever you are free.

@AlexHird
Copy link

AlexHird commented Apr 4, 2025

How would this integrate with the tools provided within the responsesAPI (web search, computer-vision etc)?

@AVtheking
Copy link
Contributor Author

Yeah I want to discuss that thing (but don't know how and where I could discuss this with maintainers) , one way could be directly importing the tools from the open ai module to this

@AlexHird
Copy link

AlexHird commented Apr 5, 2025

@lgrammel Is this already in the works, or planned, by maintainers?

Personally, I would rather be able to use the openai provider directly by configuring it for AzureOpenAI. Similarly as I'd do it when using the the OpenAI package directly. IE:

import { AzureOpenAI } from "openai";

const deployment = "deployment name";
const apiVersion = "2024-10-21";
const client = new AzureOpenAI({ azureADTokenProvider, deployment, apiVersion });

When using Azure OpenAI Services, it would be fantastic to simply create the OpenAI provider with some additional configurations:

import { createAzureOpenAI } from '@ai-sdk/openai';

const deployment = "deployment name";
const apiVersion = "2024-10-21";

const openai = createAzureOpenAI({
  azureADTokenProvider,
  deployment,
  apiVersion
});

Perhaps that would be easier to work with in the long run?

@lgrammel lgrammel changed the title Responses Api in azure provider feat (provider/azure): add OpenAI responses API support Apr 5, 2025
@lgrammel
Copy link
Collaborator

lgrammel commented Apr 5, 2025

@AVtheking looks pretty good, docs would need updating. Can you add the responses api section from the openai provider docs page to the azure provider docs page (and tweak if necessary)?

@AVtheking
Copy link
Contributor Author

@lgrammel I have updated the doc , PTAL, thanks.

@lgrammel
Copy link
Collaborator

lgrammel commented Apr 6, 2025

Seeing test & type check errors.

@AVtheking
Copy link
Contributor Author

Fixed those

@lgrammel lgrammel merged commit e82024e into vercel:main Apr 6, 2025
6 of 7 checks passed
lgrammel added a commit that referenced this pull request Apr 6, 2025
Co-authored-by: ANKIT VARSHNEY <132201033+AVtheking@users.noreply.github.com>
@miguelvictor
Copy link
Contributor

Can you also add tests to streamText? For some reason, it doesn't work with streamText.

model: azure.responses('your-deployment-name'),
prompt: 'What happened in San Francisco last week?',
tools: {
web_search_preview: azure.tools.webSearchPreview({
Copy link

@matthiasmoke matthiasmoke Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided docs example will result in a null pointer, as the azure provider object does not export a tool property.

    const azure = createAzure({
      resourceName: AZURE_OAI_RESOURCE,
      apiKey: AZURE_OAI_KEY
    })
    const model = azure.responses('insert-deployment-here')
    const result = await generateText({
      model,
      prompt: input,
      tools: {
        web_search_preview: azure.tools.webSearchPreview({
        searchContextSize: 'high',
        userLocation: {
          type: 'approximate',
          city: 'San Francisco',
          region: 'California',
        },
        })
      }
    })

Results in: TypeError: Cannot read properties of undefined (reading 'webSearchPreview')

@AVtheking can you judge whether my usage example is correct? If yes, I suppose this is an issue with the provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes you are correct, it doesn't exports tool now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your response! Do you know any workaround to still enable such tools while using the azure provider?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would raise a PR for this to fix this, if I still has azure creds, or you can do it buddy, I can also help you

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

havent tested it yet, but I think its resolved 😄 #8238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support in @ai-sdk/azure for Responses API

6 participants