Firefly API Object Composite: Submit and Verify the Async Receipt
Submit one Firefly Generate Object Composite request with Python requests, check the 202 receipt (jobId, statusUrl, cancelUrl), and learn how to cancel.
Before you start · 1. Confirm this is the right composite operation · 2. Prepare the headers
At a glance
This tutorial covers one task: using the Python requests pattern from the official guide to send one authenticated request to the Firefly API Generate Object Composite endpoint, then verifying the asynchronous receipt. The endpoint generates a background from a text prompt and composites your object into it. All three composite operations are asynchronous, so a successful submission means only that the job was accepted, not that an image is finished. The deliverable is a checked receipt (jobId, statusUrl and cancelUrl), not a finished image.
Workflow
Layer 1: Is the request well formed
Check that the path is /v3/images/generate-object-composite-async, the headers include Authorization (Bearer plus token), x-api-key and Content-Type, and the body has prompt and
image.source.url.Layer 2: Is the status an acceptance
The guide says all three endpoints return 202 Accepted. Read it as accepted, not finished. If raise_for_status throws, stop and check authentication and the body first.
Layer 3: Is the receipt complete
The response should include jobId, statusUrl and cancelUrl. Record all three as returned, since polling and cancelling both depend on them.
Before you start
- A working access token (ACCESS_TOKEN) and API key, and knowledge of which project they belong to. The sample values are placeholders; never put real values in shared files or screenshots.
- An object image reachable by URL (the sample uses https://example.com/product.png) and a local Python install with the requests library.
- A short prompt describing the background. The English text a product on a wooden table in a cozy kitchen is the official sample, not an English-only requirement.
1. Confirm this is the right composite operation
In the terminal or editor where your script lives, confirm you have an object image but no background yet. The guide says that case uses Generate Object Composite at /v3/images/generate-object-composite-async. Cases with an existing background belong to the other two endpoints and are out of scope here.
2. Prepare the headers
At the top of your Python file, set API_BASE (https://firefly-api.adobe.io) plus placeholder ACCESS_TOKEN and API_KEY values, and build headers: Authorization as Bearer plus token, x-api-key as the key, and Content-Type as application/json. Replace the placeholders with your own credentials before running, and do not commit them.
3. Fill in the request body
The payload has two parts: prompt for the background description, and image.source.url for the object image address. Use only a sample image with no private content, and confirm the URL opens directly in a browser before continuing.
4. Send the POST request
Send one request with requests.post, then call response.raise_for_status(). Investigate an explicit rejection before considering a corrected request; retain and check any job receipt received. Do not resend directly after a timeout or unknown response because the service may already have accepted the job. Preserve the unknown state and investigate first.
5. Verify and save the receipt
Read response.json() and print jobId, statusUrl and cancelUrl. Check that all three are present and that the response was 202 rather than another status. Write the three values in your own task notes.
6. Cancel if needed, then stop
For an in-progress job only, send PUT to cancelUrl when cancellation is needed, using the same authentication headers. Sending PUT alone does not prove success; successful cancellation usually returns 200 with an empty body, so inspect the actual response. Check completed or unknown job states before applying the in-progress cancellation procedure.
Original example
Illustrative code adapted from the official Python example; credentials and image URL are placeholders:
import requests
API_BASE = "https://firefly-api.adobe.io"
ACCESS_TOKEN = "your_access_token"
API_KEY = "your_api_key"
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}", "x-api-key": API_KEY, "Content-Type": "application/json"}
payload = {"prompt": "a product on a wooden table in a cozy kitchen", "image": {"source": {"url": "https://example.com/product.png"}}}
response = requests.post(f"{API_BASE}/v3/images/generate-object-composite-async", headers=headers, json=payload)
response.raise_for_status()
print("HTTP status:", response.status_code)
result = response.json()
print("Job ID:", result["jobId"])
print("Status URL:", result.get("statusUrl"))
print("Cancel URL:", result.get("cancelUrl"))
You should see three printed lines for jobId, statusUrl and cancelUrl; the actual values come from the service and are not invented here. The check passes when the response is 202 Accepted, no exception occurred, all three values are present, and they are recorded. To abandon an in-progress job, send PUT to cancelUrl and inspect the cancellation response.Completion checks
- The script raised no exception from raise_for_status and the response was 202 Accepted.
- jobId, statusUrl and cancelUrl were all printed, non-empty, and saved.
- Submit only once and retain unknown state after a timeout or unclear response, without direct resend or claiming server-side duplicates are absent.
- No real token or API key remains in the code or notes.
Limits
- 202 means only that the job was accepted, not that the image is done; this guide does not claim the job will succeed.
- The guide gives no polling response field names, so this tutorial does not describe status values or where a result image address appears.
- This guide uses the supplied compositing guide and does not cover precise/adaptive compositing or the separate API reference.
- Cancel typically returns 200 with an empty body; that is the documentation's wording, not a guarantee.
Verification scope
This guide was written from reading the official documentation only; login, installation, product API execution, file upload and generated output were not tested. The code is an illustrative sample adapted from the documentation, and the credentials and the image URL are placeholders; the service URL and fields follow the official sample.
Article sources
Original editorial content; official descriptions and checking suggestions are distinguished.