> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-docs-nav-cta-ab-test-try-cloud-free.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Chat 合作节点 ComfyUI 官方示例

> 本文将介绍如何在 ComfyUI 中使用 OpenAI Chat 合作节点来完成对话功能

OpenAI 是一家专注于生成式 AI 的科技公司，提供强大的对话功能。目前 ComfyUI 已集成 OpenAI API，你可以直接在 ComfyUI 中使用相关节点来完成对话功能。

本篇指南中，我们将引导你完成相应的对话功能。

<Tip>
  使用 API 节点需要保证你已经正常登录，并在受许可的网络环境下使用，请参考[API 节点总览](/zh/tutorials/partner-nodes/overview)部分文档来了解使用 API 节点的具体使用要求。
</Tip>

<Tip>
  <Tabs>
    <Tab title="本地用户">
      请确保你的 ComfyUI 已经更新。

      * [ComfyUI 下载](https://www.comfy.org/download)
      * [ComfyUI 更新教程](/zh/installation/update_comfyui)

      本指南里的工作流可以在[工作流模板](/zh/interface/features/template)中找到。如果找不到，可能是 ComfyUI 没有更新。

      如果加载工作流时有节点缺失，可能原因有：

      1. 你用的不是最新版（每夜版）。
      2. 启动时有些节点导入失败。
    </Tab>

    <Tab title="云端用户">
      * [Cloud](https://cloud.comfy.org) 会在 ComfyUI 稳定版本发布后更新。

      所以，如果你发现本文档中有任何核心节点缺失，可能是因为新核心节点尚未在最新稳定版中发布。请等待下一个稳定版发布。
    </Tab>
  </Tabs>
</Tip>

<h3 id="api_openai_chat">
  OpenAI: ChatGPT
</h3>

与 OpenAI 的高级语言模型进行智能对话。

<img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/templates/api_openai_chat-1.webp" alt="OpenAI: ChatGPT workflow preview" />

<CardGroup cols={2}>
  <Card title="在 Comfy Cloud 上运行" icon="cloud" href="https://cloud.comfy.org/?template=api_openai_chat&utm_source=docs&utm_medium=referral&utm_campaign=chat">
    在 Comfy Cloud 中打开
  </Card>

  <Card title="下载工作流" icon="download" href="https://github.com/Comfy-Org/workflow_templates/blob/main/templates/api_openai_chat.json">
    下载 JSON 或在模板库中搜索 "OpenAI: ChatGPT"
  </Card>
</CardGroup>

**输入素材**

上传此文件到匹配的 `LoadImage` 节点：

<CardGroup cols={2}>
  <Card title="example.png" icon="image" href="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/example.png">
    `LoadImage` 节点 5 · `example.png`
  </Card>
</CardGroup>

<div style={{display: 'grid', gridTemplateColumns: 'repeat(2, minmax(0, 1fr))', gap: '1rem', alignItems: 'start'}}>
  <img src="https://raw.githubusercontent.com/Comfy-Org/workflow_templates/main/input/example.png" alt="example.png" style={{width: '100%', height: 'auto', objectFit: 'contain'}} />
</div>

### 按步骤完成工作流执行

<img src="https://mintcdn.com/dripart-docs-nav-cta-ab-test-try-cloud-free/uZUIdcSBLoopnfbh/images/tutorial/api_nodes/openai/openai_chat_step_guide.jpg?fit=max&auto=format&n=uZUIdcSBLoopnfbh&q=85&s=fd82bd5470db9e3a27461cf8b2e7d364" alt="OpenAI Chat Step Guide" width="3834" height="2148" data-path="images/tutorial/api_nodes/openai/openai_chat_step_guide.jpg" />

<Note>
  在对应模板中，我们构建了一个用于分析提示词生成的角色设定。
</Note>

你可参考图像中的序号来完成基础的文生图工作流执行：

1. 在 `Load Image` 节点中，加载你需要 AI 解读的图像
2. (可选) 如果需要，你可以修改 `OpenAI Chat Advanced Options` 中的设置，从而让 AI 来执行特定任务
3. 在 `OpenAI Chat` 节点，你可以修改 `Prompt` 来设置对话的提示词，或者修改 `model` 来选择不同的模型
4. 点击 `Run` 按钮，或者使用快捷键 `Ctrl(cmd) + Enter` 来执行对话。
5. 等待 API 返回结果后，你可在 `Preview Any` 节点中查看对应 AI 返回的内容。

### 3. 补充说明

* 目前文件输入节点 `OpenAI Chat Input Files` 需要先将文件上传至 `ComfyUI/input/` 目录下。此节点正在改进，我们会在更新后修改模板。
* 工作流中提供了使用 `Batch Images` 来输入的示例。如果你有多张图像需要 AI 解读，可参考步骤图，使用右键将对应节点模式设置为 `总是（always）` 来启用。
