自訂範本 API
把一組剪輯設定存成範本,再在 AI 剪輯 或 片段匯出 傳入 custom_template_id,一次套用整組設定。
範本可以包含畫幅與版面、字幕樣式、表情、B-roll、AI Hook、人聲增強、去口癖、去靜音、片頭、片尾與 Logo。
範本與網站上的 My Template 是同一份資料。在網站建立的範本,這裡可以查到;在這裡建立的範本,也會出現在網站上。
套餐限制
| 套餐 | 可保存範本數 |
|---|---|
| Free | 不可用 |
| Starter | 1 |
| Pro | 3 |
| Scale | 10。購買 2 份及以上時,上限提高到 20。 |
上傳 Logo、片頭或片尾也需要付費套餐,並佔用儲存空間。參見 訂閱計劃。
使用流程
- 上傳素材只在範本需要 Logo、片頭或片尾時才做。字幕、畫幅和其他設定不需要上傳。
- 建立範本。平台會依你選擇的位置擺放 Logo、片頭和片尾。不要傳座標。
- 需要目前設定時,列出或讀取範本。
- 在
POST /api/v2/clips或POST /api/v2/clips/export傳入custom_template_id來套用範本。 - 更新會整份覆蓋。請求裡沒寫的能力會從範本中移除。先讀取目前範本,改完後再提交完整設定。
- 不再需要時刪除範本。
端點
| 方法 | 路徑 | 說明 |
|---|---|---|
POST | /api/v2/upload/single-file | 取得 Logo、片頭或片尾的上傳網址 |
POST | /api/v2/upload/status | 輪詢直到檔案可用 |
POST | /api/v2/custom-templates | 建立範本 |
GET | /api/v2/custom-templates | 列出範本 |
GET | /api/v2/custom-templates/{id} | 讀取單一範本 |
PUT | /api/v2/custom-templates/{id} | 整份覆蓋範本 |
DELETE | /api/v2/custom-templates/{id} | 刪除範本 |
所有請求都需要:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
x-wayinvideo-api-version: v2
GET 與 DELETE 不需要 Content-Type。
上傳 Logo、片頭或片尾
先取得預簽名網址,把檔案 PUT 上去,再輪詢到 status 為 DONE。把回傳的 identity 填到範本的 resource.identify。
範本不用 Logo、片頭或片尾時,跳過這一步。一般影片上傳見 上傳 API。
POST https://wayinvideo-api.wayin.ai/api/v2/upload/single-file
請求本體
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
name | string | 是 | 帶副檔名的檔名。副檔名用來檢查格式。 |
size | integer | 否 | 檔案大小,單位為位元組。建議傳入,以便檢查大小上限與儲存額度。 |
resource_type | string | 範本素材必填 | 檔案用途。見下表。省略時會當成一般影片,不能用在範本裡。 |
resource_type | 用於 | 格式 | 大小上限 | 時長上限 |
|---|---|---|---|---|
BRAND_KIT_LOGO | logo | .jpg、.jpeg、.png、.webp | 10 MB | — |
BRAND_KIT_VIDEO | intro、outro | .mp4、.mov、.webm、.avi | 5 GB | 60 分鐘 |
請求範例
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/upload/single-file \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2" \
-d '{
"name": "brand-logo.png",
"size": 204800,
"resource_type": "BRAND_KIT_LOGO"
}'
回應
{
"data": {
"upload_url": "https://storage.example.com/upload/presigned-url...",
"identity": "EF_up_06wguq1afbwg1"
}
}
| 欄位 | 類型 | 說明 |
|---|---|---|
upload_url | string | 預簽名上傳網址。會過期,請在取得後盡快上傳。 |
identity | string | 檔案 ID。建立或更新範本時,填入 resource.identify。 |
上傳檔案
curl -X PUT "https://storage.example.com/upload/presigned-url..." \
--upload-file ./brand-logo.png
HTTP 200 表示檔案已收到。平台接著處理檔案。請輪詢狀態,直到處理完成。
查詢上傳狀態
每 3 到 5 秒輪詢一次,直到 status 為 DONE 或 ERROR。只有 status 為 DONE 的檔案可以放進範本。
POST https://wayinvideo-api.wayin.ai/api/v2/upload/status
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
identify | string | 是 | 取得上傳網址時回傳的 identity。 |
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/upload/status \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2" \
-d '{
"identify": "EF_up_06wguq1afbwg1"
}'
{
"data": {
"status": "DONE",
"file_name": "brand-logo.png",
"url": "https://cdn.example.com/user/brand-logo.png"
}
}
| 欄位 | 類型 | 說明 |
|---|---|---|
status | string | START:尚未收到檔案,請確認 PUT 已成功。UPLOADED:已收到檔案,仍在處理。DONE:可以使用。ERROR:處理失敗,請重新上傳。 |
file_name | string | 檔名。 |
url | string | 檔案網址。 |
建立範本
POST https://wayinvideo-api.wayin.ai/api/v2/custom-templates
請求本體
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
name | string | 是 | 範本名稱,不能為空。 |
config | object | 是 | 要保存的能力。每個 key 是一項能力。見 設定欄位。可以是 {},不能是 null。只要還傳了其他能力,reframe 就必填。 |
config 裡寫了的能力,套用時會覆蓋 AI 剪輯 上的對應參數。沒寫的能力,沿用該次剪輯或匯出請求裡的值。
請求範例
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/custom-templates \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2" \
-d '{
"name": "Brand A - Shorts",
"config": {
"reframe": {
"ratio": "RATIO_9_16",
"layout_type": "Fit",
"auto_reframe": true
},
"caption_style": {
"mode": "on",
"template_id": "word-focus"
},
"emoji": { "operation": "add" },
"broll": {
"operation": "add",
"resource_type": "RESOURCE_VIDEO_STOCK_BROLL"
},
"ai_hook": {
"operation": "add",
"template_id": "preset-1",
"script_style": "casual",
"position": "beginning"
},
"speech_enhance": { "operation": "clean" },
"remove_filter": { "operation": "remove" },
"remove_silence": {
"operation": "remove",
"silence_duration_ms": 500
},
"intro": {
"operation": "add",
"resource": { "identify": "EF_up_06wgintro0001" }
},
"outro": {
"operation": "add",
"resource": { "identify": "EF_up_06wgoutro0001" }
},
"logo": {
"operation": "add",
"items": [
{
"resource": { "identify": "EF_up_06wguq1afbwg1" },
"position": "top_right"
}
]
}
}
}'
回應
回應是已保存的範本,結構與 讀取範本 相同。
{
"data": {
"id": "uctmpl06yf2m0m1b0pv",
"name": "Brand A - Shorts",
"config": {
"reframe": {
"ratio": "RATIO_9_16",
"layout_type": "Fit",
"auto_reframe": true
}
},
"created": 1764057600000,
"last_modified": 1764057600000
}
}
列出範本
回傳目前帳號或工作區下的全部範本,最新的在前。沒有範本時 data 為 []。
GET https://wayinvideo-api.wayin.ai/api/v2/custom-templates
請求範例
curl -X GET https://wayinvideo-api.wayin.ai/api/v2/custom-templates \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2"
回應範例
{
"data": [
{
"id": "uctmpl06yf2m0m1b0pv",
"name": "Brand A - Shorts",
"config": {
"reframe": {
"ratio": "RATIO_9_16",
"layout_type": "Fit",
"auto_reframe": true
}
},
"created": 1764057600000,
"last_modified": 1764144000000
}
]
}
| 欄位 | 類型 | 說明 |
|---|---|---|
id | string | 範本 ID,以 uctmpl 開頭。 |
name | string | 範本名稱。 |
config | object | 已保存的設定。見 讀取範本。 |
created | integer | 建立時間,毫秒 Unix 時間戳。 |
last_modified | integer | 最後修改時間,毫秒 Unix 時間戳。 |
讀取範本
GET https://wayinvideo-api.wayin.ai/api/v2/custom-templates/{id}
路徑參數
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
id | string | 是 | 建立或列出時回傳的範本 ID。 |
請求範例
curl -X GET https://wayinvideo-api.wayin.ai/api/v2/custom-templates/uctmpl06yf2m0m1b0pv \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2"
回應範例
{
"data": {
"id": "uctmpl06yf2m0m1b0pv",
"name": "Brand A - Shorts",
"config": {
"reframe": {
"ratio": "RATIO_9_16",
"layout_type": "Fit",
"auto_reframe": true
},
"caption_style": {
"mode": "on",
"template_id": "word-focus"
},
"intro": {
"operation": "add",
"resource": {
"identify": "EF_up_06wgintro0001",
"url": "https://cdn.example.com/user/intro.mp4",
"name": "intro"
}
},
"logo": {
"operation": "add",
"items": [
{
"resource": {
"identify": "EF_up_06wguq1afbwg1",
"url": "https://cdn.example.com/user/brand-logo.png",
"name": "brand-logo"
},
"position": "top_right"
}
]
}
},
"created": 1764057600000,
"last_modified": 1764144000000
}
}
| 欄位 | 類型 | 說明 |
|---|---|---|
id | string | 範本 ID。 |
name | string | 範本名稱。 |
config | object | 範本設定。除了本頁列出的欄位,config 還可能帶有 transform、operation、extra 等內部欄位。更新時可以原樣帶回。帶回的 transform 會直接沿用。如果某個 Logo 同時帶了 position,該項的 transform 會被捨棄,並依 position 重新計算位置。素材物件可能帶有 url 與 name。平台只讀取 identify。 |
created | integer | 建立時間,毫秒 Unix 時間戳。 |
last_modified | integer | 最後修改時間,毫秒 Unix 時間戳。 |
在網站上拖曳擺放的 Logo 沒有 position,該項只有 transform。原樣帶回會保持原來的位置。補上 position 則會按新位置重新擺放。
更新範本
用請求裡的 name 和 config 替換整個範本。config 裡沒寫的能力會被移除,不是局部更新。Logo、片頭和片尾會依新設定重新計算位置。
先用 讀取範本 拿到目前物件,改完後提交完整請求本體。
PUT https://wayinvideo-api.wayin.ai/api/v2/custom-templates/{id}
請求本體與 建立範本 相同。name 和 config 都必填。
請求範例
這個例子保留畫幅、字幕和 Logo,並把 Logo 移到右下角。先前保存的片頭不在這份請求裡,因此會被移除。
curl -X PUT https://wayinvideo-api.wayin.ai/api/v2/custom-templates/uctmpl06yf2m0m1b0pv \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2" \
-d '{
"name": "Brand A - Shorts v2",
"config": {
"reframe": {
"ratio": "RATIO_9_16",
"layout_type": "Fit",
"auto_reframe": true
},
"caption_style": {
"mode": "on",
"template_id": "word-focus"
},
"logo": {
"operation": "add",
"items": [
{
"resource": { "identify": "EF_up_06wguq1afbwg1" },
"position": "bottom_right"
}
]
}
}
}'
回應
更新後的範本,結構與 讀取範本 相同。
刪除範本
DELETE https://wayinvideo-api.wayin.ai/api/v2/custom-templates/{id}
刪除後不能恢復。之後再用這個 ID 讀取或套用,都會因為範本不存在而失敗。已經用這個範本生成或匯出的片段不受影響。範本引用的檔案不會被刪除。
請求範例
curl -X DELETE https://wayinvideo-api.wayin.ai/api/v2/custom-templates/uctmpl06yf2m0m1b0pv \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2"
回應
{
"data": null
}
套用範本
在 JSON 請求本體裡加上 custom_template_id。
在 AI 剪輯 中,只有 enable_export 為 true 時才會使用 custom_template_id。在 片段匯出 中,匯出請求本身就是算圖,因此只要傳了這個 ID 就會套用。
{
"video_url": "https://www.youtube.com/watch?v=example",
"target_lang": "en",
"enable_export": true,
"custom_template_id": "uctmpl06yf2m0m1b0pv"
}
| 情況 | 結果 |
|---|---|
| 範本和請求都設定了同一項能力 | 以範本為準。例如範本的 caption_style 會覆蓋請求裡的 cc_style_tpl。 |
| 請求設定了範本沒有的能力 | 使用請求裡的值。 |
| 範本設定了請求沒有的能力 | 使用範本裡的值。 |
範本在任務提交當下讀取。之後再修改或刪除範本,不會影響已經提交的任務。
設定欄位
每個 key 是一項能力。不需要的能力不要寫。reframe 必填。
reframe
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
ratio | string | 是 | RATIO_16_9、RATIO_1_1、RATIO_4_5、RATIO_9_16。 |
layout_type | string | 是 | 版面。允許值隨 ratio 改變。名稱必須完全一致,包含空格。 |
auto_reframe | boolean | 否 | 開啟 AI 主體跟隨。 |
ratio | 允許的 layout_type |
|---|---|
RATIO_16_9 | Auto、Full、Fit、Grid 4、Split 2、Trio、PiP、OTS、Screen First |
RATIO_9_16 | Auto、Full、Fit、Grid 4、Split 2、Trio、PiP、Screen First、Gameplay A、Gameplay B |
RATIO_4_5 | Auto、Full、Fit、Grid 4、Split 2、Trio、PiP、Screen First、Gameplay A、Gameplay B |
RATIO_1_1 | Auto、Full、Fit、Grid 4、Trio |
caption_style
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
mode | string | 是 | on 顯示字幕。off 不顯示字幕。inherit 把字幕留給剪輯或匯出請求。 |
template_id | string | mode 為 on 時必填 | 系統模板 ID。見 字幕樣式。 |
emoji
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | add 自動加入表情。remove 不加入表情。 |
broll
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | add 加入 B-roll。remove 不加入 B-roll,匯出時也會去掉已有的 B-roll。 |
resource_type | string | 否 | RESOURCE_VIDEO_AI_BROLL 由 AI 生成。RESOURCE_VIDEO_STOCK_BROLL 使用素材庫。 |
ai_hook
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | add 加入 AI Hook。remove 不加入,匯出時也會去掉已有的 Hook。為 remove 時不需要其他欄位。 |
template_id | string | operation 為 add 時必填 | 系統模板 ID。見 Hook 文字樣式。 |
script_style | string | 否 | 文案風格。預設 serious。允許值:serious、casual、informative、conversational、humorous、parody、inspirational、dramatic、empathetic、persuasive、neutral、excited、calm。 |
position | string | 否 | beginning 或 end。預設 beginning。 |
keywords | string | 否 | 希望 Hook 圍繞的關鍵字。 |
text_duration | integer | 否 | Hook 文字停留時間,單位為毫秒。 |
speech_enhance
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | clean 開啟人聲增強與降噪。restore 保留原聲。 |
remove_filter
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | remove 去掉 "um"、"uh" 這類口頭語。restore 保留。 |
remove_silence
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | remove 去掉靜音段。restore 保留。 |
silence_duration_ms | integer | 否 | 超過多長的靜音才去掉,單位為毫秒。預設 500。 |
intro 與 outro
兩個物件的欄位相同。片頭加在每個片段開頭,片尾加在結尾,並按範本畫幅適配。
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | add 加入素材。remove 在套用時去掉已有的片頭或片尾。為 remove 時不需要其他欄位。 |
resource.identify | string | operation 為 add 時必填 | 上傳步驟回傳的 identity。上傳時 resource_type 必須是 BRAND_KIT_VIDEO。 |
logo
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
operation | string | 是 | add 加入 Logo。remove 在套用時去掉已有的 Logo。為 remove 時不需要 items。 |
items | array | operation 為 add 時必填 | Logo 列表,至少 1 個。 |
items[].resource.identify | string | operation 為 add 時必填 | 上傳步驟回傳的 identity。上傳時 resource_type 必須是 BRAND_KIT_LOGO。 |
items[].position | string | 是 | top_left、top_right、center、bottom_left、bottom_right。更新時如果帶回詳情裡的 transform,可以不傳 position,以保持原來的位置。傳了 position 則重新擺放。 |
Logo 的大小與邊距使用平台預設值。