MATLAB webwrite and weboptions: generate an AI video and save the MP4
A MATLAB script posts a Wan 3.0 job to Sume with webwrite, polls the job status with webread and saves the finished clip with websave.

In MATLAB, three built-ins cover the whole flow: webwrite to submit a job, webread to poll it, and websave to download the result, each with a weboptions object that carries the Authorization header. Sume answers POST /v1/videos with a job id; you read GET /v1/jobs/{id}/status until terminal is true and then fetch /v1/videos/{id}/content?index=0 (Sume jobs guide, read 2026-10-06).
Researchers use this to make a short illustrative clip from a script without leaving the Live Editor. The example is wan-3.0, 5 seconds, 720p: $0.625 at $0.125 per second.
What is the script?
Set the SUME_API_KEY environment variable before starting MATLAB. With MediaType set to application/json, webwrite encodes the struct as a JSON body.
key = getenv('SUME_API_KEY');
assert(~isempty(key), 'SUME_API_KEY is empty');
base = 'https://api.sume.com';
auth = {'Authorization', ['Bearer ' key]};
postOpts = weboptions('MediaType', 'application/json', 'Timeout', 30, ...
'HeaderFields', [auth; {'Idempotency-Key', 'matlab-fog-001'}]);
job = webwrite([base '/v1/videos'], struct( ...
'model', 'wan-3.0', 'prompt', 'Fog drifting over a lab bench', ...
'duration', 5, 'resolution', '720p'), postOpts);
getOpts = weboptions('HeaderFields', auth, 'Timeout', 30);
for k = 1:120
pause(15);
s = webread([base '/v1/jobs/' job.id '/status'], getOpts);
if s.terminal, break; end
end
assert(strcmp(s.sume_status, 'completed'), 'job ended as %s', s.sume_status);
websave('clip.mp4', [base '/v1/videos/' job.id '/content?index=0'], getOpts);What does each resolution cost?
| Resolution | Per second | 5-second clip |
|---|---|---|
| 480p | $0.0625 | $0.3125 |
| 720p | $0.125 | $0.625 |
| 1080p | $0.25 | $1.25 |
Does re-running the script bill a second clip?
It can if you re-run the submit step. Send a stable Idempotency-Key on POST /v1/videos (here a fixed string; in practice a row id) so a repeat returns the original job. A give-up on the client never cancels the render, so keep the job id and read it again (Sume jobs guide, read 2026-10-06).
Sources
Related posts
More in Developers
- mcp_health, health_service or health_v1: which Sume ping to call
Three read-only Sume checks answer three questions: mcp_health for your session and tools, health_v1 for the /v1 API path, health_service for plain liveness.
- Sume MCP OAuth: the consent page is on mcp.sume.com, not app
A Sume MCP client OAuth flow goes /oauth/authorize then /oauth/consent on the MCP host. Do not send users to app.sume.com; here is what the flow checks.
- MiniMax H3 on Sume: 9 images, 3 videos, 3 audio, 12 in total check
On Sume, minimax-h3 and minimax-h3-max take at most 9 reference images, 3 videos and 3 audio clips, 12 in all, and audio cannot be alone. Check it in Python.
- Music-only Short: Timeline silence mode with a soundtrack bed
Build a Short with no voice: audio mode silence plus a soundtrack. The bed plays alone at the default -16 dB with no amix loss. Fields, limits, tail rule.
Written by Sume