stable-diffusion-aws-extension/docs/middleware-api.yaml

1020 lines
31 KiB
YAML

openapi: "3.0.2"
info:
title: "Stable Diffusion Train and Deploy API"
description: "This service is used to train and deploy Stable Diffusion models."
version: "2023-07-05"
servers:
- url: "https://<Your API Gateway ID>.execute-api.<Your AWS Account Region>.amazonaws.com/{basePath}"
variables:
basePath:
default: "prod"
paths:
/model:
post:
security:
- api_key: []
tags:
- default
summary: Create Model
requestBody:
content:
application/json:
schema:
type: object
example:
model_type: Stable-diffusion
name: testmodelcreation01
filenames:
- filename: v1-5-pruned-emaonly.safetensors.tar
parts_number: 5
params:
create_model_params:
new_model_name: testmodelcreation01
ckpt_path: v1-5-pruned-emaonly.safetensors
from_hub: false
new_model_url: ''
new_model_token: ''
extract_ema: false
train_unfrozen: false
is_512: true
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
job:
id: id
status: Initialed
s3_base: s3://S3_Location
model_type: Stable-diffusion
params: {}
s3PresignUrl:
- upload_id: id
bucket: bucket name
key: object key
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
put:
security:
- api_key: []
tags:
- default
summary: Update Model
requestBody:
content:
application/json:
schema:
type: object
example:
model_id: c9f59ee7-0672-4fd1-8a45-8a494de8a48d
status: Creating
multi_parts_tags:
v1-5-pruned-emaonly.safetensors.tar:
- ETag: cc95c41fa28463c8e9b88d67805f24e0
PartNumber: 1
- ETag: e4378bd84b0497559c55be8373cb79d0
PartNumber: 2
- ETag: 815b68042f6ac5e60b9cff5c697ffea6
PartNumber: 3
- ETag: 2c6cfbd9bfbafd5664cdc8b3ba07df6d
PartNumber: 4
- ETag: e613d37e5065b0cd63f1cad216423141
PartNumber: 5
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
job:
output_path: s3://S3_Location
id: job.id
endpointName: endpoint_name
jobStatus: Created
jobType: Stable-diffusion
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/models:
get:
security:
- api_key: []
tags:
- default
summary: List Models
parameters:
- name: types
in: query
schema:
type: array
items:
type: string
example:
- Stable-diffusion
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
models:
id: id
model_name: name
created: 12341234.0
params: {}
status: Initialed
output_s3_location: s3://S3_LOCATION/
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/checkpoint:
post:
security:
- api_key: []
tags:
- default
summary: Create Checkpoint
requestBody:
content:
application/json:
schema:
type: object
example:
checkpoint_type: Stable-diffusion
filenames:
- filename: v1-5-pruned-emaonly.safetensors
parts_number: 5
params:
new_model_name: test_api
number: 1
string: abc
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
checkpoint:
id: id
type: Stable-diffusion
s3_location: s3://S3_Location
status: Initialed
params: {}
s3PresignUrl:
- upload_id: id,
bucket: bucket name,
key: key,
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
put:
security:
- api_key: []
tags:
- default
summary: Update Checkpoints
requestBody:
content:
application/json:
schema:
type: object
example:
checkpoint_id: 906a5a1f-6833-45aa-8a10-fb0e983e0eae
status: Active
multi_parts_tags:
v1-5-pruned-emaonly.safetensors.tar:
- ETag: cc95c41fa28463c8e9b88d67805f24e0
PartNumber: 1
- ETag: e4378bd84b0497559c55be8373cb79d0
PartNumber: 2
- ETag: 815b68042f6ac5e60b9cff5c697ffea6
PartNumber: 3
- ETag: 2c6cfbd9bfbafd5664cdc8b3ba07df6d
PartNumber: 4
- ETag: e613d37e5065b0cd63f1cad216423141
PartNumber: 5
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
checkpoint:
id: id
type: Stable-diffusion
s3_location: s3://S3_Location
status: Active
params: {}
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/checkpoints:
get:
security:
- api_key: []
tags:
- default
summary: List Checkpoints
parameters:
- name: status
in: query
schema:
type: array
items:
type: string
example:
- Active
- name: types
in: query
schema:
type: array
items:
type: string
example:
- Stable-diffusion
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
checkpoints:
- id: id
s3Location: s3://S3_Location
type: Stable-diffusion
status: Active
name:
- object_1
- object_2
created: 12341234.0
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/train:
post:
security:
- api_key: []
tags:
- default
summary: Create Train Job
requestBody:
content:
application/json:
schema:
type: object
example:
train_type: dreambooth
model_id: 36c9d05e-3445-42a6-8be1-d7d054df7b9d
params:
train_params:
training_instance_type: ml.g4dn.2xlarge
test1: 2
filenames:
- training_config.json
- images.tar
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
job:
id: id
status: Initialed
trainType: Stable-diffusion
params: {}
input_location: s3://S3_Location
s3PresignUrl:
- filename: s3://S3_Location
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
put:
security:
- api_key: []
tags:
- default
summary: Update Train job
requestBody:
content:
application/json:
schema:
type: object
example:
train_job_id: b5183dd3-0279-46ff-b64e-6cd687c0fe71
status: Training
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
job:
id: id
status: Training
created: 12341234.0
trainType: Stable-diffusion
params: {}
input_location: s3://S3_Location
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/trains:
get:
security:
- api_key: []
tags:
- default
summary: List Train Jobs
parameters:
- name: types
in: query
schema:
type: array
items:
type: string
example: Stable-diffusion
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200,
trainJobs:
- id: id
modelName: model_name
status: Complete
trainType: Stable-diffusion
created: 1234124.0
sagemakerTrainName: sagemaker_train_name
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/dataset:
post:
security:
- api_key: []
tags:
- default
summary: Create Dataset
requestBody:
content:
application/json:
schema:
type: object
example:
dataset_name: test_dataset
content:
- filename: /path/to/a/file.png
name: another_name
type: png
params: {}
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
datasetName: dataset_name
s3PresignUrl:
- filename: s3://S3_Location
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
put:
security:
- api_key: []
tags:
- default
summary: Update Dataset
requestBody:
content:
application/json:
schema:
type: object
example:
dataset_name: test_dataset
status: Enabled
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
datasetName: dataset_name
status: Enabled
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/prod/datasets:
get:
security:
- api_key: []
tags:
- default
summary: List Datasets by dataset status
parameters:
- name: dataset_status
in: query
schema:
type: array
items:
type: string
example:
- Enabled
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
datasets:
- datasetName: dataset_name
s3: s3://S3_Location
status: Enabled
timestamp: 1234124.0
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
/{dataset_name}/data:
get:
security:
- api_key: []
tags:
- default
summary: List Dataset Items by Dataset Name
parameters:
- name: dataset_name
in: path
schema:
type: string
required: true
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
example:
statusCode: 200
dataset_name: dataset_name
data:
- key: key
name: file name
type: image
preview_url: https://presigned_s3_url
dataStatus: Enabled
'500':
description: Error response
content:
application/json:
schema:
type: object
example:
statusCode: 500
error: error_message
# Inference Start
/inference:
get:
summary: Root
operationId: root_inference_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/test-connection:
get:
summary: used to let client test connection
operationId: test_connection_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/run-sagemaker-inference:
post:
summary: Run Sagemaker Inference
operationId: run_sagemaker_inference_inference_run_sagemaker_inference_post
requestBody:
content:
application/json:
schema:
type: object
example:
Stable-diffusion: {}
embeddings:
FastNegativeV2.pt: s3://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3/embeddings/checkpoint/custom/c65307dd-c0ee-4649-a900-596f144cd330/FastNegativeV2.pt
okuryl3nko.pt: s3://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3/embeddings/checkpoint/custom/219dff2e-a1f0-4a70-9b2b-2bbc21295db7/okuryl3nko.pt
Lora:
3DMM_V12.safetensors: s3://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3/Lora/checkpoint/custom/ccbd651b-f239-4776-875a-034377849cb3/3DMM_V12.safetensors
hypernetworks:
streetArt_v10.pt: s3://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3/hypernetworks/checkpoint/custom/b89cb29f-eba5-4f37-939a-61099f8e13a5/streetArt_v10.pt
ControlNet: {}
sagemaker_endpoint: infer-endpoint-cb821ea
task_type: txt2img
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
example:
# {"inference_id": inference_id, "status": "inprogress", "endpoint_name": endpoint_name, "output_path": output_path}
inference_id: XXXXXXX
status: inprogress | failed
endpoint_name: NAME_OF_ENDPOINT
output_path: path_of_prediction_output
/inference/deploy-sagemaker-endpoint:
post:
summary: Deploy Sagemaker Endpoint
operationId: deploy_sagemaker_endpoint_inference_deploy_sagemaker_endpoint_post
requestBody:
content:
application/json:
schema:
type: object
example:
instance_type: ml.g4dn.xlarge | ml.g4dn.2xlarge | ml.g4dn.4xlarge
initial_instance_count: 1|2|3|4
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/delete-sagemaker-endpoint:
post:
summary: Delete Sagemaker Endpoint
operationId: delete_sagemaker_endpoint_inference_delete_sagemaker_endpoint_post
requestBody:
content:
application/json:
schema:
type: object
example:
delete_endpoint_list: ['infer-endpoint-XXXXXX','infer-endpoint-YYYYYY']
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/list-endpoint-deployment-jobs:
get:
summary: List Endpoint Deployment Jobs
operationId: list_endpoint_deployment_jobs_inference_list_endpoint_deployment_jobs_get
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
example:
- EndpointDeploymentJobId: e0f9ccfd-8d14-4e77-9e75-b340e1ef23c8
startTime: '2023-07-04 08:00:35.171309'
endTime: '2023-07-04 08:00:37.158519'
error: ''
status: failed
- EndpointDeploymentJobId: 1bd447d2-e561-4cb3-965d-2707b30aea81
startTime: '2023-07-04 08:00:22.435828'
endTime: '2023-07-04 08:00:25.421777'
error: ''
status: failed
- EndpointDeploymentJobId: cb821ea9-e9d1-4bae-98f8-c20ecadf11e0
startTime: '2023-07-04 08:00:47.736033'
endTime: '2023-07-04 08:12:55.148070'
endpoint_name: infer-endpoint-cb821ea
endpoint_status: InService
status: success
/inference/list-inference-jobs:
get:
summary: List Inference Jobs
operationId: list_inference_jobs_inference_list_inference_jobs_get
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
example:
- inference_info_name: "/tmp/417d8bc5-f6d0-49c6-9669-c981beeb602a_param.json"
startTime: '2023-07-04 09:14:21.170303'
taskType: txt2img
completeTime: 2023-07-04-09-14-26
InferenceJobId: '417d8bc5-f6d0-49c6-9669-c981beeb602a'
status: succeed
sagemakerRaw: ""
image_names:
- image_0.jpg
- inference_info_name: "/tmp/1f9679f3-25b8-4c44-8345-0a845da30094_param.json"
startTime: '2023-07-05 06:38:45.752740'
taskType: txt2img
completeTime: 2023-07-05-06-38-49
InferenceJobId: 1f9679f3-25b8-4c44-8345-0a845da30094
status: succeed
sagemakerRaw: "{'awsRegion': 'us-west-2', 'eventTime': '2023-07-05T06:38:47.73Z', 'receivedTime': '2023-07-05T06:38:45.725Z', 'invocationStatus': 'Completed', 'requestParameters': {'accept': '*/*', 'endpointName': 'infer-endpoint-cb821ea', 'inputLocation': 's3://sagemaker-us-west-2-489670441870/async-endpoint-inputs/infer-endpoint-cb821ea-230705-0638/2023-07-05-06-38-45-445-81a1ec03-f000-4a20-9a60-032ab1558a9d'}, 'responseParameters': {'contentType': 'application/json', 'outputLocation': 's3://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3/sagemaker_output/211d2095-68bc-4404-a9e1-8a18a41f4dc7.out'}, 'inferenceId': '1f9679f3-25b8-4c44-8345-0a845da30094', 'eventVersion': '1.0', 'eventSource': 'aws:sagemaker', 'eventName': 'InferenceResult'}"
image_names:
- image_0.jpg
/inference/get-endpoint-deployment-job:
get:
summary: Get Endpoint Deployment Job
operationId: get_endpoint_deployment_job_inference_get_endpoint_deployment_job_get
parameters:
- required: true
schema:
title: Jobid
type: string
name: jobID
in: query
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
example:
EndpointDeploymentJobId: cb821ea9-e9d1-4bae-98f8-c20ecadf11e0
startTime: '2023-07-04 08:00:47.736033'
endTime: '2023-07-04 08:12:55.148070'
endpoint_name: infer-endpoint-cb821ea
endpoint_status: InService
status: success
'422':
description: Validation Error
content:
application/json:
schema:
"$ref": "#/components/schemas/HTTPValidationError"
/inference/get-inference-job:
get:
summary: Get Inference Job
operationId: get_inference_job_inference_get_inference_job_get
parameters:
- required: false
schema:
title: Jobid
type: string
name: jobID
in: query
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
example:
inference_info_name: "/tmp/1f9679f3-25b8-4c44-8345-0a845da30094_param.json"
startTime: '2023-07-05 06:38:45.752740'
taskType: txt2img
completeTime: 2023-07-05-06-38-49
InferenceJobId: 1f9679f3-25b8-4c44-8345-0a845da30094
status: succeed
sagemakerRaw: "{'awsRegion': 'us-west-2', 'eventTime': '2023-07-05T06:38:47.73Z', 'receivedTime': '2023-07-05T06:38:45.725Z', 'invocationStatus': 'Completed', 'requestParameters': {'accept': '*/*', 'endpointName': 'infer-endpoint-cb821ea', 'inputLocation': 's3://sagemaker-us-west-2-489670441870/async-endpoint-inputs/infer-endpoint-cb821ea-230705-0638/2023-07-05-06-38-45-445-81a1ec03-f000-4a20-9a60-032ab1558a9d'}, 'responseParameters': {'contentType': 'application/json', 'outputLocation': 's3://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3/sagemaker_output/211d2095-68bc-4404-a9e1-8a18a41f4dc7.out'}, 'inferenceId': '1f9679f3-25b8-4c44-8345-0a845da30094', 'eventVersion': '1.0', 'eventSource': 'aws:sagemaker', 'eventName': 'InferenceResult'}"
image_names:
- image_0.jpg
'422':
description: Validation Error
content:
application/json:
schema:
"$ref": "#/components/schemas/HTTPValidationError"
/inference/get-inference-job-image-output:
get:
summary: Get Inference Job Image Output
operationId: get_inference_job_image_output_inference_get_inference_job_image_output_get
parameters:
- required: false
schema:
title: Jobid
type: string
name: jobID
in: query
responses:
'200':
description: Successful Response
content:
application/json:
schema:
title: Response Get Inference Job Image Output Inference Get Inference
Job Image Output Get
type: array
items:
type: string
example:
- https://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3.s3.amazonaws.com/out/1f9679f3-25b8-4c44-8345-0a845da30094/result/image_0.jpg
'422':
description: Validation Error
content:
application/json:
schema:
"$ref": "#/components/schemas/HTTPValidationError"
/inference/get-inference-job-param-output:
get:
summary: Get Inference Job Param Output
operationId: get_inference_job_param_output_inference_get_inference_job_param_output_get
parameters:
- required: false
schema:
title: Jobid
type: string
name: jobID
in: query
responses:
'200':
description: Successful Response
content:
application/json:
schema:
title: Response Get Inference Job Param Output Inference Get Inference
Job Param Output Get
type: array
items:
type: string
example:
- https://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3.s3.amazonaws.com/out/1f9679f3-25b8-4c44-8345-0a845da30094/result/1f9679f3-25b8-4c44-8345-0a845da30094_param.json
'422':
description: Validation Error
content:
application/json:
schema:
"$ref": "#/components/schemas/HTTPValidationError"
/inference/generate-s3-presigned-url-for-uploading:
get:
summary: Generate S3 Presigned Url For Uploading
operationId: generate_s3_presigned_url_for_uploading_inference_generate_s3_presigned_url_for_uploading_get
parameters:
- required: false
schema:
title: S3 Bucket Name
type: string
name: s3_bucket_name
in: query
- required: false
schema:
title: Key
type: string
name: key
in: query
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: string
example:
"https://stable-diffusion-aws-extension-aigcbucketa457cb49-1tlr2pqwkosg3.s3.amazonaws.com/config/aigc.json?XXX"
'422':
description: Validation Error
content:
application/json:
schema:
"$ref": "#/components/schemas/HTTPValidationError"
/inference/get-texual-inversion-list:
get:
summary: Get Textual Inversion List
operationId: get_texual_inversion_list_inference_get_texual_inversion_list_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/get-lora-list:
get:
summary: Get Lora List
operationId: get_lora_list_inference_get_lora_list_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/get-hypernetwork-list:
get:
summary: Get Hypernetwork List
operationId: get_hypernetwork_list_inference_get_hypernetwork_list_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/get-controlnet-model-list:
get:
summary: Get Controlnet Model List
operationId: get_controlnet_model_list_inference_get_controlnet_model_list_get
responses:
'200':
description: Successful Response
content:
application/json:
schema: {}
/inference/run-model-merge:
post:
summary: Run Model Merge
operationId: run_model_merge_inference_run_model_merge_post
responses:
'200':
description: Successful Response
content:
application/json:
schema:
type: object
example:
primary_model_name : primary_model_name,
secondary_model_name : secondary_model_name,
tertiary_model_name : teritary_model_name
# Inference End
components:
schemas:
Empty:
title: "Empty Schema"
type: "object"
HTTPValidationError:
title: HTTPValidationError
type: object
properties:
detail:
title: Detail
type: array
items:
"$ref": "#/components/schemas/ValidationError"
ValidationError:
title: ValidationError
required:
- loc
- msg
- type
type: object
properties:
loc:
title: Location
type: array
items:
anyOf:
- type: string
- type: integer
msg:
title: Message
type: string
type:
title: Error Type
type: string
securitySchemes:
api_key:
type: "apiKey"
name: "x-api-key"
in: "header"