Skip to main content

Generate a product image

End-to-end: from nothing to a generated, on-brand Scene Forge image using the REST API. Every step is copy-paste curl. Set your key first:

export NATIVEADS_API_KEY="nak_production_<keyId>.<secret>"
export BASE="https://api.nativeads.ai/v1"

Prerequisite: your organization must have image generation capacity left on its plan. Check with GET /organizations/current/feature-usage.

1. Create a brand

BRAND_ID=$(curl -s -X POST "$BASE/brands" \
-H "Authorization: Bearer $NATIVEADS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name":"Acme Coffee","industry":"Food & Beverage",
"description":"Small-batch specialty coffee roasted daily.",
"mission":"Make exceptional coffee accessible to everyone.",
"values":["Quality","Sustainability"],
"tone":["Friendly","Authoritative"],
"voice":["Warm","Knowledgeable"]
}' | jq -r '.id')
echo "brand: $BRAND_ID"

2. Extract and activate Brand DNA

Brand DNA teaches the models your visual identity. Extract it from your website, then activate the version so useBrandDna applies. (See the Brand DNA from a URL recipe for the detailed version.)

VERSION_ID=$(curl -s -X POST "$BASE/brands/$BRAND_ID/brand-dna/versions" \
-H "Authorization: Bearer $NATIVEADS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"urls":["https://www.acme-coffee.example"]}' | jq -r '.data.versionId')

# poll until ready
while true; do
S=$(curl -s "$BASE/brands/$BRAND_ID/brand-dna/versions/$VERSION_ID" \
-H "Authorization: Bearer $NATIVEADS_API_KEY" | jq -r '.data.status')
echo "dna: $S"; [ "$S" = "ready" ] && break; [ "$S" = "failed" ] && exit 1; sleep 3
done

curl -s -X POST "$BASE/brands/$BRAND_ID/brand-dna/versions/$VERSION_ID/activate" \
-H "Authorization: Bearer $NATIVEADS_API_KEY" >/dev/null

3. Generate a Scene Forge image

SF_ID=$(curl -s -X POST "$BASE/brands/$BRAND_ID/scene-forges" \
-H "Authorization: Bearer $NATIVEADS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"blendingPrompt":"a bag of coffee on a sunlit marble kitchen counter",
"promptIsEnhanced":false,
"aspectRatio":"1:1",
"useBrandDna":true
}' | jq -r '.sceneForgeId')
echo "scene forge: $SF_ID"

4. Poll until done and read the images

while true; do
S=$(curl -s "$BASE/scene-forges/$SF_ID" \
-H "Authorization: Bearer $NATIVEADS_API_KEY" | jq -r '.status')
echo "scene forge: $S"; [ "$S" = "completed" ] && break; [ "$S" = "failed" ] && exit 1; sleep 3
done

# print the generated image URLs
curl -s "$BASE/scene-forges/$SF_ID" \
-H "Authorization: Bearer $NATIVEADS_API_KEY" \
| jq -r '.variations[].asset.url'

A Scene Forge produces four variations. Each variation's asset.url is a signed, short-lived download link.

Next