> ## 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`）没有干扰加载
* 如果使用代理或非标准端点，确保您的自定义提供商不需要替代的身份验证方案。
* 通过显式传递凭据来绕过环境变量问题：

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { ChatOpenAI } from "@langchain/openai";

const model = new ChatOpenAI({
  apiKey: "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>
