圖片生成

概覽

Atlas Cloud 透過統一 API 提供多種 AI 圖片生成模型的存取。從文字提示生成精美圖片、轉換現有圖片、移除背景、替換人臉等——只需一次 API 呼叫。

支援的模型類型

類型說明使用場景
文字轉圖片從文字描述生成圖片創意內容、行銷、設計、原型製作
圖片轉圖片轉換和增強現有圖片風格轉換、修復、外擴
圖片工具進階圖片處理和操作背景移除、人臉替換、放大、修復

精選模型

模型供應商特點
SeedreamByteDance高品質文字轉圖片,出色的提示詞遵循能力
FLUXBlack Forest Labs快速、高保真圖片生成,提供多個變體(Dev、Schnell、Pro)
Qwen-ImageAlibaba強大的多語言圖片生成
IdeogramIdeogram出色的圖片文字渲染能力
HiDreamHiDream創意和藝術風格圖片生成
DALL-EOpenAI多功能圖片生成和編輯
ImagenGoogleGoogle 最先進的圖片生成

如需所有圖片模型的完整列表和規格,請造訪模型庫

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(Low-Rank Adaptation)模型來增強圖片生成,實現自訂風格和精細控制。詳見 LoRA 指南了解如何在 Atlas Cloud 中尋找、選擇和使用 LoRA 模型。

獲得更好結果的技巧

  • 具體描述:在提示詞中描述風格、構圖、光線和氛圍
  • 使用負面提示詞:指定圖片中不希望出現的內容(如模型支援)
  • 嘗試不同模型:不同模型擅長不同風格——寫實、動漫、藝術等
  • 調整參數:每個模型有獨特的參數。在模型庫查看模型詳情頁面了解可用選項
  • 使用種子值:設定 seed 以在迭代提示詞時獲得可重現的結果

業界領先的速度

Atlas Cloud 最佳化的推理基礎架構提供快速的圖片生成速度——大多數模型不到 5 秒。結合具競爭力的定價,非常適合原型設計和生產工作負載。

完整的 API 規格和模型專屬參數,請參閱 API 參考