> ## Documentation Index
> Fetch the complete documentation index at: https://comfyuiwiki.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Comfy API 和 Router 示例

> Comfy Router 模型与已部署 ComfyUI 工作流的起点，以及可部署并自行改造的完整演示应用。

选择与你想要运行的内容相匹配的路径。

## 模型 API

使用 Comfy Router，通过一个 Comfy API 密钥即可调用托管的合作伙伴模型。

<CardGroup cols={2}>
  <Card title="生成图像" icon="image" href="/zh/development/comfy-router/quickstart">
    使用 Python、TypeScript 或 cURL，通过 Flux 制作你的第一张图像。
  </Card>

  <Card title="浏览可用模型" icon="magnifying-glass" href="/zh/development/comfy-router/models">
    查找模型、查看其输入，并复制其模型 ID。
  </Card>

  <Card title="使用模型的 schema" icon="list-tree" href="/zh/development/comfy-router/models/black-forest-labs/flux-2-pro/code">
    查看某个 Router 模型的请求与响应结构。
  </Card>

  <Card title="通过 HTTP 调用 Router" icon="terminal" href="/zh/development/comfy-router/reference">
    查询共享的 Router 端点和请求头。
  </Card>
</CardGroup>

## Comfy API

打包你自己的 ComfyUI 工作流，将其部署到托管的 GPU 基础设施，并通过 Comfy API 运行。

<CardGroup cols={2}>
  <Card title="部署工作流" icon="cloud-arrow-up" href="/zh/development/serverless/overview#快速开始">
    创建 Build、发布它，并启动托管部署。
  </Card>

  <Card title="选择计算资源" icon="microchip" href="/zh/development/serverless/overview#区域与-gpu-可用性">
    在部署之前查找可用的区域和 GPU 类型。
  </Card>

  <Card title="运行已部署的工作流" icon="play" href="/zh/development/serverless/overview#4-运行工作流">
    提交 API 格式的工作流并下载其输出。
  </Card>

  <Card title="使用 SDK" icon="code" href="/zh/development/api-development/sdks#serverless-deployment">
    将 Python 或 TypeScript SDK 指向你的部署。
  </Card>
</CardGroup>

<h2 id="full-demos">
  完整演示
</h2>

从一个完整的演示应用入手，然后为自己的项目调整工作流和界面。选择 Comfy Cloud 可获得最快的上手路径；当需要自己的模型或节点时，选择“自行部署”。

<div className="sample-card-grid">
  <div className="sample-card" data-sample-card="true">
    <div className="sample-card-inner">
      <div className="sample-card-face sample-card-front" data-sample-front="true">
        <img src="https://mintcdn.com/comfyuiwikicom/BkE53cHdW1j4wHJS/images/samples/img2img-web-app.svg?fit=max&auto=format&n=BkE53cHdW1j4wHJS&q=85&s=39e11c3011b2ef857e5a661a007d8849" alt="图生图网页应用预览" className="sample-card-preview" data-sample-preview="api" noZoom="true" width="960" height="540" data-path="images/samples/img2img-web-app.svg" />

        <div className="sample-card-body">
          <h2>图生图网页应用</h2>
          <p>上传图片，运行 Comfy 工作流，并在 Next.js 应用中展示结果。</p>

          <div className="sample-card-actions">
            <button type="button" data-sample-open="api">使用 Comfy Cloud</button>
            <button type="button" data-sample-open="endpoint">自行部署</button>
          </div>

          <div className="sample-card-links">
            <a href="https://github.com/Comfy-Org/comfy-examples/blob/main/img2img-web-app/workflows/workflow_api.json?raw=1">下载工作流 ↗</a><span>·</span><a href="https://github.com/Comfy-Org/comfy-examples/tree/main/img2img-web-app">查看源代码 ↗</a>
          </div>
        </div>
      </div>

      <div className="sample-card-face sample-card-back" data-sample-path="api" aria-hidden="true" inert="true">
        <div className="sample-path-body">
          <button type="button" data-sample-back="true">← 返回演示应用</button>
          <p className="sample-path-eyebrow">Comfy Cloud</p><h2>在图生图网页应用中使用 Comfy Cloud</h2>
          <p>将 Comfy Cloud 用作托管端点。创建 API 密钥，然后部署该应用的一份副本。</p>

          <div className="sample-path-steps">
            <div className="sample-path-step"><span className="sample-path-number">1</span><div className="sample-path-copy"><strong>创建 API 密钥</strong><span>创建并保存一个 Comfy API 密钥。还需拥有符合条件的 Comfy Cloud 订阅。</span></div><a href="https://platform.comfy.org/profile/api-keys">创建 API 密钥 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">2</span><div className="sample-path-copy"><strong>将应用部署到 Vercel</strong><span>提供商会在此示例的基础上，在你的账户中创建一份副本。</span></div><a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FComfy-Org%2Fcomfy-examples%2Ftree%2Fmain%2Fimg2img-web-app&env=COMFY_BASE_URL%2CCOMFY_API_KEY&envDefaults=%7B%22COMFY_BASE_URL%22%3A%22https%3A%2F%2Fcloud.comfy.org%22%7D">部署应用 ↗</a></div>
          </div>
        </div>
      </div>

      <div className="sample-card-face sample-card-back" data-sample-path="endpoint" aria-hidden="true" inert="true">
        <div className="sample-path-body">
          <button type="button" data-sample-back="true">← 返回演示应用</button>
          <p className="sample-path-eyebrow">自行部署</p><h2>为图生图网页应用部署你自己的端点</h2>
          <p>当需要自己的模型或自定义节点时，创建 Comfy API 无服务器端点。</p>

          <div className="sample-path-steps">
            <div className="sample-path-step"><span className="sample-path-number">1</span><div className="sample-path-copy"><strong>下载工作流</strong><span>在专用部署流程中使用此 API 格式的工作流。</span></div><a href="https://github.com/Comfy-Org/comfy-examples/blob/main/img2img-web-app/workflows/workflow_api.json?raw=1">下载工作流 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">2</span><div className="sample-path-copy"><strong>创建 API 密钥</strong><span>创建并保存已部署应用将要使用的密钥。</span></div><a href="https://platform.comfy.org/profile/api-keys">创建 API 密钥 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">3</span><div className="sample-path-copy"><strong>粘贴工作流并部署</strong><span>在 Builds 中粘贴工作流，配置端点，然后等待其 URL。</span></div><a href="https://platform.comfy.org/profile/builds">打开 Builds ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">4</span><div className="sample-path-copy"><strong>粘贴端点 URL 和 API 密钥</strong><span>在部署应用时设置 COMFY\_BASE\_URL 和 COMFY\_API\_KEY。</span></div><a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FComfy-Org%2Fcomfy-examples%2Ftree%2Fmain%2Fimg2img-web-app&env=COMFY_BASE_URL%2CCOMFY_API_KEY">部署应用 ↗</a></div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div className="sample-card" data-sample-card="true">
    <div className="sample-card-inner">
      <div className="sample-card-face sample-card-front" data-sample-front="true">
        <img src="https://mintcdn.com/comfyuiwikicom/BkE53cHdW1j4wHJS/images/samples/sketch-to-image.svg?fit=max&auto=format&n=BkE53cHdW1j4wHJS&q=85&s=af862b3d298ceb0fc311ae5cc3323270" alt="草图生图应用预览" className="sample-card-preview" data-sample-preview="api" noZoom="true" width="960" height="540" data-path="images/samples/sketch-to-image.svg" />

        <div className="sample-card-body">
          <h2>草图生图</h2><p>绘制或导入一张引导图，然后根据该引导图和提示词生成图像。</p>
          <div className="sample-card-actions"><button type="button" data-sample-open="api">使用 Comfy Cloud</button><button type="button" data-sample-open="endpoint">自行部署</button></div>
          <div className="sample-card-links"><a href="https://github.com/Comfy-Org/comfy-examples/blob/main/sketch-to-image/workflows/workflow_api.json?raw=1">下载工作流 ↗</a><span>·</span><a href="https://github.com/Comfy-Org/comfy-examples/tree/main/sketch-to-image">查看源代码 ↗</a></div>
        </div>
      </div>

      <div className="sample-card-face sample-card-back" data-sample-path="api" aria-hidden="true" inert="true">
        <div className="sample-path-body">
          <button type="button" data-sample-back="true">← 返回演示应用</button>
          <p className="sample-path-eyebrow">Comfy Cloud</p>
          <h2>将 Sketch to image 与 Comfy Cloud 配合使用</h2>
          <p>使用 Comfy Cloud 作为托管端点。创建 API 密钥，然后部署该应用的副本。</p>

          <div className="sample-path-steps">
            <div className="sample-path-step"><span className="sample-path-number">1</span><div className="sample-path-copy"><strong>创建 API 密钥</strong><span>创建并保存 Comfy API 密钥。还需要有符合条件的 Comfy Cloud 订阅。</span></div><a href="https://platform.comfy.org/profile/api-keys">创建 API 密钥 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">2</span><div className="sample-path-copy"><strong>将应用部署到 Vercel</strong><span>提供商会在此账户中创建该示例的副本。</span></div><a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FComfy-Org%2Fcomfy-examples%2Ftree%2Fmain%2Fsketch-to-image&env=COMFY_BASE_URL%2CCOMFY_API_KEY&envDefaults=%7B%22COMFY_BASE_URL%22%3A%22https%3A%2F%2Fcloud.comfy.org%22%7D">部署应用 ↗</a></div>
          </div>
        </div>
      </div>

      <div className="sample-card-face sample-card-back" data-sample-path="endpoint" aria-hidden="true" inert="true">
        <div className="sample-path-body">
          <button type="button" data-sample-back="true">← 返回演示应用</button>
          <p className="sample-path-eyebrow">自行部署</p>
          <h2>为 Sketch to image 部署你自己的端点</h2>
          <p>当你需要自己的模型或自定义节点时，创建一个 Comfy API 无服务器端点。</p>

          <div className="sample-path-steps">
            <div className="sample-path-step"><span className="sample-path-number">1</span><div className="sample-path-copy"><strong>下载工作流</strong><span>在专用的部署流程中使用这个 API 格式的工作流。</span></div><a href="https://github.com/Comfy-Org/comfy-examples/blob/main/sketch-to-image/workflows/workflow_api.json?raw=1">下载工作流 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">2</span><div className="sample-path-copy"><strong>创建 API 密钥</strong><span>创建并保存你部署的应用将要使用的密钥。</span></div><a href="https://platform.comfy.org/profile/api-keys">创建 API 密钥 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">3</span><div className="sample-path-copy"><strong>粘贴工作流并部署</strong><span>在 Builds 中粘贴工作流，配置端点，然后等待其 URL。</span></div><a href="https://platform.comfy.org/profile/builds">打开 builds ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">4</span><div className="sample-path-copy"><strong>粘贴端点 URL 和 API 密钥</strong><span>在应用部署期间设置 COMFY\_BASE\_URL 和 COMFY\_API\_KEY。</span></div><a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FComfy-Org%2Fcomfy-examples%2Ftree%2Fmain%2Fsketch-to-image&env=COMFY_BASE_URL%2CCOMFY_API_KEY">部署应用 ↗</a></div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <div className="sample-card" data-sample-card="true">
    <div className="sample-card-inner">
      <div className="sample-card-face sample-card-front" data-sample-front="true">
        <img src="https://mintcdn.com/comfyuiwikicom/BkE53cHdW1j4wHJS/images/samples/discord-image-bot.svg?fit=max&auto=format&n=BkE53cHdW1j4wHJS&q=85&s=e2a7b16c61afc2ad639f4a8988b194d8" alt="Discord image bot 的预览" className="sample-card-preview" data-sample-preview="api" noZoom="true" width="960" height="540" data-path="images/samples/discord-image-bot.svg" />

        <div className="sample-card-body">
          <h2>Discord image bot</h2><p>为 Discord 服务器添加一个 `/imagine` 指令，并运行随附的 Comfy 工作流。</p>
          <div className="sample-card-actions"><button type="button" data-sample-open="api">使用 Comfy Cloud</button><button type="button" data-sample-open="endpoint">自行部署</button></div>
          <div className="sample-card-links"><a href="https://github.com/Comfy-Org/comfy-discord-image-bot/blob/main/workflows/workflow_api.json?raw=1">下载工作流 ↗</a><span>·</span><a href="https://github.com/Comfy-Org/comfy-discord-image-bot">查看来源 ↗</a></div>
        </div>
      </div>

      <div className="sample-card-face sample-card-back" data-sample-path="api" aria-hidden="true" inert="true">
        <div className="sample-path-body">
          <button type="button" data-sample-back="true">← 返回演示应用</button>
          <p className="sample-path-eyebrow">Comfy Cloud</p>
          <h2>将 Discord image bot 与 Comfy Cloud 配合使用</h2>
          <p>使用 Comfy Cloud 作为托管端点。创建 API 密钥，然后部署该应用的副本。</p>

          <div className="sample-path-steps">
            <div className="sample-path-step"><span className="sample-path-number">1</span><div className="sample-path-copy"><strong>创建 API 密钥</strong><span>创建并保存 Comfy API 密钥。还需要有符合条件的 Comfy Cloud 订阅。</span></div><a href="https://platform.comfy.org/profile/api-keys">创建 API 密钥 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">2</span><div className="sample-path-copy"><strong>将应用部署到 Render</strong><span>提供商会在此账户中创建该示例的副本。</span></div><a href="https://render.com/deploy?repo=https%3A%2F%2Fgithub.com%2FComfy-Org%2Fcomfy-discord-image-bot">部署应用 ↗</a></div>
          </div>
        </div>
      </div>

      <div className="sample-card-face sample-card-back" data-sample-path="endpoint" aria-hidden="true" inert="true">
        <div className="sample-path-body">
          <button type="button" data-sample-back="true">← 返回演示应用</button>
          <p className="sample-path-eyebrow">自行部署</p>
          <h2>为 Discord image bot 部署你自己的端点</h2><p>当你需要自己的模型或自定义节点时，创建 Comfy API 无服务器端点。</p>

          <div className="sample-path-steps">
            <div className="sample-path-step"><span className="sample-path-number">1</span><div className="sample-path-copy"><strong>下载工作流</strong><span>在专用部署流程中使用此 API 格式的工作流。</span></div><a href="https://github.com/Comfy-Org/comfy-discord-image-bot/blob/main/workflows/workflow_api.json?raw=1">下载工作流 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">2</span><div className="sample-path-copy"><strong>创建 API 密钥</strong><span>创建并保存你的已部署应用将要使用的密钥。</span></div><a href="https://platform.comfy.org/profile/api-keys">创建 API 密钥 ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">3</span><div className="sample-path-copy"><strong>粘贴工作流并部署</strong><span>在 Builds 中粘贴工作流，配置端点，然后等待其 URL。</span></div><a href="https://platform.comfy.org/profile/builds">打开 Builds ↗</a></div>
            <div className="sample-path-step"><span className="sample-path-number">4</span><div className="sample-path-copy"><strong>粘贴端点 URL 和 API 密钥</strong><span>在应用部署期间设置 COMFY\_BASE\_URL 和 COMFY\_API\_KEY。</span></div><a href="https://render.com/deploy?repo=https%3A%2F%2Fgithub.com%2FComfy-Org%2Fcomfy-discord-image-bot">部署应用 ↗</a></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<Note>
  两条路径都需要一个 [Comfy API 密钥](https://platform.comfy.org/profile/api-keys)。对于 Deploy Your Own，请下载工作流，使用 Builds 粘贴它并配置无服务器端点，等待其 URL，然后将该 URL 和 API 密钥粘贴到你的 Vercel 或 Render 部署中。
</Note>

想要添加演示应用？请参阅[示例仓库](https://github.com/Comfy-Org/comfy-examples)。
