Magic Mix Endpoint
Overview
This endpoint allow you to magic mix image and prompt to produce an catching images
Request
--request POST 'https://modelslab.com/api/v6/image_editing/magic_mix' \
Make a POST
request to https://modelslab.com/api/v6/image_editing/magic_mix endpoint and pass the required parameters as a request body to the endpoint.
Body Attributes
Parameter | Description | Values |
---|---|---|
key | Your API Key used for request authorization | key |
prompt | Text prompt with a description of the things you want in the image to be generated | string |
negative_prompt | Items you don't want in the image | string |
image | Link or valid base64 data following the format data:image/jpeg;base64,{your_base64_string} for the image you want your generations to resemble | URL, base64 string |
width | The width of the image. Default: 768 pixels. Max: 1024 pixels | integer |
height | The height of the image. Default: 768 pixels. Max: 1024 pixels | integer |
kmin | Minimum k value. Default: 0.3 . Max: 1 | float |
kmax | Maximum k value. Default: 0.5 . Max: 1 | float |
mix_factor | Mix factor for the task. Default: 0.5 . Max: 1 | float |
steps | Number of denoising steps. Default: 20 . Min: 1 . Max: 50 | integer |
base64 | If provided image is in base64 format or if you want your generated images as a base64 string, set this to true. Default: false | boolean (true, false) |
samples | Number of images to be returned in response. Max: 1 | integer |
seed | Seed used to reproduce results. Same seed will give you the same image again. Pass null for a random number | integer, null |
webhook | Set a URL to receive a POST API call once the image generation is complete | URL |
track_id | This ID is returned in the response to the webhook API call and will be used to identify the webhook request | integer |
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/v6/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/v6/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/v6/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/v6/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
}
}