Create Memes
In this example we will look at how to create memes using the Predis.ai API. We will set the value of post_type
to meme
and the value of media_type
parameter to single_image
. Currently only single_image
is supported for generating memes and hence any other value in media_type
will fail.
You can provide the topic/idea for the meme in the text
parameter.
import requests
url = "https://brain.predis.ai/predis_api/v1/create_content/"
payload = {
"brand_id": "YOUR_BRAND_ID",
"text": "Me trying to prioritize work over sleep",
"media_type": "single_image",
"template_ids": [], # pass template_ids if you want to use a particular meme template
"post_type": "meme"
}
headers = {"Authorization": "YOUR_API_KEY"}
response = requests.request("POST", url, data=payload, headers=headers)
if response.status_code == 200:
json_response = response.json()
post_id = response.get("post_id")
post_status = response.get("status")
else:
print("Error occurred - {}".format(response.text))
If you get a inProgress
status in response, your request is successful and the meme is getting generated. Once the meme gets generated successfully (or fails), you will get a request on your configured webhook URL with more details.