Skip to content
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

Add support for token providers in the native OpenAI client #1156

Open
1 task done
samuelwcm opened this issue Feb 15, 2024 · 1 comment
Open
1 task done

Add support for token providers in the native OpenAI client #1156

samuelwcm opened this issue Feb 15, 2024 · 1 comment

Comments

@samuelwcm
Copy link

Confirm this is a feature request for the Python library and not the underlying OpenAI API.

  • This is a feature request for the Python library

Describe the feature or improvement you're requesting

Our project utilizes both OpenAI and Azure OpenAI APIs, which our organisation manages through an API gateway. The gateway provides its own short-lived JWTs and serves as a mediator between clients and these APIs, with some organisational logic over the top.

For Azure APIs, we use the AzureOpenAI.azure_ad_token_provider parameter to automatically refresh access tokens. Unfortunately, OpenAI's standard clients lack this feature.

As a workaround, we have written a custom class extending openai.AsyncOpenAI, with api_key defined as an @property getter to handle token refreshes. However, this workaround is not ideal due to the extra maintenance required. Ideally, OpenAI's clients would natively support token providers the same way as the Azure ones do.

Would there be interest in adding this feature? I'm willing to make this contribution myself!

Additional context

No response

@rattrayalex
Copy link
Collaborator

Thanks for sharing your use-case!

May I ask what's wrong with using the AzureOpenAI class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants