Enterprise: Update S3 Details Endpoint
Overview
This endpoint is used to update the S3 details on your dedicated server. It is important you add s3 details for each of your server. The available server includes text_to_image
, image_editing
, voice_cloning
,text_to_3d
,face_gen
, deepfake
, realtime
, flux
and interior
.
Request
--request POST 'https://modelslab.com/api/v1/enterprise/update_s3' \
Send a POST
request to https://modelslab.com/api/v1/enterprise/update_s3 endpoint. You have to pass the below listed request body parameters to update the S3 details.
You can use any S3 compatible service like Cloudflare R2, Digital Ocean Spaces, AWS S3, Google Cloud Storage, Alibaba OSS, Backblaze, etc.
You need to give PutObjectAcl on S3 bucket. Else you won't be able to upload images to S3 bucket.
Here is link to stackoverflow on how to do it: https://stackoverflow.com/questions/36272286/getting-access-denied-when-calling-the-putobject-operation-with-bucket-level-per
Attributes
Parameter | Description |
---|---|
key | Your enterprise API Key of the particular server deploy type you want to add s3 details for. |
deploy_type | This is the server type you want to add the s3 details for. It includes text_to_image , image_editing , voice_cloning ,text_to_3d , video , face_gen , deepfake , realtime ,super_resolution , flux and interior . If nothing is passed text_to_image will be the default |
public_url | A public URL on which images can be accessible. Make sure to make your bucket publicly accessible, so you can access the links. |
region_name | S3 region name. |
endpoint_url | S3 endpoint URL. |
aws_access_key_id | Bucket's access key. |
aws_secret_access_key | Bucket's secret key. |
image_directory | The image directory inside the S3 bucket, where images will be stored. For instance, create a directory named "generations" inside the bucket and make sure it is public, so you can access the images using their links. |
Example
Body
{
"key": "enterprise_api_key",
"deploy_type": "text_to_image",
"public_url": "https://cdn2.stablediffusionapi.com/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
}
Google Cloud Example
{
"key": "enterprise_api_key",
"deploy_type": "text_to_image",
"public_url": "https://cdn2.stablediffusionapi.com/generations/",
"region_name": "US-CENTRAL1",
"endpoint_url": "https://storage.googleapis.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"public_url": "https://cdn2.stablediffusionapi.com/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v1/enterprise/update_s3", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"deploy_type": "text_to_image",
"public_url" => "https://cdn2.stablediffusionapi.com/generations/",
"region_name" => "us-east-1",
"endpoint_url" => "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id" => "access-key",
"aws_secret_access_key" => "secret-key",
"image_directory" => "generations"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v1/enterprise/update_s3',
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/update_s3',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"deploy_type": "text_to_image",
"public_url": "https://cdn2.stablediffusionapi.com/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
})
};
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/update_s3"
payload = json.dumps({
"key": "",
"deploy_type": "text_to_image",
"public_url": "https://cdn2.stablediffusionapi.com/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
})
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 \"public_url\": \"https://cdn2.stablediffusionapi.com/generations/\",\n \"region_name\": \"us-east-1\",\n \"endpoint_url\": \"https://stable-diffusion-api.s3.amazonaws.com\",\n \"aws_access_key_id\": \"access-key\",\n \"aws_secret_access_key\": \"secret-key\",\n \"image_directory\": \"generations\"\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v1/enterprise/update_s3")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Make sure to give below permissions to your IAM user to upload images on S3 bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:PutObject",
"s3:GetObject",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::stable-diffusion-api",
"arn:aws:s3:::stable-diffusion-api/*"
]
}
]
}