Understanding Firefly API Seeds
Use seeds to generate similar AI images across multiple API requests. Learn about seeds and how they're used with Firefly AI.
About seeds
Whenever Firefly AI generates an image it begins that process by picking a random number called a "seed". In the context of AI, the seed is a starting value or series of values for a random number generator (RNG) to help vary the generated results.
Computer programs are completely deterministic, so they can't create true randomness. A random seed facilitates pseudorandomness with AI so that generated images are different even when other parameters remain the same. Using the same seed, prompt, and other presets, would generate the same image every time.
When Firefly generates an image that you want to preserve and modify more precisely using Firefly's other image options (such as style presets, reference images, etc.), you'll use that image's seed to limit the variations and hone in on the image you want.
Concepts in action
data-variant=warning
data-slots=heading, text
Find the seed
- First, open a secure terminal and
exportyour Client ID and Access Token as environment variables:
export FIREFLY_SERVICES_CLIENT_ID=yourClientIdAsdf123
export FIREFLY_SERVICES_ACCESS_TOKEN=yourAccessTokenAsdf123
- Run the following command to generate an AI image of a futuristic city with a unique seed:
curl --location 'https://firefly-api.adobe.io/v3/images/generate-async' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "x-api-key: $FIREFLY_SERVICES_CLIENT_ID" \
--header "Authorization: Bearer $FIREFLY_SERVICES_ACCESS_TOKEN" \
--data '{
"prompt": "a futuristic future cityscape with flying cars"
}'
The request returns a rapid response for the async job:
{
"jobId":"<YOUR_JOB_ID>",
"statusUrl":"https://firefly-epo854211.adobe.io/v3/status/urn:ff:jobs:...",
"cancelUrl":"https://firefly-epo854211.adobe.io/v3/cancel/urn:ff:jobs:..."
}
- Use the
jobIdto check the status of the job:
curl -X GET "https://firefly-api.adobe.io/v3/status/<YOUR_JOB_ID>" \
-H "x-api-key: $FIREFLY_SERVICES_CLIENT_ID" \
-H "Authorization: Bearer $FIREFLY_SERVICES_ACCESS_TOKEN" \
-H "Content-Type: application/json"
After Firefly successfully generates the image, the JSON response for the final status will contain the image seed in outputs, along with other details.
Below is an example of our sample image response and the image it generated:
{
"status": "succeeded",
"jobId": "urn:ff:jobs:epo854211:783e1c22-5a15-4a01-ab2b-32966a06ce6c",
"result": {
"size": {
"width": 2048,
"height": 2048
},
"outputs": [
{
"seed": 1842533538, // Here is the seed for our generated image
"image": {
"url": "https://pre-signed-firefly-prod.s3-accelerate.amazonaws.com/images/asdf-1234..."
}
}
],
"contentClass": "art"
}
}
Generate a seed image
Use Firefly's other image generation options (like style presets or size) while keeping the results consistent with the original generated image. Generate similar cityscapes by using its seed:
1842533538
- Use the command below to generate an image variation of our cityscape. This variation has "landscape photography" and "science fiction" style presets applied to it. Or include other options to experiment with new results.
curl --location 'https://firefly-api.adobe.io/v3/images/generate-async' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "x-api-key: $FIREFLY_SERVICES_CLIENT_ID" \
--header "Authorization: Bearer $FIREFLY_SERVICES_ACCESS_TOKEN" \
--data '{
"prompt": "a futuristic future cityscape with flying cars",
"seeds": [
1842533538
],
"style": {
"presets": [
"landscape_photography", "science_fiction"
]
}
}'
The request returns a rapid response for the async job:
{
"jobId":"<YOUR_JOB_ID>",
"statusUrl":"https://firefly-epo854211.adobe.io/v3/status/urn:ff:jobs:...",
"cancelUrl":"https://firefly-epo854211.adobe.io/v3/cancel/urn:ff:jobs:..."
}
- Use the
jobIdto see the result:
curl -X GET "https://firefly-api.adobe.io/v3/status/<YOUR_JOB_ID>" \
-H "x-api-key: $FIREFLY_SERVICES_CLIENT_ID" \
-H "Authorization: Bearer $FIREFLY_SERVICES_ACCESS_TOKEN" \
-H "Content-Type: application/json"
The differences are obvious, but you'll also notice the similarities. Those characteristics come from the seed.