docs_new/cookbook/diffusion/Ernie-Image/Ernie-Image.mdx
ERNIE-Image is Baidu's text-to-image diffusion model family. SGLang Diffusion supports both the regular and Turbo checkpoints with the native ErnieImagePipeline.
| 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 |
Install SGLang with the diffusion dependencies:
pip install -e "python[diffusion]"
For full installation options, see the SGLang Diffusion installation guide.
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:
sglang serve \
--model-path baidu/ERNIE-Image \
--num-gpus 1 \
--performance-mode auto \
--port 30010
Serve ERNIE-Image-Turbo:
sglang serve \
--model-path baidu/ERNIE-Image-Turbo \
--num-gpus 1 \
--performance-mode auto \
--port 30010
Use the OpenAI-compatible image generation API after the server starts:
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)
--image-path.--performance-mode auto keeps conservative defaults while preserving explicit user flags.model_index.json.