概述
集成详情
设置
要访问 OpenAI models,你需要create an OpenAI account, get an API key, and install the@langchain/openai integration package.
凭证
前往 platform.openai.com 注册 OpenAI 并生成 API 密钥。完成后设置OPENAI_API_KEY 环境变量:
安装
LangChain 的 OpenAI 集成位于@langchain/openai 包中:
实例化
现在我们可以实例化模型对象并生成聊天补全:调用
自定义 URL
You can customize the base URL the SDK sends requests to by passing aconfiguration parameter like this:
ClientOptions parameters accepted by the official SDK.
If you are hosting on Azure OpenAI, see the dedicated page instead.
API 参考
有关所有OpenAI 功能和配置的详细文档,请前往 API 参考。
将这些文档连接到 Claude、VSCode 等工具,通过 MCP 获取实时答案。

