Template ID and modifications
To generate an image from a template, you'll need two things:
- Template ID
- Template's modifications
Template ID
Pika has tons of templates you can use to generate image from using API. You can view all the available templates here in Pika'a API templates page
Here are some templates you might find useful:
- Open graph images
- Beautify screenshots
- Tweet to image
Template modifications
Each image template in Pika is unique and comes with it's own set of cusomizable parameters called modifications
. You can use these modifications to customize colors, text, background etc. in the template
For ex. in Open Graph Image API template you can use the following modifications:
modifications: {
title: "Pika API",
description: "Hey! Thanks Dinesh for helping with the API",
}
A sample request would look something like this:
const response = await fetch(`https://api.pika.style/v1/templates/${PIKA_TEMPLATE_ID}/images`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${PIKA_API_KEY}`,
},
body: JSON.stringify({
response_format: "base64", // Optional, default is base64
modifications: {
title: "Pika API",
description: "Hey! Thanks Dinesh for helping with the API",
},
}),
}).then((res) => res.json());