anse
anse copied to clipboard
How to set the default API key
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.
This issue is similar to https://github.com/anse-app/anse/issues/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.