openapi-typescript on the Sume OpenAPI JSON: types only, one command
npx openapi-typescript takes a URL or file and writes a .d.ts. Generate Sume job and error types from the 3.0.3 spec with no runtime code in your bundle.

The answer
openapi-typescript's introduction says it turns OpenAPI 3.0 and 3.1 schemas into TypeScript using Node.js, and shows two input forms: a local file and a URL. Sume's spec is OpenAPI 3.0.3, so it is in the supported range. Run npx openapi-typescript https://api.sume.com/reference/json -o ./sume.d.ts and you have types for every request and response.
A .d.ts file is types only. It adds nothing to the runtime bundle, which makes it the lightest way to type your own fetch calls against Sume.
The commands
The tool's page describes the invocation as the input schema followed by --output or -o. The two forms below differ only in where the schema comes from.
# from the live spec
npx openapi-typescript https://api.sume.com/reference/json -o ./sume.d.ts
# from a committed copy (recommended for reproducible builds)
curl -s https://api.sume.com/reference/json -o sume-openapi.json
npx openapi-typescript ./sume-openapi.json -o ./sume.d.tsUsing the output with fetch
The generated file exports paths and components. Index into them to type a request body or a response without writing the shape by hand. For example, take the job status response type from the /v1/jobs/{id}/status path and use it to type the parsed JSON. Because Sume wraps every success body in a data object, your code reads body.data.terminal and body.data.result_ready.
Types do not validate. If you need a runtime check, pair them with a schema library at the boundary; the Valibot post shows one way.
| Field | Meaning from the spec |
|---|---|
| terminal | True when completed, failed or canceled; stop polling |
| result_ready | True only when /result can return 200 |
| next_poll_after_seconds | Suggested minimum delay; null for terminal jobs |
| cancelable | True only before external generation starts |
Pin the schema and review the diff
A URL input is convenient for a first try. For a team, commit the downloaded JSON and the generated .d.ts, and regenerate when you choose to. A change in the spec then shows up as a plain diff on a types file, which is easy to review and easy to roll back.
Watch the nullable fields. In 3.0.x a field marked nullable: true generates a type that allows null; handle it explicitly when you compute a poll delay.
A small typed helper
With the types in place, write one function that takes a job id and returns the status body. Type the return value from the generated paths entry for the status endpoint, and let the compiler tell you when the spec changes a field you read. That is the whole benefit of generating types: the build fails at the line that depends on a field that moved.
Keep authentication out of the types. They describe request and response shapes only; you still add the Bearer or x-api-key header yourself, and you should send only one of them, since Sume answers 401 when both are present.
If you also need a fetch wrapper, the project documents a companion client, but you do not need it to use the types. Plain fetch with a typed return is enough for a polling loop, and it keeps your dependency list short.
Sources
Related posts
More in Developers
- Orval react-query client from the Sume OpenAPI JSON, tags-split
Point Orval at api.sume.com/reference/json with client react-query and mode tags-split for typed hooks per Sume tag. Config, caveats and polling tips.
- Poison Sume webhook events: park them in a table, return 2xx
A webhook your handler can never process will be retried up to 10 times. Store the raw body in a dead-letter table, return 2xx, and replay it later.
- Per-customer spend caps on Sume: what Sume caps, what you log
A Sume key belongs to a workspace, not your end customer. Cap each run with generation_spend_cap_usd and keep a per-customer ledger yourself.
- Perplexity Decisions API as a publish gate for Sume output
Check a finished Sume Format image with Perplexity's Decisions API before it ships: base64 data URL, one yes/no question, a threshold, and a human-review lane.
Written by Sume