跳轉到主要內容

Documentation Index

Fetch the complete documentation index at: https://docs.tokenlab.sh/llms.txt

Use this file to discover all available pages before exploring further.

概述

建立給定圖像的變體。需要 multipart/form-data 內容類型。

請求主體

同步請求逾時: 某些路由到的圖片提供者會以内嵌方式返回最終圖片,並等待生成完成。高解析度或高品質請求可能接近一分鐘甚至更久,因此請將 HTTP 用戶端逾時設定為至少 120s。如果建立回應包含 status: "pending"task_idpoll_url,請改為依照返回的 poll_url 輪詢。
image
file
必填
用作變體基礎的圖像。必須是有效的 PNG 檔案,小於 50MB,且為正方形。
model
string
預設值:"dall-e-2"
用於圖像變體的模型。目前僅支援 dall-e-2
n
integer
預設值:"1"
要生成的圖像數量。必須在 1 到 10 之間。
size
string
生成圖像的尺寸。必須是 256x256512x5121024x1024 之一。
response_format
string
預設值:"url"
回傳生成圖像的格式。必須是 urlb64_json
user
string
代表終端使用者的唯一識別碼,用於濫用監控。

回應

created
integer
圖像建立時間的 Unix 時間戳。
data
array
生成的圖像變體陣列。每個物件包含:
  • url (string): 變體圖像的 URL(如果 response_format 是 url
  • b64_json (string): Base64 編碼的圖像(如果 response_format 是 b64_json
curl -X POST "https://api.tokenlab.sh/v1/images/variations" \
  -H "Authorization: Bearer sk-your-api-key" \
  -F "image=@cat.png" \
  -F "n=2" \
  -F "size=1024x1024"
{
  "created": 1706000000,
  "data": [
    {
      "url": "https://..."
    },
    {
      "url": "https://..."
    }
  ]
}

注意事項

圖像變體僅適用於 DALL-E 2。模型將生成與原始圖像在風格和內容上相似的新圖像。