Can I attach my order ID to an AI image job? Sume's metadata field
Sume's image request takes a metadata object stored on the job, not sent to the provider. Pair it with an Idempotency-Key and your own table in Python.

Yes. Sume's Image API request table lists metadata as an optional object of caller metadata that Sume stores on the job and does not send to the provider. Put your order id, customer reference or batch name there so the job can be traced back to your system.
Do not rely on it as your only record. Keep your own table keyed by the job id, because the docs describe what is stored and not how you read it back.
Three identifiers, three jobs
| Identifier | Who creates it | Purpose |
|---|---|---|
Idempotency-Key header | You | Retry the same paid request without paying twice |
metadata object | You | Caller data stored on the job, never sent to the provider |
Job id in the 202 envelope | Sume | Poll status and fetch the result |
Submit and record
The script sends an async request with an order id, then writes the order and the job id to a small SQLite table. The Idempotency-Key is there so a retry of the same request does not become a second paid generation.
import os, sqlite3, requests
key = os.environ.get("SUME_API_KEY")
if not key:
raise SystemExit("set SUME_API_KEY")
db = sqlite3.connect("orders.db")
db.execute("create table if not exists img (order_id text primary key, job_id text)")
order = "ord-1042"
r = requests.post(
"https://api.sume.com/v1/images",
headers={"Authorization": f"Bearer {key}", "Idempotency-Key": f"img-{order}"},
json={"model": "ideogram/ideogram-v4.5", "quality": "low", "mode": "async",
"prompt": "Gift tag, kraft paper, bold serif lettering",
"metadata": {"order_id": order}},
timeout=60,
)
r.raise_for_status()
job = r.json()["data"]["job"]["id"]
db.execute("insert or replace into img values (?, ?)", (order, job))
db.commit()
print(order, job)What to keep out of metadata
- Anything secret. It is stored on the job, so treat it like job data.
- Large blobs. It is caller metadata, not a place for the source image.
- Personal data you do not need. An order number is enough to find the person in your own system.
Retry rules to keep
The jobs docs say not to submit the original paid request again just because a local process timed out. Poll the job first. If you must resend, reuse the same Idempotency-Key with the same payload. A changed payload is a different request and should get a new key.
Why the split matters
Because metadata is not sent to the provider, your order numbers and batch labels stay inside your Sume account and your own database. That is a useful default when the labels would mean something to a person who saw them.
Sources
Related posts
More in Developers
- Check balance before bulk transcription: 402 and admission preview
A 402 insufficient_credits arrives before any provider work. Read GET /v1/balance and POST /v1/generation/admission-preview first and size the run.
- Port a Bedrock image call to Sume /v1/images in Python
Moving from boto3 invoke_model for Nova Canvas or Titan to Sume's REST call: the request mapping, the response shape, the status codes, and the swap code.
- Build a Sume Idempotency-Key from an order id: changed body result
The same key and body replays the original Sume job. A different body with the same key is a 409. Pick keys that make both outcomes safe, in runnable Python.
- BullMQ delayed job that polls an AI video job and reschedules itself
A BullMQ worker reads Sume's job status once, then adds the next poll with a delay from next_poll_after_seconds, so no worker slot is held while a clip renders.
Written by Sume