# get_env_var

> **Function** in `langsmith`

📖 [View in docs](https://reference.langchain.com/python/langsmith/utils/get_env_var)

Retrieve an environment variable from a list of namespaces.

## Signature

```python
get_env_var(
    name: str,
    default: Optional[str] = None,
    *,
    namespaces: tuple = ('LANGSMITH', 'LANGCHAIN'),
) -> Optional[str]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | `str` | Yes | The name of the environment variable. |
| `default` | `Optional[str]` | No | The default value to return if the environment variable is not found. (default: `None`) |
| `namespaces` | `tuple` | No | A tuple of namespaces to search for the environment variable.  Defaults to `('LANGSMITH', 'LANGCHAINs')`. (default: `('LANGSMITH', 'LANGCHAIN')`) |

## Returns

`Optional[str]`

The value of the environment variable if found, otherwise the default value.

---

[View source on GitHub](https://github.com/langchain-ai/langsmith-sdk/blob/ce9e9e8973442b33e98ec3ce1b9c2dd3f58a43a7/python/langsmith/utils.py#L418)