Create Generation
POST
/v1/image/generation/create
This endpoint is for generating images. Although it supports many parameters, in its simplest form, you just need to send a prompt and the system will use the defaults for the rest.
Request Example
Below is the simplest example of generating an image. You just send a prompt and the system will use the defaults for the rest.
curl -X POST 'https://api.stablecog.com/v1/image/generation/create' \
-H 'Authorization: Bearer <YOUR_STABLECOG_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{"prompt": "red cat wearing a purple hat"}'
const API_KEY = process.env.STABLECOG_API_KEY;
const API_HOST = 'https://api.stablecog.com';
const API_ENDPOINT = '/v1/image/generation/create';
const API_URL = `${API_HOST}${ENDPOINT}`;
const req = {
prompt: 'red cat wearing a purple hat'
};
const res = await fetch(API_URL, {
method: 'POST',
body: JSON.stringify(req),
headers: {
Authorization: `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
});
const resJSON = await res.json();
console.log(resJSON);
import os
import requests
import json
API_KEY = os.environ.get("STABLECOG_API_KEY")
API_HOST = "https://api.stablecog.com"
API_ENDPOINT = "/v1/image/generation/create"
API_URL = f"{API_HOST}{API_ENDPOINT}"
req = {
"prompt": "red cat wearing a purple hat"
}
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
res = requests.post(API_URL, data=json.dumps(req), headers=headers)
res_json = res.json()
print(json.dumps(res_json, indent=2))
Response
{
"outputs": [···],
"remaining_credits": 1392,
"settings": {···}
}
Request Headers
Authorization required
string
Authorization: Bearer <YOUR_STABLECOG_API_KEY>
.Request Body
prompt required
string
model_id
(enum) TGenerationModelID
width
min256 max1024 | int
8
and follow this formula:
width * height * inference steps <= 1024 * 1024 * 30
.height
min256 max1024 | int
8
and follow this formula:
height * width * inference steps <= 1024 * 1024 * 30
.negative_prompt
string
prompt
.num_outputs
min1 max4 | int
guidance_scale
min1 max20 | float
inference_steps
min10 max50 | int
inference steps * width * height < 50 * 640 * 640
.scheduler_id
(enum) TGenerationSchedulerID
seed
int
init_image_url
string
img2img
or image to image
generations.prompt_strength
min0 max1 | float
init_image_url
and prompt
. Higher value will follow the prompt
more closely, lower value will follow the init_image_url
more closely.Response Body
outputs
array of TOutput
remaining_credits
float
settings
(object) TGenerationSettings