Worlds
Prepare Media Asset Upload
Creates a World Labs media asset upload target
Create a World Labs media asset record and receive an upload URL for an image or video. Upload the binary file to upload_info.upload_url, then reference the returned media_asset.media_asset_id from world_prompt with source: "media_asset".
The asset is available only in the Workspace that created it.
{
"model": "marble-1.1",
"world_prompt": {
"type": "image",
"image_prompt": { "source": "media_asset", "media_asset_id": "<media_asset.media_asset_id>" }
}
}Send this body to Create World. A media_asset_id that belongs to another Workspace returns 403 media_asset_not_owned; an unknown one returns 404 media_asset_not_found.
Request Body
Original file name, up to 64 characters, for example reference.png.
Media type: image or video.
Optional extension such as png, jpg, or mp4.
Custom metadata stored with the asset.
Response
Prepared media asset metadata: media_asset_id, file_name, kind, extension, metadata, created_at, and updated_at.
Signed URL for uploading the file.
HTTP method to use when uploading the binary file to upload_info.upload_url, when returned.
Headers to include with the binary upload, when returned.
Request
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" } }}Authorization
BearerAuth API Key authentication. Create or manage API keys in Dashboard > API > API Keys.
In: header
Request Body
application/json
Response
application/json
application/json