-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Supplying API keys per request #160
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
Comments
Thanks @numpde ! I'm a little confused by this issue. Can you elaborate a bit more on what you'd expect to see in the different test cases? |
Basically, I'd expect openai.Image(api_key=api_key).create(...) or openai.Image.create(api_key=api_key, ...) to work, but they don't. What I did to work-around was: def create(**kw):
worker = openai.Image()
assert api_key
worker.refresh_from({}, api_key=api_key) # hammer it in
return worker.request("post", worker._get_url("generations"), kw)
create(prompt=....) |
That makes sense. I've been able to recreate this behavior on Image.create but not on other API calls. Are there any other places you're seeing this issue? |
I haven't tried (but seeing the code, I don't expect it). |
We probably won't be able to merge this in until after the holidays, but I think the patch above should fix your issue? |
I'd like to supply the API key for each request separatly (for different users of the same app), instead of
openai.api_key = ...
.I find this strange behaviour, as documented in the following code, see in particular the
_UNEXPECTED_BEHAVIOR
tests.Edit: the following tests all pass with
openai==0.25.0
.The text was updated successfully, but these errors were encountered: