**TL;DR:** The key is missing, wrong, expired, or not visible to the process. This error is not retryable, so retry loops will not save you. Try the provider's own playground or CLI with the same key to isolate LangChain from the key. Proxy or non-standard endpoint?

## The error

```text
langchain_core.exceptions.ModelAuthenticationError
```

## The fix

1. Is the variable set in the actual process environment? Print it (or its presence) from inside the running process. dotenv files that load after the model is constructed, containers that did not get the env file, and notebooks with a stale kernel are the classics.

2. Is the name right? OPENAI_API_KEY, ANTHROPIC_API_KEY. A typo'd variable name looks exactly like a missing key.

3. Is the key valid and current? Keys get rotated and revoked. Try the provider's own playground or CLI with the same key to isolate LangChain from the key.

4. Proxy or non-standard endpoint? Make sure the custom endpoint does not expect a different auth scheme.

5. Set the variable before the model is constructed, or pass the key explicitly to the model class.

6. In JS, the same condition surfaces as the MODEL_AUTHENTICATION error code on the thrown error's `lc_error_code`.

## When to use this

- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: ModelAuthenticationError.
- You want the fastest verified fix before digging through logs.

## When not to use this

- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.

## Compatibility

- Not pinned to a specific version; follows current ModelAuthenticationError behavior.

## Also seen as

- `lc_error_code`
- `d variable name looks exactly like a missing key.
3. Is the key valid and current? Keys get rotated and revoked. Try the provider`