Upload Model
Overview
This endpoint is used to load a private or public model
Request
--request POST 'https://stablediffusionapi.com/api/v3/load_model' \
Send a POST
request to https://stablediffusionapi.com/api/v3/load_model endpoint.
note
To load a private model you must have purchased model credit from private model page.
Attributes
Parameter | Description |
---|---|
key | Your API Key used for request authorization. |
url | The URL of the huggingface model, ckpt download link, or safetensors model |
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. |
force_load | Set this to "yes" if you want to reload automatically once upload fails; otherwise pass "no". |
model_format | Available options: "diffusers", "safetensors", "ckpt". |
revision | Specify whether the loaded model is "fp16" or "fp32". |
model_category | The category of the model you want to upload, it accepts any of these;stable_diffusion,stable_diffusion_xl, controlnet, lora, embeddings,vae |
model_visibility | It accepts private or public. |
model_name | This is the name you want to give your model. |
model_image | A valid image url of to display the model when uploaded. |
hf_upload | It accepts yes or 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",
"model_id": "majicmix-realistic",
"revision": "fp32",
"model_id": "stable-diffusion-1.0-inpainting-0.1",
"force_load": "yes",
"revision": "fp16",
"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"
}
- JS
- PHP
- NODE
- PYTHON
- JAVA
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://stablediffusionapi.com/api/v3/load_model", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"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"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://stablediffusionapi.com/api/v3/load_model',
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://stablediffusionapi.com/api/v3/load_model',
'headers': {
'Content-Type': 'application/json'
},
body: 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"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://stablediffusionapi.com/api/v3/load_model"
payload = json.dumps({
"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"
})
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\": \"diffusers/stable-diffusion-xl-1.0-inpainting-0.1\",\n \"model_id\": \"stable-diffusion-xl-1.0-inpainting-0.1\",\n \"force_load\": \"yes\", \n \"revision\": \"fp16\",\n \"model_category\": \"stable_diffusion_xl\",\n \"model_subcategory\": null,\n \"model_format\": \"diffusers\",\n \"model_visibility\": \"private\",\n \"model_name\": \"stable-diffusion-xl-1.0-inpainting-0.1\",\n \"model_image\": \"https://cdn2.stablediffusionapi.com/generations/1a14cab3-cc79-4cee-ab28-29379bff766b-0.png\",\n \"hf_upload\": \"no\"\n}");
Request request = new Request.Builder()
.url("https://stablediffusionapi.com/api/v3/load_model")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"message": "model load started",
}