图像生成
概述
Atlas Cloud 通过统一的 API 提供对各类 AI 图像生成模型的访问。从文本提示生成精美图片、变换现有图像、移除背景、换脸等——只需一次 API 调用即可完成。
支持的模型类型
| 类型 | 描述 | 用例 |
|---|---|---|
| 文生图 | 从文本描述生成图像 | 创意内容、营销素材、设计、原型制作 |
| 图生图 | 变换和增强现有图像 | 风格迁移、修复、扩展 |
| 图像工具 | 高级图像处理和编辑 | 背景移除、换脸、放大、修复 |
精选模型
| 模型 | 供应商 | 亮点 |
|---|---|---|
| Seedream | ByteDance | 高质量文生图,提示词遵循度出色 |
| FLUX | Black Forest Labs | 快速、高保真图像生成,提供多个变体(Dev、Schnell、Pro) |
| Qwen-Image | 阿里巴巴 | 强大的多语言图像生成 |
| Ideogram | Ideogram | 出色的图像内文字渲染能力 |
| HiDream | HiDream | 创意和艺术风格图像生成 |
有关所有图像模型及其规格的完整列表,请访问模型库。
API 使用
文生图
import requests
response = requests.post(
"https://api.atlascloud.ai/api/v1/model/generateImage",
headers={
"Authorization": "Bearer your-api-key",
"Content-Type": "application/json"
},
json={
"model": "seedream-3.0",
"prompt": "A serene Japanese garden with cherry blossoms, watercolor style"
}
)
result = response.json()
prediction_id = result["data"]["id"]
print(f"Prediction ID: {prediction_id}")Node.js 示例
const response = await fetch(
"https://api.atlascloud.ai/api/v1/model/generateImage",
{
method: "POST",
headers: {
Authorization: "Bearer your-api-key",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "seedream-3.0",
prompt:
"A serene Japanese garden with cherry blossoms, watercolor style",
}),
}
);
const data = await response.json();
const predictionId = data.data.id;
console.log(`Prediction ID: ${predictionId}`);cURL 示例
curl -X POST https://api.atlascloud.ai/api/v1/model/generateImage \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-3.0",
"prompt": "A serene Japanese garden with cherry blossoms, watercolor style"
}'获取图像结果
图像生成是异步的。使用 prediction ID 获取结果:
import requests
import time
def get_image_result(prediction_id, api_key):
while True:
response = requests.get(
f"https://api.atlascloud.ai/api/v1/model/prediction/{prediction_id}",
headers={"Authorization": f"Bearer {api_key}"}
)
result = response.json()
if result["data"]["status"] == "completed":
return result["data"]["outputs"][0]
elif result["data"]["status"] == "failed":
raise Exception(f"Generation failed: {result['data'].get('error')}")
time.sleep(2) # 每 2 秒轮询一次
image_url = get_image_result(prediction_id, "your-api-key")
print(f"Image URL: {image_url}")使用 LoRA 模型
你可以使用 LoRA(低秩自适应)模型来增强图像生成,实现自定义风格和精细控制。详细的查找、选择和使用 LoRA 模型的说明请参阅 LoRA 指南。
获得更好效果的技巧
- 描述具体:在提示词中描述风格、构图、光线和氛围
- 使用否定提示词:指定你不希望出现在图像中的内容(如果模型支持)
- 尝试不同模型:不同模型擅长不同风格——写实、动漫、艺术等
- 调整参数:每个模型有独特的参数。在模型库的模型详情页查看可用选项
- 使用种子值:设置 seed 以在迭代提示词时获得可复现的结果
行业领先的速度
Atlas Cloud 优化的推理基础设施提供快速的图像生成速度——大多数模型在 5 秒以内完成。结合极具竞争力的定价,非常适合原型制作和生产工作负载。
完整的 API 规范和模型特定参数请参阅 API 参考。