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

How to set the default API key #83

Open
1 task
editionserver opened this issue Jul 11, 2023 · 1 comment
Open
1 task

How to set the default API key #83

editionserver opened this issue Jul 11, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@editionserver
Copy link

Describe the feature

how to set the default API key

Additional context

I don't want people to enter the API, I added it by default so that the openai API is recognized automatically and everyone can chat.

Participation

  • I am willing to submit a pull request for this feature.
@editionserver editionserver added the enhancement New feature or request label Jul 11, 2023
@LyuLumos
Copy link
Contributor

This issue is similar to #1.

This project does not support setting environment variables now. However, if your project (source code) is not public, you can try:

// src/providers/openai/api.ts
export const fetchChatCompletion = async(payload: OpenAIFetchPayload) => {
   if (!payload.apiKey) {
    payload.apiKey = 'sk-xxx'
  }
  const initOptions = {
    // same
  }
  return fetch(`${payload.baseUrl}/v1/chat/completions`, initOptions)
}

It will not display your key in web. And if the user enters his key, it will be used first.

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

No branches or pull requests

2 participants