The resources (image, video, voice) generated by our API are valid for 7 days. Please save the relevant resources as soon as possible to prevent expiration.
Text to image / Image to image
POST https://openapi.akool.com/api/open/v3/content/image/createbyprompt
| Parameter | Value | Description |
|---|---|---|
| Authorization | Bearer token | Your API Key used for request authorization |
| Parameter | Type | Value | Description |
|---|---|---|---|
| prompt | String | Describe the information needed to generate the image | |
| scale | String | ”1:1” “4:3” “3:4” “16:9” “9:16” “3:2” “2:3” | The size of the generated image default: “1:1” |
| source_image | String | Need to generate the original image link of the image 【If you want to perform imageToImage operation you can pass in this parameter】 | |
| webhookUrl | String | Callback url address based on HTTP request |
| Parameter | Type | Value | Description |
|---|---|---|---|
| code | int | 1000 | Interface returns business status code(1000:success) |
| msg | String | Interface returns status information | |
| data | Object | { _id: "", image_status: 1 } | _id: Interface returns data, image_status: the status of image: 【1:queueing, 2:processing, 3:completed, 4:failed】 |
{
"prompt": "Sun Wukong is surrounded by heavenly soldiers and generals", // Describe the information needed to generate the image
"scale": "1:1",
"source_image": "https://drz0f01yeq1cx.cloudfront.net/1708333063911-9cbe39b7-3c5f-4a35-894c-359a6cbb76c3-3283.png", // Need to generate the original image link of the image 【If you want to perform imageToImage operation you can pass in this parameter】
"webhookUrl":"http://localhost:3007/image/webhook" // Callback url address based on HTTP request
}
curl --location 'https://openapi.akool.com/api/open/v3/content/image/createbyprompt' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "Sun Wukong is surrounded by heavenly soldiers and generals",
"source_image": "https://drz0f01yeq1cx.cloudfront.net/1708333063911-9cbe39b7-3c5f-4a35-894c-359a6cbb76c3-3283.png",
"scale": "1:1",
"webhookUrl":"http://localhost:3007/image/webhook"
}
'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"prompt\": \"Sun Wukong is surrounded by heavenly soldiers and generals\", \n \"source_image\": \"https://drz0f01yeq1cx.cloudfront.net/1708333063911-9cbe39b7-3c5f-4a35-894c-359a6cbb76c3-3283.png\", \n \"webhookUrl\":\"http://localhost:3007/image/webhook\" \n}\n");
Request request = new Request.Builder()
.url("https://openapi.akool.com/api/open/v3/content/image/createbyprompt")
.method("POST", body)
.addHeader("Authorization", "Bearer token")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
const myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
"prompt": "Sun Wukong is surrounded by heavenly soldiers and generals",
"source_image": "https://drz0f01yeq1cx.cloudfront.net/1708333063911-9cbe39b7-3c5f-4a35-894c-359a6cbb76c3-3283.png",
"scale": "1:1",
"webhookUrl": "http://localhost:3007/image/webhook"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://openapi.akool.com/api/open/v3/content/image/createbyprompt", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$client = new Client();
$headers = [
'Authorization' => 'Bearer token',
'Content-Type' => 'application/json'
];
$body = '{
"prompt": "Sun Wukong is surrounded by heavenly soldiers and generals",
"source_image": "https://drz0f01yeq1cx.cloudfront.net/1708333063911-9cbe39b7-3c5f-4a35-894c-359a6cbb76c3-3283.png",
"scale": "1:1",
"webhookUrl": "http://localhost:3007/image/webhook"
}';
$request = new Request('POST', 'https://openapi.akool.com/api/open/v3/content/image/createbyprompt', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
import requests
import json
url = "https://openapi.akool.com/api/open/v3/content/image/createbyprompt"
payload = json.dumps({
"prompt": "Sun Wukong is surrounded by heavenly soldiers and generals",
"source_image": "https://drz0f01yeq1cx.cloudfront.net/1708333063911-9cbe39b7-3c5f-4a35-894c-359a6cbb76c3-3283.png",
"scale": "1:1",
"webhookUrl": "http://localhost:3007/image/webhook"
})
headers = {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
{
"code": 1000,
"msg": "OK",
"data": {
"faceswap_quality": 2,
"deduction_credit": 2,
"buttons": [],
"used_buttons": [],
"upscaled_urls": [],
"_id": "64dd82eef0b6684651e90131",
"uid": 378337,
"create_time": 1692238574633,
"origin_prompt": "***",
"source_image": "https://***.cloudfront.net/1702436829534-4a813e6c-303e-48c7-8a4e-b915ae408b78-5034.png",
"prompt": "***** was a revolutionary leader who transformed *** into a powerful communist state.",
"type": 4,
"from": 1,
"image_status": 1 // the status of image: 【1:queueing, 2:processing,3:completed, 4:failed】
}
}
Generate 4K or variations
POST https://openapi.akool.com/api/open/v3/content/image/createbybutton
| Parameter | Value | Description |
|---|---|---|
| Authorization | Bearer token | Your API Key used for request authorization |
| Parameter | Type | Value | Description |
|---|---|---|---|
| _id | String | the image_id you had generated, you can got it from https://openapi.akool.com/api/open/v3/content/image/createbyprompt | |
| button | String | the type of operation you want to perform, You can get the field(display_buttons) value from https://openapi.akool.com/api/open/v3/content/image/infobymodelid 【U(1-4): Generate a single 4k image based on the corresponding serial number original image, V(1-4):Generate a single variant image based on the corresponding serial number original image】 | |
| webhookUrl | String | Callback url address based on HTTP request |
| Parameter | Type | Value | Description |
|---|---|---|---|
| code | int | 1000 | Interface returns business status code(1000:success) |
| msg | String | Interface returns status information | |
| data | Object | {_id:"",image_content_model_id: "",op_button: "",image_status:1} | _id: Interface returns data image_content_model_id: the origin image _id you had generated op_button: the type of operation you want to perform image_status: the status of image: 【1:queueing, 2:processing, 3:completed, 4:failed】 |
{
"_id": "65d3206b83ccf5ab7d46cdc6", // the image【_id】 you had generated, you can got it from https://openapi.akool.com/api/open/v3/content/image/createbyprompt
"button": "U2", // the type of operation you want to perform, You can get the field(display_buttons) value from https://content.akool.com/api/v1/content/image/infobyid 【U(1-4): Generate a single 4k image based on the corresponding serial number original image, V(1-4):Generate a single variant image based on the corresponding serial number original image】
"webhookUrl":"http://localhost:3007/image/webhook" // Callback url address based on HTTP request
}
curl --location 'https://openapi.akool.com/api/open/v3/content/image/createbybutton' \
--header 'Authorization: Bearer token' \
--header 'Content-Type: application/json' \
--data '{
"_id": "65d3206b83ccf5ab7d46cdc6",
"button": "U2",
"webhookUrl":"http://localhost:3007/image/webhook"
}'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"_id\": \"65d3206b83ccf5ab7d46cdc6\", \n \"button\": \"U2\", \n \"webhookUrl\":\"http://localhost:3007/image/webhook\" \n}");
Request request = new Request.Builder()
.url("https://openapi.akool.com/api/open/v3/content/image/createbybutton")
.method("POST", body)
.addHeader("Authorization", "Bearer token")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
const myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
myHeaders.append("Content-Type", "application/json");
const raw = JSON.stringify({
"_id": "65d3206b83ccf5ab7d46cdc6",
"button": "U2",
"webhookUrl": "http://localhost:3007/image/webhook"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://openapi.akool.com/api/open/v3/content/image/createbybutton", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$client = new Client();
$headers = [
'Authorization' => 'Bearer token',
'Content-Type' => 'application/json'
];
$body = '{
"_id": "65d3206b83ccf5ab7d46cdc6",
"button": "U2",
"webhookUrl": "http://localhost:3007/image/webhook"
}';
$request = new Request('POST', 'https://openapi.akool.com/api/open/v3/content/image/createbybutton', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
import requests
import json
url = "https://openapi.akool.com/api/open/v3/content/image/createbybutton"
payload = json.dumps({
"_id": "65d3206b83ccf5ab7d46cdc6",
"button": "U2",
"webhookUrl": "http://localhost:3007/image/webhook"
})
headers = {
'Authorization': 'Bearer token',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
{
"code": 1000,
"msg": "OK",
"data": {
"faceswap_quality": 2,
"deduction_credit": 2,
"buttons": [],
"used_buttons": [],
"upscaled_urls": [],
"_id": "6508292f16e5ba407d47d21b",
"image_content_model_id": "6508288416e5ba407d47d13f", // the origin image【_id】 you had generated
"create_time": 1695033647012,
"op_button": "U2", // the type of operation you want to perform
"op_buttonMessageId": "kwZsk6elltno5Nt37VLj",
"image_status": 1, // the status of image: 【1:queueing, 2:processing, 3:completed, 4:failed】
"from": 1
}
}
Get Image Result image info
GET https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=64dd838cf0b6684651e90217
| Parameter | Value | Description |
|---|---|---|
| Authorization | Bearer token | Your API Key used for request authorization |
| Parameter | Type | Value | Description |
|---|---|---|---|
| image_model_id | String | image db id:You can get it based on the _id field returned by https://openapi.akool.com/api/open/v3/content/image/createbyprompt or https://openapi.akool.com/api/open/v3/content/image/createbybutton api. |
| Parameter | Type | Value | Description |
|---|---|---|---|
| code | int | 1000 | Interface returns business status code(1000:success) |
| msg | String | Interface returns status information | |
| data | Object | {image_status:1,_id:"",image:""} | image_status: the status of image: 【1:queueing, 2:processing, 3:completed, 4:failed】 image: Image result after processing _id: Interface returns data |
curl --location 'https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=662a10df4197b3af58532e89' \
--header 'Authorization: Bearer token'
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("text/plain");
RequestBody body = RequestBody.create(mediaType, "");
Request request = new Request.Builder()
.url("https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=662a10df4197b3af58532e89")
.method("GET", body)
.addHeader("Authorization", "Bearer token")
.build();
Response response = client.newCall(request).execute();
const myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer token");
const requestOptions = {
method: "GET",
headers: myHeaders,
redirect: "follow"
};
fetch("https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=662a10df4197b3af58532e89", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
<?php
$client = new Client();
$headers = [
'Authorization' => 'Bearer token'
];
$request = new Request('GET', 'https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=662a10df4197b3af58532e89', $headers);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
import requests
url = "https://openapi.akool.com/api/open/v3/content/image/infobymodelid?image_model_id=662a10df4197b3af58532e89"
payload = {}
headers = {
'Authorization': 'Bearer token'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
{
"code": 1000,
"msg": "OK",
"data": {
"faceswap_quality": 2,
"deduction_credit": 2,
"buttons": [ "U1",
"U2",
"U3",
"U4",
"V1",
"V2",
"V3",
"V4"],
"used_buttons": [],
"upscaled_urls": [],
"_id": "662a10df4197b3af58532e89",
"create_time": 1714032863272,
"uid": 378337,
"type": 3,
"image_status": 3, // the status of image:【1:queueing, 2:processing,3:completed,4:failed】
"image": "https://***.cloudfront.net/1714032892336-e0ec9305-e217-4b79-8704-e595a822c12b-8013.png" // Image result after processing
}
}
Please note that if the value of the response code is not equal to 1000, the request is failed or wrong
| Parameter | Value | Description |
|---|---|---|
| code | 1000 | Success |
| code | 1003 | Parameter error or Parameter can not be empty |
| code | 1008 | The content you get does not exist |
| code | 1009 | You do not have permission to operate |
| code | 1010 | You can not operate this content |
| code | 1101 | Invalid authorization or The request token has expired |
| code | 1102 | Authorization cannot be empty |
| code | 1108 | image generate error,please try again later |
| code | 1200 | The account has been banned |