C with libcurl: POST /v1/images on Sume and read the status code
A 29-line C program that posts to Sume's image API with libcurl, prints the JSON body, and exits non-zero unless the status is 200 or 202.

libcurl is the right tool when you embed an image call in a native program or a build step.
The request is the same in every language: POST https://api.sume.com/v1/images with a bearer key from SUME_API_KEY, a JSON body with model, prompt and aspect_ratio, and a client timeout above the route's 30-second wait. The route defaults to mode: "sync", so the status code decides what you do next (docs read 2026-10-07):
Status codes to branch on
| Status | Meaning | What the code below does |
|---|---|---|
| 200 | Image finished inside the wait; data[].url holds the file | Prints the result |
| 202 | Wait expired (or mode is async or webhook); body is a job envelope with status_url and result_url | Prints the envelope; poll status_url and read result_url |
| 502 | The job failed inside the wait; error has code, retryable, next_action | Prints the error |
| 400, 404 | unsupported_parameter, or model_not_found | Prints the error |
C code
Compile with cc gen.c -lcurl -o gen and run SUME_API_KEY=... ./gen. The body goes to stdout by default; the status line goes to stderr.
#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
const char *key = getenv("SUME_API_KEY");
if (!key || !*key) { fprintf(stderr, "SUME_API_KEY missing\n"); return 1; }
char auth[512];
snprintf(auth, sizeof auth, "Authorization: Bearer %s", key);
const char *body = "{\"model\":\"bytedance-seed/seedream-5-lite\","
"\"prompt\":\"matte ceramic mug on a white sweep, soft shadow\","
"\"aspect_ratio\":\"16:9\"}";
curl_global_init(CURL_GLOBAL_DEFAULT);
CURL *c = curl_easy_init();
struct curl_slist *h = curl_slist_append(NULL, auth);
h = curl_slist_append(h, "Content-Type: application/json");
curl_easy_setopt(c, CURLOPT_URL, "https://api.sume.com/v1/images");
curl_easy_setopt(c, CURLOPT_HTTPHEADER, h);
curl_easy_setopt(c, CURLOPT_POSTFIELDS, body);
curl_easy_setopt(c, CURLOPT_TIMEOUT, 40L);
CURLcode rc = curl_easy_perform(c);
long status = 0;
curl_easy_getinfo(c, CURLINFO_RESPONSE_CODE, &status);
fprintf(stderr, "\nstatus %ld (200 = done, 202 = follow status_url)\n", status);
curl_slist_free_all(h);
curl_easy_cleanup(c);
curl_global_cleanup();
return rc == CURLE_OK && (status == 200 || status == 202) ? 0 : 1;
}Notes
libcurl writes the response body to stdout when no write callback is set, so ./gen > out.json captures the JSON. The status is read after curl_easy_perform with CURLINFO_RESPONSE_CODE.
CURLOPT_TIMEOUT is 40 seconds, above Sume's 30-second sync wait. The exit code is 0 for 200 and 202 and 1 otherwise, so a Makefile or CI step can check it.
One bytedance-seed/seedream-5-lite image is $0.04375 billed (list $0.035 x 1.25). Prices here are Sume's list-times-1.25 figures. The catalog states the billable formula as "list × 1.25 → ceil usd cents", so treat the dollar amounts as the pre-rounding value and read the exact charge from billable_amount_usd_micros in the submit envelope. Failed or cancelled generations are not billed.
Sources: Sume Image API docs and Jobs and results (read 2026-10-07).
Sources
Related posts
More in Developers
- C# HttpClient: submit a Seedance 2.5 job and poll until completed
A .NET top-level-statements script that posts a seedance-2.5 job to Sume, polls every 30 seconds, and stops on completed, failed or cancelled.
- Call Sume video generation from Java 11 with HttpClient
Java 11 HttpClient against Sume /v1/videos: submit a sume/auto job, poll until completed, and see what a default 8-second clip costs. No SDK needed.
- callback_url or webhook_url: which field each Sume video route takes
POST /v1/videos takes callback_url; motion control, lip-sync and image routes take mode plus webhook_url. The field names and what they share.
- Cancel a wrong video job after a Sora port: only before it starts
Ported prompts on the wrong model burn money. Sume cancels a video job only before generation starts; later you get 409 job_generation_already_started.
Written by Sume