vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
10.06k stars 1.49k forks source link

Support azure authentication with managed identity #3124

Open MathiasGruber opened 1 month ago

MathiasGruber commented 1 month ago

Feature Description

Currently azure provider works with API keys, however, in our organization it is encouraged and enforced that we only use managed identity for auth against azure services (https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#authentication).

Implementing this type of auth would be a requirement for us to be able to use this library, would it be possible to add it?

Use Case

Corporate environments with strict guidelines on security protocols to be followed.

Additional context

i.e. currently we do something like this with the openai library:

export const client = new OpenAIClient(
  env.OPENAI_API_BASE_URL,
  new DefaultAzureCredential(),
);
ShervK commented 1 week ago

Mind if I take a crack at this, @lgrammel? We use Azure OpenAI and have managed identity already set up so I can use our existing infrastructure for testing.

ShervK commented 1 week ago

@lgrammel submitted a PR for this and waiting for review.