Enterprise: Magic Mix Endpoint
Overview
This endpoint allow you to magic mix image and prompt to produce an catching images
caution
Make sure you add your s3 details for image_editing
server, so you can receive image generated in your bucket.
Images generated without s3 details being added will be delete after 24hours
Request
--request POST 'https://modelslab.com/api/v1/enterprise/image_editing/magic_mix' \
Make a POST
request to https://modelslab.com/api/v1/enterprise/image_editing/magic_mix endpoint and pass the required parameters as a request body to the endpoint.
Body Attributes
Parameter | Description |
---|---|
key | Your API Key used for request authorization |
prompt | Text prompt with description of the things you want in the image to be generated |
negative_prompt | Items you don't want in the image |
image | url of the image you want magic mix |
width | Max Height: Default 768 |
height | Max Height: Default 768 |
kmin | Optional. Minimum k value. Default is 0.3 |
kmax | Optional. Maximum k value. Default is 0.5 |
mix_factor | Optional. Mix factor for the task. Default is 0.5 |
steps | Number of denoising steps (minimum: 1; maximum: 50) Default is 20 |
samples | Number of images to be returned in response. The maximum value is 1. |
seed | Seed is used to reproduce results, same seed will give you same image in return again. Pass null for a |
webhook | Set an URL to get a POST API call once the image generation is complete. |
track_id | This ID is returned in the response to the webhook API call. This will be used to identify the webhook request. |
Example
Body
Body
{
"key":"",
"prompt":"Bed",
"height":768,
"width":768,
"image":"https://user-images.githubusercontent.com/59410571/209578593-141467c7-d831-4792-8b9a-b17dc5e47816.jpg",
"kmax":0.5,
"kmin":0.3,
"mix_factor":0.5,
"samples":1,
"negative_prompt":"low quality",
"seed":1829183163,
"steps":20,
"webhook": null,
"track_id": null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key":"",
"prompt":"Bed",
"height":768,
"width":768,
"image":"https://user-images.githubusercontent.com/59410571/209578593-141467c7-d831-4792-8b9a-b17dc5e47816.jpg",
"kmax":0.5,
"kmin":0.3,
"mix_factor":0.5,
"samples":1,
"negative_prompt":"low quality",
"seed":1829183163,
"steps":20,
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v1/enterprise/image_editing/magic_mix", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"prompt" => "Bed",
"height" => 768,
"width" => 768,
"image" => "https://user-images.githubusercontent.com/59410571/209578593-141467c7-d831-4792-8b9a-b17dc5e47816.jpg",
"kmax" => 0.5,
"kmin" => 0.3,
"mix_factor" => 0.5,
"samples" => 1,
"negative_prompt" => "low quality",
"seed" => 1829183163,
"steps" => 20,
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v1/enterprise/image_editing/magic_mix',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v1/enterprise/image_editing/magic_mix',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key":"",
"prompt":"Bed",
"height":768,
"width":768,
"image":"https://user-images.githubusercontent.com/59410571/209578593-141467c7-d831-4792-8b9a-b17dc5e47816.jpg",
"kmax":0.5,
"kmin":0.3,
"mix_factor":0.5,
"samples":1,
"negative_prompt":"low quality",
"seed":1829183163,
"steps":20,
"webhook": null,
"track_id": null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v1/enterprise/image_editing/magic_mix"
payload = json.dumps({
"key":"",
"prompt":"Bed",
"height":768,
"width":768,
"image":"https://user-images.githubusercontent.com/59410571/209578593-141467c7-d831-4792-8b9a-b17dc5e47816.jpg",
"kmax":0.5,
"kmin":0.3,
"mix_factor":0.5,
"samples":1,
"negative_prompt":"low quality",
"seed":1829183163,
"steps":20,
"webhook": None,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"key\":\"\",\n \"prompt\":\"Bed\",\n \"height\":768,\n \"width\":768,\n \"image\":\"https://user-images.githubusercontent.com/59410571/209578593-141467c7-d831-4792-8b9a-b17dc5e47816.jpg\",\n \"kmax\":0.5,\n \"kmin\":0.3,\n \"mix_factor\":0.5,\n \"samples\":1,\n \"negative_prompt\":\"low quality\",\n \"seed\":1829183163,\n \"steps\":20,\n \"webhook\": null,\n \"track_id\": null \n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v3/magic_mix")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Example Response
{
"status": "success",
"generationTime": 7.986585378646851,
"id": 511,
"output": [
"https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/424151c6-00fd-4837-aaef-8b98a5c09f38.png"
],
"meta": {
"H": 768,
"W": 768,
"file_prefix": "424151c6-00fd-4837-aaef-8b98a5c09f38",
"image": "https://user-images.githubusercontent.com/59410571/209578593-141467c7-d831-4792-8b9a-b17dc5e47816.jpg",
"kmax": 0.5,
"kmin": 0.3,
"mix_factor": 0.5,
"n_samples": 1,
"negative_prompt": "low quality",
"outdir": "out",
"prompt": "Bed",
"seed": 1829183163,
"steps": 20
}
}