secret_from_env#

langchain_core.utils.utils.secret_from_env(key: str, /) Callable[[], SecretStr][source]#
langchain_core.utils.utils.secret_from_env(key: str, /, *, default: str) Callable[[], SecretStr]
langchain_core.utils.utils.secret_from_env(key: str | Sequence[str], /, *, default: None) Callable[[], SecretStr | None]
langchain_core.utils.utils.secret_from_env(key: str, /, *, error_message: str) Callable[[], SecretStr]

Secret from env.

Parameters:
  • key – The environment variable to look up.

  • default – The default value to return if the environment variable is not set.

  • error_message – the error message which will be raised if the key is not found and no default value is provided. This will be raised as a ValueError.

Returns:

factory method that will look up the secret from the environment.