Worlds
準備媒體資產上傳
建立 World Labs 媒體資產上傳目標
建立 World Labs 媒體資產記錄,並取得圖片或影片的上傳 URL。將二進位檔案上傳到 upload_info.upload_url 後,可在 world_prompt 中透過 source: "media_asset" 引用返回的 media_asset.media_asset_id。
TokenLab 會記錄資產歸屬。只有同一組織可以取得或在 World 生成中使用該媒體資產。
請求體
file_namestring必填
原始檔名,最多 64 個字元。
kindstring必填
媒體類型:image 或 video。
extensionstring | null
可選副檔名,例如 png、jpg 或 mp4。
metadataobject | null
隨上游媒體資產保存的可選中繼資料物件。
回應
media_assetobject
已準備好的 World Labs 媒體資產中繼資料。
upload_info.upload_urlstring
用於上傳二進位檔案的上游簽名 URL。
upload_info.upload_methodstring
將二進位檔案上傳至 upload_info.upload_url 時使用的 HTTP 方法(如有回傳)。
upload_info.required_headersobject
上傳二進位檔案時須附帶的請求標頭(如有回傳)。
請求
curl -X POST "https://api.tokenlab.sh/v1/worlds/media-assets/prepare-upload" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"file_name": "reference.png",
"kind": "image",
"extension": "png"
}'{ "media_asset": { "created_at": "2019-08-24T14:15:22Z", "file_name": "string", "kind": "image", "media_asset_id": "string", "extension": "string", "metadata": {}, "updated_at": "2019-08-24T14:15:22Z" }, "upload_info": { "upload_method": "string", "upload_url": "http://example.com", "curl_example": "string", "required_headers": { "property1": "string", "property2": "string" } }}授權
BearerAuth AuthorizationBearer <token>
API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。
位置: header
請求主體
application/json
回應
application/json
application/json