aisuite icon indicating copy to clipboard operation
aisuite copied to clipboard

Support keyless auth for Azure OpenAI (token provider)

Open pamelafox opened this issue 11 months ago • 2 comments

Many of our Azure developers do not use API keys, they use "keyless auth" which passes in a short-lived OAuth token, which can then be refreshed. The OpenAI package already supports that keyless auth, by accepting a token_provider callback, calling that at the appropriate times, and passing in a Bearer header with the resulting token. Would you consider adding bearer token auth for this wrapper? Or is this wrapper meant for hobbyist scenarios only?

pamelafox avatar Dec 02 '24 22:12 pamelafox

Here's an example of how I would use keyless auth with Azure with the openai package, by the way: https://github.com/pamelafox/python-openai-demos/blob/c7de0ec332cab9340ff1bf327efceebdec2f6364/chat.py#L16

client = openai.AzureOpenAI(
    api_version=os.getenv("AZURE_OPENAI_VERSION"),
    azure_endpoint=os.getenv("AZURE_OPENAI_ENDPOINT"),
    azure_ad_token_provider=token_provider,
)

pamelafox avatar Dec 02 '24 22:12 pamelafox

@pamelafox This is super helpful thank you. We will try to get this added in an upcoming release.

ksolo avatar Dec 03 '24 03:12 ksolo