Last updated 2026-08-31
LangChain's OpenAI chat model class takes the same two arguments as the SDK it wraps. Everything built on top of that class — chains, agents, tools — keeps working unchanged.
Every client needs the same three. Sign in and take them from the console.
A LangChain agent may call the model many times to answer one question, each call carrying the full conversation so far. The credit cost of one agent run is not comparable to one chat message.
Retrieval chains send the retrieved documents on every call. A large context window makes that convenient and expensive at the same time.
Invoke the model directly with a one-line prompt before wiring it into a chain. If that returns and shows up in the console, the connection is fine and anything after that is a chain problem, not a connection problem.
A 401 usually means the key was copied with a trailing space. A 404 means the base URL has /v1 twice or not at all — try it the other way. A 400 saying the model is not allowed means the tool sent its own default name instead of one of ours. The full table is on the clients page.
最后更新 2026-08-31
LangChain 的 OpenAI 对话模型类接受与其底层 SDK 相同的两个参数。基于该类构建的一切——链、智能体、工具——均无需改动即可继续使用。
所有客户端要的都是这三个。登录后在控制台获取。
LangChain 智能体回答一个问题可能调用模型多次,且每次调用都会携带当前完整对话。一次智能体运行的额度消耗与一条普通对话不可同日而语。
检索链在每次调用时都会发送检索到的文档。较大的上下文窗口在带来便利的同时也带来了成本。
在接入链之前,先用一行提示词直接调用模型。若能正常返回并出现在控制台中,说明连接无误;之后出现的问题属于链本身,而非连接。
返回 401 通常是密钥复制时末尾带了空格;返回 404 是接口地址中 /v1 重复或缺失,改成另一种写法即可;返回 400 且提示模型不被允许,说明客户端发送的是它自带的默认模型名,需手动填写本站的名称。完整对照表见客户端总览。