laravel icon indicating copy to clipboard operation
laravel copied to clipboard

Can we get a feature to specify project keys. At the moment we're forced to use one OpenAI key

Open Flame1994 opened this issue 1 year ago • 2 comments

As mentioned in the title, the ServiceProvider forced one orginization key but also only one API key. A newer version of the API now supports project keys which can have their own api keys as well. It would be nice to have the functionality to specify different keys on demand

Flame1994 avatar Jul 05 '24 10:07 Flame1994

I got confused at this, but now re-reading this. You are requesting pluggable API keys and I think thats a good idea. I just need to brainstorm on how.

Since the client is HTTP agnostic and the client is assembled once established - there is not like a generic method we can rely on (outside of headers) to do this. I'll think on this.

iBotPeaches avatar Apr 07 '25 16:04 iBotPeaches

I think I've been dealing with a similar problem. In my application code I was able to do something like this:

OpenAI::factory()->withApiKey($apiKey)->make()

The problem with this for me was mostly in tests which were using OpenAI::fake(), since the fake instance that's provided doesn't have methods like "factory" so calling factory on your application would break those tests.

Is this somewhat similar to your problem(s)?

Timm49 avatar May 25 '25 10:05 Timm49