ERNIE-Image Atlas Cloud API + Batch Production: Enterprise AI Image Pipeline
Baidu Atlas Cloud provides ERNIE-Image API service — build enterprise-level batch image generation pipeline.
Atlas Cloud Platform Overview
Baidu AI Cloud Atlas provides ERNIE-Image cloud API service — call without local GPU.
Core Features
| Feature | Description |
|---|---|
| Pay-per-use | Pay by generation count, no upfront cost |
| Elastic Scaling | Support high-concurrency batch generation |
| Global Acceleration | Global nodes, low latency |
| SLA Guarantee | 99.9% availability |
Access
- Console: https://console.bce.baidu.com
- API Docs: https://cloud.baidu.com/doc/ERNE.html
Basic API Call
Get API Key
- Login to Baidu AI Cloud Console
- Create application
- Get Access Key and Secret Key
Python Example
import requests
import base64
def ernie_image_api(prompt, access_key, secret_key):
url = "https://wenxin.baidu.com/v1/images/generations"
headers = {
"Authorization": f"Bearer {get_token(access_key, secret_key)}",
"Content-Type": "application/json"
}
data = {
"model": "ernie-image-8b",
"prompt": prompt,
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
image_data = base64.b64decode(result["data"][0]["b64_json"])
return image_data
def get_token(access_key, secret_key):
url = f"https://aip.baidubce.com/oauth/2.0/token"
params = {
"grant_type": "client_credentials",
"client_id": access_key,
"client_secret": secret_key
}
return requests.get(url, params=params).json()["access_token"]
Batch Production Pipeline
Architecture
CSV/JSON input → Task queue → API call → Image storage → Output
Batch Generation Script
import csv
import requests
import base64
import time
from concurrent.futures import ThreadPoolExecutor
def batch_generate(csv_file, access_key, secret_key, output_dir="./output"):
with open(csv_file, 'r', encoding='utf-8') as f:
reader = csv.DictReader(f)
tasks = list(reader)
def generate_task(task):
image_data = ernie_image_api(
task['prompt'],
access_key,
secret_key
)
import os
os.makedirs(output_dir, exist_ok=True)
filename = f"{task['id']}.png"
with open(f"{output_dir}/{filename}", 'wb') as f:
f.write(image_data)
return task['id']
with ThreadPoolExecutor(max_workers=10) as executor:
results = executor.map(generate_task, tasks)
print(f"Generated {len(list(results))} images")
CSV Input Template
id,prompt,negative_prompt,width,height
1,"a cat on a table","","1024","1024"
2,"a dog in a garden","","1024","1024"
3,"a bird in a tree","","1024","1024"
ComfyUI + API Hybrid Pipeline
Architecture
Local ComfyUI (complex tasks) ↔ Atlas API (simple tasks)
Task Routing Logic
| Task Type | Location | Reason |
|---|---|---|
| Simple generation | Atlas API | Low cost, fast |
| IP-Adapter | Local ComfyUI | Not supported by API |
| ControlNet | Local ComfyUI | Not supported by API |
| Inpainting | Local ComfyUI | Fine control |
| Batch production | Atlas API | Elastic scaling |
Enterprise Deployment Options
Option 1: Full Cloud
Advantages:
- Zero hardware cost
- Elastic scaling
- Low maintenance cost
Cost:
- API calls: $0.001/image
- Storage: $0.01/GB/month
Option 2: Hybrid Cloud
Advantages:
- Core data local
- Elastic cloud scaling
- Flexible cost control
Cost:
- Local GPU: $7-14K
- API calls: Pay-per-use
Summary
Atlas Cloud API + Batch Production key points:
- API call: Simple integration, pay-per-use
- Batch pipeline: CSV/JSON-driven + concurrent execution
- Hybrid deployment: Complex tasks local, simple tasks cloud
- Enterprise-grade: SLA guarantee + global acceleration
Master Atlas Cloud API, and ERNIE-Image becomes your enterprise AI image engine.
Based on Baidu AI Cloud Atlas + ERNIE-Image API.