Enterprise: Load Model V2 Endpoint
Overview
This endpoint is updated V2 version of the load_model endpoint. It allows you to load models from Huggingface, Civitai, and custom trained models.
Request
--request POST 'https://modelslab.com/api/v1/enterprise/load_model_v2' \
Send a POST
request to https://modelslab.com/api/v1/enterprise/load_model_v2 endpoint.
Watch the how-to video to see it in action.
Attributes
Parameter | Description |
---|---|
key | Your enterprise API Key used for request authorization. |
url | The URL of the huggingface model, .ckpt download link, or trained model from our Dreambooth API. |
model_id | Choose a name(ID) for your model. The loaded model will be saved under this ID, so you can refer to it when generating images. |
model_category | Available options: "lora", "embeddings", "stable_diffusion", "stable_diffusion_xl", "controlnet". |
model_format | Available options: "ckpt", "safetensors", "pt", "diffusers" |
revision | Specify whether the loaded model is "fp16" or "fp32". |
webhook | A webhook to receive response on model load events. |
ControlNet Model url and model_id table
url | model_id |
---|---|
lllyasviel/control_v11p_sd15_inpaint | inpaint |
lllyasviel/control_v11e_sd15_ip2p | ip2p |
lllyasviel/control_v11f1e_sd15_tile | tile |
lllyasviel/control_v11e_sd15_shuffle | shuffle |
lllyasviel/control_v11p_sd15_softedge | softedge |
lllyasviel/control_v11p_sd15_scribble | scribble |
lllyasviel/control_v11p_sd15_lineart | lineart |
lllyasviel/control_v11p_sd15_normalbae | normalbae |
lllyasviel/control_v11f1p_sd15_depth | depth |
lllyasviel/control_v11p_sd15_mlsd | mlsd |
lllyasviel/control_v11p_sd15_canny | canny |
Examples
Load a .ckpt or .safetensors Model from Civitai
Body Raw
{
"key": "enterprise_api_key",
"url": "https://civitai.com/api/download/models/94640",
"model_id": "majicmix-realistic",
"model_category": "stable_diffusion",
"model_format": "safetensors",
"webhook": "https://modelslab.com",
"revision": "fp16"
}
Load a .ckpt Model from Civitai
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"url": "https://civitai.com/api/download/models/94640",
"model_id": "majicmix-realistic",
"model_category": "stable_diffusion",
"model_format": "safetensors",
"webhook": "https://modelslab.com",
"revision": "fp16"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
model_reload("https://modelslab.com/api/v1/enterprise/load_model_v2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"url": "https://civitai.com/api/download/models/94640",
"model_id": "majicmix-realistic",
"model_category": "stable_diffusion",
"model_format": "safetensors",
"webhook": "https://modelslab.com",
"revision": "fp16"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v1/enterprise/load_model_v2',
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/load_model_v2',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"url": "https://civitai.com/api/download/models/94640",
"model_id": "majicmix-realistic",
"model_category": "stable_diffusion",
"model_format": "safetensors",
"webhook": "https://modelslab.com",
"revision": "fp16"
})
};
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/load_model_v2"
payload = json.dumps({
"key": "",
"url": "https://civitai.com/api/download/models/94640",
"model_id": "majicmix-realistic",
"model_category": "stable_diffusion",
"model_format": "safetensors",
"webhook": "https://modelslab.com",
"revision": "fp16"
})
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 \"url\": \"https://civitai.com/api/download/models/94640\",\n \"model_id\": \"nckpt-model\",\n \"model_category\": \"stable_diffusion\",\n \"webhook\": \"https://modelslab.com\",\n \"revision\": \"fp16\",\n \"model_format\": \"safetensors\"\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v1/enterprise/load_model_v2")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Load a Huggingface Model
Body Raw
{
"key": "enterprise_api_key",
"url": "wavymulder/Analog-Diffusion",
"model_id": "analog-diffusion",
"model_type": "huggingface",
"from_safetensors": "no",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
}
Request: Load a Huggingface Model
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "enterprise_api_key",
"url": "wavymulder/Analog-Diffusion",
"model_id": "analog-diffusion",
"model_type": "huggingface",
"from_safetensors": "no",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
model_reload("https://modelslab.com/api/v1/enterprise/load_model_v2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "enterprise_api_key",
"url" => "wavymulder/Analog-Diffusion",
"model_id" => "analog-diffusion",
"model_type" => "huggingface",
"from_safetensors": "no",
"webhook" => "https://modelslab.com",
"revision" => "fp32",
"upcast_attention" => "no"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v1/enterprise/load_model_v2',
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/load_model_v2',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "enterprise_api_key",
"url": "wavymulder/Analog-Diffusion",
"model_id": "analog-diffusion",
"model_type": "huggingface",
"from_safetensors": "no",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
})
};
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/load_model_v2"
payload = json.dumps({
"key": "enterprise_api_key",
"url": "wavymulder/Analog-Diffusion",
"model_id": "analog-diffusion",
"model_type": "huggingface",
"from_safetensors": "no",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
})
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\": \"enterprise_api_key\",\n \"url\": \"wavymulder/Analog-Diffusion\",\n \"model_id\": \"analog-diffusion\",\n \"model_type\": \"huggingface\",\n \"webhook\": \"https://modelslab.com\",\n \"revision\": \"fp32\",\n \"upcast_attention\": \"no\"\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v1/enterprise/load_model_v2")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Request Body: Load a ControlNet Model
Body Raw
{
"key": "enterprise_api_key",
"url": "lllyasviel/control_v11p_sd15_canny",
"model_id": "canny",
"model_type": "controlnet",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
}
Request: Load a ControlNet Model
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "enterprise_api_key",
"url": "lllyasviel/control_v11p_sd15_canny",
"model_id": "canny",
"model_type": "controlnet",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
model_reload("https://modelslab.com/api/v1/enterprise/load_model_v2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "enterprise_api_key",
"url" => "lllyasviel/control_v11p_sd15_canny",
"model_id" => "hed",
"model_type" => "controlnet",
"webhook" => "https://modelslab.com",
"revision" => "fp32",
"upcast_attention" => "no"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v1/enterprise/load_model_v2',
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/load_model_v2',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "enterprise_api_key",
"url": "lllyasviel/control_v11p_sd15_canny",
"model_id": "canny",
"model_type": "controlnet",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
})
};
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/load_model_v2"
payload = json.dumps({
"key": "enterprise_api_key",
"url": "lllyasviel/control_v11p_sd15_canny",
"model_id": "canny",
"model_type": "controlnet",
"webhook": "https://modelslab.com",
"revision": "fp32",
"upcast_attention": "no"
})
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\": \"enterprise_api_key\",\n \"url\": \"lllyasviel/control_v11p_sd15_canny\",\n \"model_id\": \"hed\",\n \"model_type\": \"controlnet\",\n \"webhook\": \"https://modelslab.com\",\n \"revision\": \"fp32\",\n \"upcast_attention\": \"no\"\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v1/enterprise/load_model_v2")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"message": "model load started",
"status": "success"
}