# resolve_env_var

> **Function** in `deepagents_cli`

📖 [View in docs](https://reference.langchain.com/python/deepagents-cli/model_config/resolve_env_var)

Look up an env var with `DEEPAGENTS_CLI_` prefix override.

Checks `DEEPAGENTS_CLI_{name}` first, then falls back to `{name}`.

If the prefixed variable is *present* in the environment (even as an empty
string), the canonical variable is never consulted. This lets users
set `DEEPAGENTS_CLI_X=""` to shadow a canonically-set key -- the function
will return `None` (since empty strings are normalized to `None`),
effectively suppressing the canonical value.

If `name` already carries the prefix, the double-prefixed lookup is skipped
to avoid nonsensical `DEEPAGENTS_CLI_DEEPAGENTS_CLI_*` reads
(e.g., when the name comes from a user's `config.toml`).

## Signature

```python
resolve_env_var(
    name: str,
) -> str | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | `str` | Yes | The canonical environment variable name (e.g. `ANTHROPIC_API_KEY`). |

## Returns

`str | None`

The resolved value, or `None` when absent or empty.

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/3bcc51a95da80094cfc8bc4bcaf25dc1e2ad8f44/libs/cli/deepagents_cli/model_config.py#L31)