# resolve_provider_credential

> **Function** in `deepagents_code`

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

Resolve the credential value for `provider` from any configured source.

Lookup order:

1. Stored API key in `~/.deepagents/.state/auth.json` (added via `/auth`).
2. Canonical env var via `resolve_env_var()` (which honors the
    `DEEPAGENTS_CODE_` prefix and dotenv files).

A user who has *both* a stored key and an env var set gets the stored
key — entering one in the TUI is the more deliberate, more recent
action, so "I just typed this in" beats whatever the shell exported.

## Signature

```python
resolve_provider_credential(
    provider: str,
) -> str | None
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `provider` | `str` | Yes | Provider name (e.g., `"anthropic"`). |

## Returns

`str | None`

The credential value, or `None` when no source has one or the

---

[View source on GitHub](https://github.com/langchain-ai/deepagents/blob/a98f0dfa8d534d8a1885b524632400e52db22ac6/libs/code/deepagents_code/model_config.py#L1640)