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

# ERNIE-Image

export const ComfyUISupport = ({model = "video", note}) => {
  const PLUGIN_PATH = "python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion";
  const PLUGIN_URL = "https://github.com/sgl-project/sglang/tree/main/" + PLUGIN_PATH;
  const MODELS = {
    flux: {
      serverNode: "SGLDiffusion Generate Image",
      integratedKey: "flux",
      workflow: "flux_sgld_sp.json"
    },
    "z-image": {
      serverNode: "SGLDiffusion Generate Image",
      integratedKey: "lumina2",
      workflow: "z-image_sgld.json"
    },
    "qwen-image": {
      serverNode: "SGLDiffusion Generate Image",
      integratedKey: "qwen_image",
      workflow: "qwen_image_sgld.json"
    },
    "qwen-image-edit": {
      serverNode: "SGLDiffusion Generate Image",
      integratedKey: "qwen_image_edit",
      note: "Image editing through the integrated path is experimental."
    },
    "minimax-h3": {
      serverNode: "SGLDiffusion Generate H3",
      verified: true,
      integratedBlockedBecause: "H3 denoises a packed video-and-audio sequence in one pass and routes " + "conditioning by task, while ComfyUI's KSampler drives a single latent " + "tensor and has no audio branch"
    },
    image: {
      serverNode: "SGLDiffusion Generate Image"
    },
    video: {
      serverNode: "SGLDiffusion Generate Video"
    }
  };
  const spec = MODELS[model] || MODELS.video;
  const extraNote = note || spec.note;
  return <div>
      <p>
        Run this model from ComfyUI with the{" "}
        <a href={PLUGIN_URL}>SGLDiffusion plugin</a>, which ships in the SGLang
        repository at <code>{PLUGIN_PATH}</code>.
      </p>

      <p>
        <strong>Server mode</strong> — SGLang runs the pipeline and ComfyUI
        sends the request. Start a server as shown above, point the{" "}
        <code>SGLDiffusion Server Model</code> node at it, then generate with{" "}
        <code>{spec.serverNode}</code>.
        {spec.verified ? " This path has been run end to end against a live server." : ""}
      </p>

      {spec.integratedKey ? <p>
          <strong>Integrated mode</strong> — ComfyUI's own sampler, CLIP, and
          VAE drive the loop while SGLang replaces the model forward. Load the
          checkpoint with <code>SGLDiffusion UNET Loader</code> and set{" "}
          <code>model_type</code> to <code>{spec.integratedKey}</code> on the{" "}
          <code>SGLDiffusion Options</code> node.
          {spec.workflow ? <>
              {" "}
              A reference workflow is included at{" "}
              <code>{`${PLUGIN_PATH}/workflows/${spec.workflow}`}</code>.
            </> : null}
        </p> : <p>
          <strong>Integrated mode</strong> — not available for this model
          {spec.integratedBlockedBecause ? `: ${spec.integratedBlockedBecause}` : ", which has no executor in the plugin"}
          . Use server mode.
        </p>}

      {extraNote ? <p>{extraNote}</p> : null}
    </div>;
};

export const DiffusionModelTags = ({tags = []}) => {
  const normalizedTags = Array.isArray(tags) ? tags : [tags];
  return <div className="not-prose sgd-model-tags">
      {normalizedTags.map(tag => <span key={tag} className="sgd-chip">
          {tag}
        </span>)}
    </div>;
};

<DiffusionModelTags tags={["image", "text-to-image", "standard + Turbo", "single GPU"]} />

## 1. Model Introduction

[ERNIE-Image](https://huggingface.co/baidu/ERNIE-Image) is Baidu's text-to-image family with separate standard and Turbo checkpoints. The standard model is the quality-oriented path; Turbo is the lower-latency choice, and both load through SGLang's native `ErnieImagePipeline`.

This integration currently targets text-only image generation rather than image editing or reference conditioning. Choose it for a straightforward single-GPU T2I deployment; use a dedicated editing model when preserving source-image structure is part of the task.

| Model | Hugging Face model ID | Notes |
| - | - | - |
| ERNIE-Image | `baidu/ERNIE-Image` | Regular text-to-image checkpoint |
| ERNIE-Image-Turbo | `baidu/ERNIE-Image-Turbo` | Turbo text-to-image checkpoint |

## 2. Installation

Follow the [SGLang Diffusion installation guide](/docs/sglang-diffusion/installation). Docker is recommended for Linux GPU deployments; run the commands below inside the container or your installed Python environment.

## 3. Serve the model

The commands below target a single supported NVIDIA CUDA or AMD ROCm GPU. Start with `--performance-mode auto`; use `speed` only when the full pipeline fits comfortably on the selected GPU(s), and use `memory` when you need lower peak GPU memory.

Serve ERNIE-Image:

```bash Command theme={null}
sglang serve \
  --model-path baidu/ERNIE-Image \
  --num-gpus 1 \
  --performance-mode auto \
  --port 30010
```

Serve ERNIE-Image-Turbo:

```bash Command theme={null}
sglang serve \
  --model-path baidu/ERNIE-Image-Turbo \
  --num-gpus 1 \
  --performance-mode auto \
  --port 30010
```

## 4. Generate an image

Use the OpenAI-compatible image generation API after the server starts:

```python Python theme={null}
import base64
from openai import OpenAI

client = OpenAI(api_key="EMPTY", base_url="http://127.0.0.1:30010/v1")

response = client.images.generate(
    model="baidu/ERNIE-Image-Turbo",
    prompt="A cinematic photo of a quiet lakeside cabin at sunrise",
    n=1,
    response_format="b64_json",
)

image_bytes = base64.b64decode(response.data[0].b64_json)
with open("ernie_image.png", "wb") as f:
    f.write(image_bytes)
```

## 5. Configuration tips

* ERNIE-Image is a text-to-image pipeline; do not pass `--image-path`.
* `--performance-mode auto` keeps conservative defaults while preserving explicit user flags.
* If the checkpoint includes a PE component, SGLang loads it automatically with the native Ministral3 runtime. Use `--layerwise-offload-components pe` when the local PE decoder needs to trade latency for lower GPU memory usage.
* Treat FSDP, SP/Ulysses/Ring, and TP as explicit benchmark knobs. Measure the target resolution, step count, and GPU type before making them production defaults.

## 6. Run in ComfyUI

<ComfyUISupport model="image" />


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.