openai-java icon indicating copy to clipboard operation
openai-java copied to clipboard

How to set organisation id

Open Talgat777 opened this issue 3 years ago • 3 comments

I have multiple organizations setup and I need to specify which one is used. Is there a way to do it? https://platform.openai.com/docs/api-reference/requesting-organization

Talgat777 avatar Apr 26 '23 16:04 Talgat777

Have you found the solution yet? I was looking for this too, but could not find yet

itskashi avatar May 03 '23 13:05 itskashi

I think the best you can do right now is to add the header to the ExecutorService by using this version of the constructor:

    public OpenAiService(final OpenAiApi api, final ExecutorService executorService) {
        this.api = api;
        this.executorService = executorService;
    }

And then I'm not exactly sure where to put this, but you can initialize and add headers where the HTTP request is constructed.

HashMap <String, String> headers = new HashMap<>();
headers.put("organization", "YOUR_ORG_ID");

cryptoapebot avatar May 03 '23 14:05 cryptoapebot

There is an open PR for this - #69. @TheoKanning can you merge it?

nikhilgupta23 avatar May 22 '23 06:05 nikhilgupta23