from_env#

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

Create a factory method that gets a value from an environment variable.

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.