get_from_env#

langchain_core.utils.env.get_from_env(key: str, env_key: str, default: str | None = None) str[source]#

Get a value from a dictionary or an environment variable.

Parameters:
  • key (str) – The key to look up in the dictionary.

  • env_key (str) – The environment variable to look up if the key is not in the dictionary.

  • default (str | None) – The default value to return if the key is not in the dictionary or the environment. Defaults to None.

Returns:

The value of the key.

Return type:

str

Raises:

ValueError – If the key is not in the dictionary and no default value is provided or if the environment variable is not set.

Examples using get_from_env