跳至主要內容

Sprite Zenith

用途​

使用 Zenith 流程生成精靈動畫。此功能與網頁應用程式「Sprite Zenith」頁面相同,並支援其三種模式:

mode網頁分頁輸入
image_to_video單張圖片一張圖片
first_last_frame開始/結束參考圖片兩張圖片:依序為起始幀與結束參考圖片
video_restyleSprite To Sprite一個現有精靈(PNG 精靈圖表 + 網格,或 GIF)以及可選的參考圖片

代幣消耗: 9(36 幀)、25(100 幀)

方法與路徑​

POST /public/v1/sprite/zenith

認證​

請參閱認證頁面。需要 Bearer Token。

必要標頭:

Authorization: Bearer {your_api_key}

請求欄位​

請以 multipart/form-data 傳送請求。每個檔案重複一次 images 欄位。

欄位名稱類型必填預設值說明
modestring是允許的值:image_to_video、first_last_frame、video_restyle
imagesfile[]是image_to_video:恰好 1 個 PNG/JPEG。first_last_frame:恰好 2 個 PNG/JPEG(起始、結束)。video_restyle:恰好 1 個來源,PNG 精靈圖表或 GIF
textstring是,除非提供參考圖片""描述動作的提示詞。會移除前後空白。在 video_restyle 中,僅當提供 reference_image 時才可為空
frameinteger圖片模式為必填幀數。允許的值:36、100。在 video_restyle 中必須省略(由來源推導,見下方)
is_pixelboolean否false像素風。如果附加圖片本身是像素風,請開啟此選項。在 video_restyle 中會被忽略(強制為 false)
is_prompt_enhancementboolean否true提示詞優化。根據你輸入的內容,將提示詞優化為更適合生成精靈的形式。在 video_restyle 中會被忽略(強制為 false)
reference_imagefile否(僅限 video_restyle)參考圖片(選填)。僅限 PNG。來源精靈的主體會被替換為此圖片
sprite_gridstring使用 PNG 圖表的 video_restyle描述 PNG 圖表如何切割的 JSON 物件,例如 {"columns": 6, "rows": 6}。每個值為 1–32,最多 120 幀。不可與 GIF 來源一起使用
background_colorstring否更換背景(網頁中的「更換背景」)。允許的值:chroma_green、magenta、transparent。chroma_green、magenta:生成前將輸入圖片的背景替換為該顏色。transparent:產生的圖表與 GIF 背景為透明。省略時保留原背景(網頁中的「預設背景」)。在 video_restyle 中僅套用於 reference_image,因此必須提供 reference_image,且不可使用 transparent。不額外消耗代幣

Sprite To Sprite(video_restyle)規則​

  • 來源檔案: PNG 精靈圖表(需傳送 sprite_grid)或 GIF(不傳送 sprite_grid)。GIF 最多 120 幀,且長度最多 10 秒。
  • 幀數由來源推導,與網頁應用程式完全相同:來源長度超過 5 秒時產生 100 幀(25 代幣),否則產生 36 幀(9 代幣)。GIF 使用其實際播放長度;含 N 幀的 PNG 圖表計為 round(N × 3000 / 36) 毫秒,因此 61 幀以上會使用 100 幀層級。
  • 必須提供 text 或 reference_image(或兩者皆提供)。
  • 上傳來源的副檔名取自其內容,因此即使檔名沒有副檔名也能偵測到 GIF。

回應​

成功回應 (200 OK):

{
"job_id": "uuid-string"
}
欄位類型說明
job_idstring已建立作業的唯一識別碼。請使用取得作業狀態查詢結果

錯誤 / 驗證規則​

情況HTTP 狀態錯誤訊息
檔案不是有效的圖片或格式不被允許400"Invalid image file"
frame 遺漏或不允許(圖片模式)400"frame should be one of 36, 100"
在 video_restyle 中傳送了 frame400"frame is derived from the source for video_restyle; do not send it"
該模式的圖片數量錯誤400"image_to_video requires exactly one image" / "first_last_frame requires exactly two images (start, end)" / "video_restyle requires exactly one source image (PNG sprite sheet or GIF)"
text 為空(圖片模式)400"text must not be empty"
text 為空且沒有參考圖片(video_restyle)400"video_restyle requires text when no reference_image is given"
在 video_restyle 以外傳送了 reference_image 或 sprite_grid400"reference_image is only supported for video_restyle" / "sprite_grid is only supported for video_restyle"
PNG 圖表未附 sprite_grid400"sprite_grid is required for a PNG sprite sheet"
GIF 附帶 sprite_grid400"sprite_grid is not allowed for a GIF source"
sprite_grid 格式錯誤或超出範圍400sprite_grid must be a JSON object like {"columns": 6, "rows": 6} (1-32 each, at most 120 frames)
GIF 超過 120 幀400"GIF must have at most 120 frames"
GIF 長度超過 10 秒400"GIF must be at most 10 seconds long"
在 video_restyle 中指定 background_color 但未提供 reference_image400"background_color requires reference_image for video_restyle"
在 video_restyle 中 background_color 為 transparent400"transparent background is not supported for video_restyle"
無效的 API 金鑰401"Invalid API key"
欄位遺漏、未知的 mode 或 background_color422Validation error

所有驗證都會在上傳任何檔案之前執行。

非同步作業行為​

此端點會建立非同步作業。它會立即回傳 job_id,實際的精靈生成會在背景進行。

輪詢方法:

  1. 儲存回應中收到的 job_id
  2. 輪詢 GET /public/v1/job/{job_id} 確認狀態
  3. 當狀態變為 Succeed 時,於 image_urls 查看結果(精靈圖表與 GIF)

狀態流程: Pending → Succeed 或 Failed

請求範例​

cURL (單張圖片):

curl -X POST "https://api.aetherforgeai.com/public/v1/sprite/zenith" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "mode=image_to_video" \
-F "images=@/path/to/character.png" \
-F "text=running animation cycle" \
-F "frame=36" \
-F "is_pixel=true"

cURL (開始/結束參考圖片):

curl -X POST "https://api.aetherforgeai.com/public/v1/sprite/zenith" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "mode=first_last_frame" \
-F "images=@/path/to/start.png" \
-F "images=@/path/to/end.png" \
-F "text=turn around" \
-F "frame=100"

cURL (Sprite To Sprite,PNG 圖表附網格與參考圖片):

curl -X POST "https://api.aetherforgeai.com/public/v1/sprite/zenith" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "mode=video_restyle" \
-F "images=@/path/to/sprite_sheet.png" \
-F 'sprite_grid={"columns": 6, "rows": 6}' \
-F "reference_image=@/path/to/new_character.png"

cURL (Sprite To Sprite,GIF 附提示詞):

curl -X POST "https://api.aetherforgeai.com/public/v1/sprite/zenith" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "mode=video_restyle" \
-F "images=@/path/to/sprite.gif" \
-F "text=a knight in silver armor"

cURL (單張圖片,透明背景):

curl -X POST "https://api.aetherforgeai.com/public/v1/sprite/zenith" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "mode=image_to_video" \
-F "images=@/path/to/character.png" \
-F "text=running animation cycle" \
-F "frame=36" \
-F "background_color=transparent"