SamurAIGPT / Open-Custom-GPT

Create Custom GPT and add/embed on your site using Assistants api
https://customgpt.thesamur.ai
MIT License
1.52k stars 269 forks source link

API key request using other devices #20

Closed hcdgsv closed 1 month ago

hcdgsv commented 5 months ago

Is there a way to set the API key as fixed so that external users can interact with the chat?

I've installed it and it works perfectly in Chrome; however, when I open it in another browser or device, it asks me to enter the API KEY.?

Anil-matcha commented 5 months ago

It is designed by default to take the api key from the user and use it for generating the response

hcdgsv commented 5 months ago

is there any way to keep my API key?

SamuelChabal commented 4 months ago

For me the only job I am looking for is the use of the chat by external people via my key.

vonbarnekowa commented 3 months ago

Any news about this ? Would be nice to have the possibility to store an api key for all users. So when you share a custom gpt, the end user has not to put in the API key

mledwards commented 1 month ago

Just thinking about the easiest way to do this, then I'll PR an "option" to make it public (without the key being visible to the client)

mledwards commented 1 month ago

I got this working by changing all the client-side openai calls to server side API calls, so

This...

const messages = await openai.beta.threads.messages.list(threadId);

Becomes this...

const getMessagesResponses = await fetch(`/api/openai`, {
        method: "post",
        body: JSON.stringify({
          method: "messages",
          action: "list",
          threadId,
        }),
      });

      const messages = await getMessagesResponses.json();

And the API route returns this...

const listMessages = await openai.beta.threads[method].list(threadId);
      return NextResponse.json({
        ...listMessages,
      });

See this branch: https://github.com/mledwards/Open-Custom-GPT/tree/update/make-server-side

Anil-matcha commented 1 month ago

@hcdgsv @SamuelChabal @vonbarnekowa

Now added support for using api key of owner instead of requesting it everytime in the web version. Do try at customgpt.thesamur.ai