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

[Enhancement]: if user_provided API KEY value is used, fetch models for user #1028

Open
1 task done
ZentixUA opened this issue Oct 8, 2023 · 5 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@ZentixUA
Copy link
Contributor

ZentixUA commented Oct 8, 2023

Contact Details

zentixua@gmail.com

What happened?

if user_provided API KEY value is used, the model list will not be loaded.

Screenshot:
image

But setting the global key fixes it:
image
image

Steps to Reproduce

  1. Go to https://chat.naga.ac/
  2. Try it yourself

OR

  1. Use OPENAI_REVERSE_PROXY=https://api.naga.ac/v1/chat/completions
  2. Use OPENAI_API_KEY=user_provided
  3. Enter your NagaAI key on the web page
  4. Enjoy this issue xDDD

What browsers are you seeing the problem on?

Firefox, Chrome

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ZentixUA ZentixUA added the bug Something isn't working label Oct 8, 2023
@danny-avila danny-avila added enhancement New feature or request and removed bug Something isn't working labels Oct 8, 2023
@danny-avila danny-avila changed the title [Bug]: if user_provided API KEY value is used, the model list will not be loaded Oct 8, 2023
@danny-avila
Copy link
Owner

This is by design so not a bug but a feature request. OpenAI doesn't allow model calls without API key, so this will need an added feature

image

@danny-avila
Copy link
Owner

danny-avila commented Oct 8, 2023

there's two potential solutions, and both can be added. # 1 might be more useful in your case (using reverse proxies)

  1. add a env var for an API KEY exclusively for fetching available models
  2. if user_provided is set, change the fetch to a different controller, which will read the encrypted key the user provided for the official api
@ArakiSatoshi
Copy link

ArakiSatoshi commented Oct 13, 2024

It should be considered a bug, or at least a design flaw.

It's insecure to hardcode API keys into the config files over properly hashing them individually for each user (I haven't confirmed this is how LibreChat handles it, just hopefully assume), so using user_provided should be prioritized. However, the fetch mechanism does not use the user-provided key to fetch available models, although it is expected to do so, making the issue a bug.

The only workaround for the user is to specify the models using the default: list, but this could be quite troublesome for remotes like OpenRouter which has 100+ models available and it is desirable to both have all of them and have access to the most recent ones without rewriting the librechat.yaml file.

@nitanmarcel
Copy link

there's two potential solutions, and both can be added. # 1 might be more useful in your case (using reverse proxies)

  1. add a env var for an API KEY exclusively for fetching available models
  2. if user_provided is set, change the fetch to a different controller, which will read the encrypted key the user provided for the official api

You can also try to fetch them anyway either if it's an user_provided key or not. Some proxies including the ones above allow to get models without an API key

@danny-avila
Copy link
Owner

danny-avila commented Oct 24, 2024

It's insecure to hardcode API keys into the config files over properly hashing them individually for each user (I haven't confirmed this is how LibreChat handles it, just hopefully assume), so using user_provided should be prioritized.

This is not how we encourage users to define API keys in the LibreChat config file.

While you can directly put in API keys in the config file, it's discouraged, and references to the environment variable names are encouraged instead.

i.e this is a valid setting: apiKey: "${WESTUS_API_KEY}" , where WESTUS_API_KEY is meant to be defined in the .env file.

However, the fetch mechanism does not use the user-provided key to fetch available models, although it is expected to do so, making the issue a bug.

The models are fetched on startup, which is why it doesn't happen. They would need to be fetched upon user requests for this to be possible, which is planned.

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