Sketch
This service offers an ideal solution for design projects that require brainstorming and frequent iterations. It upgrades rough hand-drawn sketches to refined outputs with precise control. For non-sketch images, it allows detailed manipulation of the final appearance by leveraging the contour lines and edges within the image.
Credits
The service uses 6 credits per successful result. You will not be charged for failed results.
Example Request and Response
API Documentation
API Endpoint | Method |
---|---|
/api/control/sketch | POST |
Request Header
Parameter | Description |
---|---|
Authentication | Use your API key to authentication requests to this App. |
Request Body
The request should include a JSON object in the body with the following parameters:
Parameter | Type | Required | Description |
---|---|---|---|
image | string <binary> | Yes | Image Dimensions:Every side must be at least 64 pixels;The total pixel count cannot exceed 9,437,184 pixels (e.g. 3072x3072, 4096x2304, etc.) |
prompt | string | Yes | [ 1 .. 10000 ] What you wish to see in the output image. A strong, descriptive prompt that clearly defines elements, colors, and subjects will lead to better results. |
control_strength | number | No | [ 0 .. 1 ] How much influence, or control, the image has on the generation. Represented as a float between 0 and 1, where 0 is the least influence and 1 is the maximum. |
negative_prompt | string | No | A blurb of text describing what you do not wish to see in the output image.This is an advanced feature. |
seed | number | No | [ 0 .. 4294967294 ], A specific value that is used to guide the 'randomness' of the generation. (Omit this parameter or pass 0 to use a random seed.) |
output_format | string | No | Enum: jpeg png webp |
Response Body
The response should include a JSON object in the body with the following parameters:
Parameter | Type | Description |
---|---|---|
code | int | Status Code, 0 for success callback, -1 for failure callback |
message | string | Callback message, 'success' for success, failure reason for failure |
data | object | Image Details |
Image Details
Parameter | Type | Description |
---|---|---|
image | string | Return the base64 encoded image of the generated picture. |
seed | int | The seed used as random noise for this generation. |
Example Request
import requests
response = requests.post(
f"https://www.aithriving.com/api/control/sketch",
headers={
"authorization": f"your-auth-token"
},
files={
"image": open("./your-image.png", "rb")
},
data={
"prompt": "your-prompt",
"output_format": "webp",
},
)
if response.status_code == 200:
data = response.json()
if data['code'] == 0:
// image: data['data']['image']
else:
// error
else:
raise Exception(str(response.json()))
Example Response
{
"code": 0,
"message": "success",
"data": {
"image": "base64 encoded image data",
"seed": 1050625087
}
}