Generate API
Photo generation allows you to input your envisioned concept as text, and AI will create a photo of the product for you. This API is primarily used to gain inspiration for product photos and can be utilized in conjunction with the Remix API to use the generated photos as references. With the Generate API, there's no longer a need to search for ideas for product photos.
Authentication
header
X-Photio-Key : {PHOTIO_API_KEY}
Do you not have an API key yet?
To call the API, you first need to obtain a Photio API key. To get your API key, go to the API Dashboard. After registering your card, you can use the issued API key.
Request Body
Variable | Type | Require | Default | Description |
---|---|---|---|---|
prompt | string | ✓ | "" | This is a description of the image you want to create, provided in English. It should include a detailed depiction of the scene or object you'd like to generate. |
negative_prompt | string | "worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch" | Enter in English any objects or scenarios you do not want to appear in the image. If nothing is entered, a default negative prompt will be used, which includes: "worst quality, low quality, illustration, 3d, 2d, painting, cartoons, sketch." | |
quality | string | "LOW" | Choose from three levels of quality: "LOW", "MIDDLE", "HIGH". The default is "LOW". Setting the quality to "HIGH" will increase the detail quality of the generated image but will also take more time. A "LOW" quality setting results in relatively lower detail quality but faster generation speed. | |
seed | int | -1 | This variable allows for the creation of different outcomes even with the same input. It can be set to any integer between 1 and 4,294,967,296. If you enter -1 or leave this field blank, a random seed number will be used to generate the image. | |
cfg_scale | float | 2.5 | This setting determines how closely the AI should follow the prompt. A higher cfg_scale (e.g., 2.5) means the AI will strictly adhere to the prompt and not add extraneous elements. Lower cfg_scale settings allow the AI more freedom to incorporate various elements into the image. Recommend value range is 1.0~2.5 |
- Shell
- Python
- Java
- JS
curl --request POST
--url https://api.photio.io/v1/inference/generate
--header 'X-Photio-Key: {X-Photio-Key}'
--header 'Content-Type: application/json'
--data '{ "prompt": "A modern drone hovering above a glossy, geometrically shaped platform, with dynamic LED lighting below.", "quality": "MIDDLE" }'
import requests
import json
data = {
"prompt": "A modern drone hovering above a glossy, geometrically shaped platform, with dynamic LED lighting below.",
"quality": "MIDDLE"
}
body_data = json.dumps(data)
# Set the necessary headers
headers = {
'X-Photio-Key': '{X-Photio-Key}',
'Content-Type': 'application/json'
}
response = requests.post('https://api.photio.io/v1/inference/generate', headers=headers, data=body_data)
class Generate {
public void generate() {
URL url = new URL("https://api.photio.io/v1/inference/generate");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("X-Photio-Key", "${PHOTIO_API_KEY}");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("POST");
JSONObject data = new JSONObject();
data.put("prompt", "A modern drone hovering above a glossy, geometrically shaped platform, with dynamic LED lighting below.");
data.put("quality", "MIDDLE");
String bodyData = data.toString();
try (OutputStream os = conn.getOutputStream()) {
byte[] input = bodyData.getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = conn.getResponseCode();
System.out.println("Response Code : " + responseCode);
conn.disconnect();
}
}
const data = {
prompt:"A modern drone hovering above a glossy, geometrically shaped platform, with dynamic LED lighting below.",
quality: "MIDDLE"
};
const bodyData = JSON.stringify(data);
// Set the necessary headers
const headers = {
'X-Photio-Key': '{X-Photio-Key}',
'Content-Type': 'application/json'
};
fetch('https://api.photio.io/v1/inference/generate', {
method: 'POST',
headers: headers,
body: bodyData
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Response
Variable | Type | Description |
---|---|---|
status_code | int | In the response, you can find a status value to check the status of the request. A normal response is indicated by 200, authentication issues by 401, and API status problems by a 500 error. |
body | string | The result image data is output as a Base64-encoded string. |
Response Example
{
"status_code": Int,
"body": Base64 String
}
Output Example