Check Sume artifact size, width and duration before you download
Read size_bytes, width, height and duration_ms from the job result and reject an unexpected artifact before spending bandwidth. Node 18 TypeScript sample.

Each artifact in data.result.artifacts can carry size_bytes, width, height and duration_ms, so you can validate a render before you download it. All four are nullable integers, so treat null as unknown rather than as zero.
Fields and sensible checks
The checks are plain comparisons against limits you choose. Sume does not enforce them for you.
| Field | Nullable | Example check |
|---|---|---|
size_bytes | yes | Reject above the upload cap of your next system. |
width / height | yes | Match the aspect ratio you asked for. |
duration_ms | yes | Compare with the duration in the request. |
content_type | yes | Expect video/mp4 for a video job. |
TypeScript
This runs on Node 18 or later with the built-in fetch. Compile with any TypeScript setup or strip the types.
const base = "https://api.sume.com/v1";
const key = process.env.SUME_API_KEY;
if (!key) throw new Error("SUME_API_KEY is not set");
const headers = { "x-api-key": key };
type Artifact = {
id: string; url: string; content_type: string | null;
size_bytes: number | null; width: number | null; height: number | null; duration_ms: number | null;
};
async function main(jobId: string, maxBytes: number, expectedSeconds: number) {
const res = await fetch(`${base}/jobs/${jobId}/result`, { headers });
if (!res.ok) throw new Error(`result ${res.status}: ${await res.text()}`);
const { data } = await res.json();
for (const a of data.result.artifacts as Artifact[]) {
const problems: string[] = [];
if (a.size_bytes != null && a.size_bytes > maxBytes) problems.push(`size ${a.size_bytes}`);
if (a.duration_ms != null && Math.abs(a.duration_ms / 1000 - expectedSeconds) > 1) problems.push(`duration ${a.duration_ms}ms`);
console.log(a.id, problems.length ? `REJECT ${problems.join(", ")}` : "ok", a.width, a.height);
}
}
main(process.argv[2], 50_000_000, Number(process.argv[3])).catch((e) => { console.error(e); process.exit(1); });What not to infer
Artifact URLs sit on the Sume media CDN and are opaque. The schema says clients must not parse them, so do not read the file size or the job from the path. Use the fields above, and use the checksum after the download.
Timing
GET /v1/jobs/{id}/result returns 409 job_not_completed until the job is completed. Gate the call on the status route's terminal and result_ready flags rather than catching the 409 in a loop.
Sources
Related posts
More in Developers
- Choose an image model in code from the Sume catalog's parameters
Filter GET /v1/images/models by what a request needs (references, ratio, transparency), then rank the matches by endpoint price. Python script for Sume.
- Claude batch custom_id is 64 characters: keep SKU keys valid
Anthropic batch custom_id allows 1 to 64 letters, digits, underscore and hyphen. How to sanitize SKUs, avoid collisions and carry the key into Sume input.
- Claude Code 2.1.285 lists WebSocket MCP servers; Sume uses HTTP
Claude Code 2.1.285 shows WebSocket MCP servers in claude mcp list. Sume's hosted MCP is a remote HTTP server, added with --transport http.
- MCP error text showed a Bearer token: rotate the Sume API key
Claude Code 2.1.286 masks credentials after Bearer or Basic in MCP errors. If an old log shows a Sume key, replace it and keep keys out of logs.
Written by Sume