Dynamically updating OpenAI Key #16424
Replies: 3 comments
-
🤖 Based on the current design of the LangChain framework, the OpenAI API key is not designed to be dynamically updated in the same way as the temperature. The API key is set during the initialization of the The values["openai_api_key"] = get_from_dict_or_env(
values, "openai_api_key", "OPENAI_API_KEY"
) This means that when you update the However, you can manually update the # Assume `model` is an instance of the `BaseOpenAI` class
model.openai_api_key = 'new_api_key' This will update the API key for the Please be aware that this is not the intended use of the For more details, you can refer to the source code of the SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
did you find any solution? |
Beta Was this translation helpful? Give feedback.
-
Hi, is there any solution for it? I am facing the same issue |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We can dynamically update the temperature as so
But the same cannot be done for api key
I realize this might be because of how secrets are configured
Can anyone explain if there is any workaround for this
Beta Was this translation helpful? Give feedback.
All reactions