Edit a photo with an Agent Completion: attach it, read output.images
Send the photo in attachments to POST /v1/agent/completions with a spend cap, poll the run, read the edit from output.images. Python code and limits.

To edit a photo with an Agent Completion, send the instruction and the photo in attachments to POST /v1/agent/completions with a generation_spend_cap_usd, poll the run, and read the result from output.images. The agent looks at the image, picks its own tool for the edit, and stays under your cap. It is a different shape from POST /v1/images, where you pick the model and parameters yourself.
The request
The call returns 202 and an agent.run receipt. Each attachment is an input_image with either an image_url or an asset_id. You can send up to 30 images, 30 MB each and 500 MB per run, in JPEG, PNG, WebP, GIF or AVIF (Agent Completions, Formats). generation_spend_cap_usd has no default and a missing field is a 400.
import os, time, requests
H = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
r = requests.post(
"https://api.sume.com/v1/agent/completions",
headers=H,
json={
"instruction": "Remove dust specks from this product photo. Keep the product and label unchanged.",
"attachments": [{"type": "input_image", "image_url": "https://example.com/shot.jpg"}],
"generation_spend_cap_usd": 1,
},
timeout=60,
)
r.raise_for_status()
run = r.json()["data"]
while True:
s = requests.get(f"https://api.sume.com/v1/agent-runs/{run['id']}", headers=H, timeout=60).json()
s = s.get("data", s)
if s["status"] in ("completed", "failed", "canceled"):
break
time.sleep(5)
print(s["status"], (s.get("output") or {}).get("images"))What comes back
A completed run has output.text for the agent's last message and output.images for generated pictures, with durable media.sume.com URLs. The run also records spend in usage. A failed or canceled status ends the loop in the code above, so check the status before you read the images.
| Item | Value |
|---|---|
| Endpoint | POST /v1/agent/completions, 202 receipt |
| Poll | GET /v1/agent-runs/{id} |
| Attachments | up to 30 images, 30 MB each, 500 MB per run |
| Result field | output.images |
| Spend limit | generation_spend_cap_usd, required |
Errors to expect
invalid_attachment is a bad item, attachment_too_large is a 413, attachment_fetch_failed is a 502 that means Sume could not download your URL, and insufficient_scope is a 403 for a key without the right scope. Re-sending with the same Idempotency-Key returns the original receipt, and a different payload under the same key is a 409.
When not to use it
If you already know the model, the aspect ratio and the exact prompt, use the Image API. It is synchronous for up to 30 seconds, you can set quality and aspect_ratio. A completion is better when the task is loose, for example a photo plus a written brief where the agent should choose between a retouch and a background change.
Also keep the cap honest. The agent can make several generation calls in one run, so a cap of $1 is the most you accept for the whole task, not for one image.
A note on cost
The cap is the control you have. Sume documents the metered rates on the API pricing page, and a good habit is to run one example with a generous cap, read usage on the finished run, and set later caps a little above that figure.
If a run ends as failed, read the status payload before you retry. A retry with the same Idempotency-Key returns the original receipt, so use a new key only when you mean to start a new run.
Sources
Related posts
More in Developers
- Per-request character limits: Eleven v4 10,000 vs Sume TTS 20,000
Eleven v4 takes up to 10,000 characters per generation, Sume TTS 1 to 20,000. A 45,000-character script is 5 requests versus 3, with a chunking script.
- ElevenLabs Music can sign MP3s with C2PA; what to log for a Sume track
The ElevenLabs Music API has sign_with_c2pa for MP3 output only. Sume's Music docs name no audio credential, so keep a record of job, prompt and routed model.
- Edit a transcript with plain-language instructions: ElevenLabs STT
ElevenLabs STT edits a transcript from an instruction of up to 2,000 characters and returns edited_transcript. Sume captions align your own script_text.
- Embargoed Black Friday reveal: Sume media URLs are public, copy first
Format artifacts sit on durable public media.sume.com URLs with no expiry. For an embargoed drop, copy the file to your own storage and never log the URL.
Written by Sume