> ## Documentation Index
> Fetch the complete documentation index at: https://nvd-54.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# MODEL_AUTHENTICATION

<Note>
  目前仅在 `langchainjs`（JavaScript/TypeScript）中使用。
</Note>

你的模型提供商拒绝了你对其服务的访问。

此错误通常发生在身份验证凭据或 API 密钥存在问题时。

## 故障排除

* 确认你的 API 密钥或身份验证凭据准确且有效。
* 如果使用基于环境变量的身份验证，请验证：
  * 变量名拼写正确
  * 变量包含已分配的值
  * 第三方包如 `dotenv` 没有干扰加载过程
* 如果使用代理或非标准端点，请确保你的自定义提供商不需要替代的身份验证方案。
* 通过显式传入凭据来绕过环境变量问题：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
from langchain_openai import ChatOpenAI

model = ChatOpenAI(api_key="YOUR_KEY_HERE")
```

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档连接](/use-these-docs)到 Claude、VSCode 等工具，通过 MCP 获取实时回答。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/langchain/errors/MODEL_AUTHENTICATION.mdx)或[提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
