Skip to main content

Upload Model

Overview​

This endpoint is used to load a private or public model

Request​

--request POST 'https://modelslab.com/api/v3/load_model' \

Send a POST request to https://modelslab.com/api/v3/load_model endpoint.

note

To load a private model you must have purchased model credit from private model page.

Attributes​

ParameterDescriptionValues
keyYour API Key used for request authorization.string
urlThe URL of the Huggingface model, CKPT download link, or Safetensors model.URL
model_idChoose a name (ID) for your model. The loaded model will be saved under this ID.id
force_loadSet this to "yes" if you want to reload automatically once upload fails; otherwise pass "no"."yes"/"no"
model_formatAvailable options are "diffusers", "safetensors", or "ckpt"."diffusers", "safetensors", "ckpt"
revisionSpecify whether the loaded model is "fp16" or "fp32"."fp16", "fp32"
model_categoryThe category of the model you want to upload.stable_diffusion, stable_diffusion_xl,flux
model_subcategoryThe sub category of the model you want to upload. If you want to load a checkout model, leave the model_subcategory empty. If you want to load a lora model, the model_subcategory should be loracontrolnet, lora
model_visibilityIt accepts "private" or "public"."private", "public"
model_nameThe name you want to give your model.id
model_imageA valid image URL to display the model when uploaded.URL
hf_uploadIt accepts "yes" or "no"."yes"/"no"

Examples​

Load a ckpt or safetensors Model from Civitai​

Body Raw
{
"key": "api_key",
"url": "https://civitai.com/api/download/models/132760?type=Model&format=SafeTensor&size=pruned&fp=fp16",
"revision": "fp32",
"model_id": "stable-diffusion-1.0-inpainting-0.1",
"force_load": "yes",
"model_category": "stable_diffusion_xl",
"model_format": "safetensors",
"model_visibility": "public",
"model_name": "stable-diffusion-1.0-inpainting-0.1",
"model_image": "https://cdn2.stablediffusionapi.com/generations/1a14cab3-cc79-4cee-ab28-29379bff766b-0.png",
"hf_upload": "no"
}

Load a diffusers​

Body Raw
{
"key": "api_key",
"url": "diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
"model_id": "stable-diffusion-xl-1.0-inpainting-0.1",
"force_load": "yes",
"revision": "fp16",
"model_category": "stable_diffusion_xl",
"model_format": "diffusers",
"model_visibility": "public",
"model_name": "stable-diffusion-xl-1.0-inpainting-0.1",
"model_image": "https://cdn2.stablediffusionapi.com/generations/1a14cab3-cc79-4cee-ab28-29379bff766b-0.png",
"hf_upload": "no"
}
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
"key": "",
"url": "diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
"model_id": "stable-diffusion-xl-1.0-inpainting-0.1",
"force_load": "yes",
"revision": "fp16",
"model_category": "stable_diffusion_xl",
"model_format": "diffusers",
"model_visibility": "private",
"model_name": "stable-diffusion-xl-1.0-inpainting-0.1",
"model_image": "https://cdn2.stablediffusionapi.com/generations/1a14cab3-cc79-4cee-ab28-29379bff766b-0.png",
"hf_upload": "no"
});

var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};

model_reload("https://modelslab.com/api/v3/load_model", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Response​

{
"status": "success",
"message": "model load started",
}