Get Started with the Generative AI Features on Marketing API
Updated: Jan 21, 2025
API support for Generative AI features
Advertisers are responsible for previewing ad creative featuring AI-generated creatives before publishing their ads. See preview configuration instructions.
Meta does not make any warranties regarding the completeness, reliability, and accuracy of the suggested text generations, generated backgrounds, or expanded images. If you use Marketing API to access our Generative AI features outlined below, the Ad Creative Generative AI Terms apply in addition to the Meta Platform Terms.
Text variations are generated with AI inspired by your original primary text, your previous ads, or content from your business Page to help make suggestions more relevant. Adding more text options to your ad can help customize your creative and reduce creative fatigue which can help increase performance. Learn more about this feature here.
Step 1: Opt-in to use Text Generation when creating the ad
You can create an ad through the /ads endpoint or create a standalone creative through the /adcreatives endpoint. Opt-in to the feature only applies to the ad or creative created in the current request. In either approach, opt-in to use the Text Generation feature by:
Providing a primary text in the message field in the object_story_spec
When an ad is created with opt-in to use text_generation, the feature will only be applied to the current ad, and generated primary texts will be inserted to the creative spec. If the feature was opted-in through the /ads endpoint, the status field on the adgroup will be set to PAUSED by default (see documentation). You can review the generated suggestions before manually setting the ad’s status to ACTIVE so it can be delivered.
The creative spec containing generated suggestions can be previewed by reading the asset_feed_spec through the creative ID or the ad ID. See example request and response below:
Start by querying asset_feed_spec of your standalone ad creative created in step 1.
Request
// request from creative
curl -X GET -G \
-d 'fields=asset_feed_spec' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<CREATIVE_ID>
// request from ad
curl -X GET -G \
-d 'fields=creative{asset_feed_spec,status}' \
-d 'access_token=<ACCESS_TOKEN>' \
https://graph.facebook.com/v25.0/<AD_ID>
Response
{
"asset_feed_spec": {
"bodies": [
{
"text": "Buy some cool LED TV at cheap price"
},
{
"text": "Get your dream LED TV at an unbeatable price! Buy now and save big!"
},
{
"text": "Get the best LED TV deals! 📺 Save money and upgrade your entertainment."
},
{
"text": "Get an LED TV at a low cost! Cheap, high-quality options are available."
},
{
"text": "Get LED TVs at affordable prices ✨ !"
}
],
"optimization_type": "DEGREES_OF_FREEDOM"
},
"id": "<CREATIVE_ID>"
}
Once the suggestions have been reviewed and appear acceptable to publish, please move on to Step 3 to set the ad to ACTIVE. If any of the generated suggestions are not acceptable, please create a new ad or creative without opt-in to Text Generation.
Automatically expand your image to fit more placements.
Step 1: Create an ad or creative opted-in to image expansion
You can create an ad through the /ads endpoint or create a standalone creative through the /adcreatives endpoint. In either approach, opt-in to use the Image Expansion feature in the creative spec (see examples below).
This feature is supported for INSTAGRAM_STANDARD, FACEBOOK_REELS_MOBILE, INSTAGRAM_REELS, MOBILE_FEED_STANDARD, INSTGRAM_STORY placements. To look at a preview for these placements, make a GET request to the /<AD_ID>/previews endpoint.
If any of the generated images are not acceptable, please re-create the ad or creative without opt-in to Image Expansion:
Set the creative_feature as image_uncrop.
Re-request the preview if the status shows as pending.
Note: If a transformation_spec node is not shown, that means the creative is not eligible for image expansion.
We’ll create different backgrounds for eligible product images and deliver the version that your audience is most likely to respond to. These backgrounds were created based on your original asset.
Step 1: Create an ad or creative opted-in to background generation
Background generation currently only works with dynamic product ads or Advantage+ catalog ads on Mobile Feed.
You can create an ad through the /ads endpoint or create a standalone creative through the /adcreatives endpoint. In either approach, opt-in to use the Background Generation feature in the creative spec (see examples below).
With opt-in to the feature, we will create different backgrounds for eligible product images and deliver the version that your audience is most likely to respond to. Feature opt-in only applies to the ad created in the current request. These backgrounds are created based on your original asset, featuring different colors or patterns for eligible product images. You will see a static or live preview of your generated background depending on catalog eligibility.
If any of the generated backgrounds are not acceptable, please re-create the ad or creative without opt-in to Background Generation.
Preview is currently supported only the MOBILE_FEED_STANDARD placement
Set the creative_feature as image_background_gen
If the live preview for your catalog products is not ready, a stock preview is shown with status set to PENDING
{
"data": [
{
"body": "<iframe src='<PREVIEW_URL>'></iframe>",
"transformation_spec": {
"image_background_gen": [
{
"body": "<iframe src='<PREVIEW_URL>'></iframe>",
"status": "eligible" // or one of "pending", "ineligible"
}
]
}
}
]
}
About AI transparency
Ad images created or materially edited with certain Meta generative AI creative features available in our marketing tools may include AI info within the three-dot menu of an ad or have an AI info label next to the Sponsored label. Learn about generative AI transparency for ads.