mrhan1993 / FooocusAPI

Fooocus with fastapi
https://mrhan1993.github.io/docs
GNU General Public License v3.0
17 stars 4 forks source link
fooocus fooocus-api fooocusapi

中文

Introduction

FastAPI is a modern, fast (high-performance) web framework for building APIs. This project builds the Rest interface of Fooocus based on Fastapi.

For a partial description of Fooocus, please refer to the Fooocus documentation, which mainly introduces the interface section.

Compared to the previous API project Fooocus-API, there are major changes:

You can get a guide here if you use the previous API project.

advantage:

Functional features

Install

Based on Fooocus, there are several dependencies, so you can install it in the same way as Fooocus.

Startup

Same as Fooocus, use --apikey to specify the API authentication key.

Default API port is WebUI port plus 1, that is 7866, use --port to modify WebUI port

Environment variable API_PORT is used to specify the API port. It takes precedence over the default setting.

example for WebUI and API:

python launch.py --listen 0.0.0.0 --port 7865

Only API example:

python launch.py --listen 0.0.0.0 --port 7865 --nowebui

Security

Use --apikey to specify the API authentication key on startup.

EndPoints

Generate

POST /v1/engine/generate/

Explain:

Request parameter model CommonRequest contains all parameters of WebUI, but some parameters you need to pay attention to when using them, including the following categories:

Invalid parameters in the API, this part of the parameter contains:

Parameters that are not recommended:

The following parameters need to be set according to the usage scenario:

In addition, some API-specific parameters are also included:

stream_output has a higher priority than async_process, that is, when both are true, return streaming output. When all are false, task will be synchronously returned. when you set Accept: image/xxx in the request header, the response will be a binary image

Stop or Skip

POST /v1/engine/control/

Get tasks

GET /tasks

Although all models are based on RecordResponse, the current one will have a preview field

Get task by id

GET /tasks/{task_id}

Get all models

GET /v1/engines/all-models

Get all styles

GET /v1/engines/styles

Get output file

GET /outputs/{date}/{file_name}

if you set Accept: image/xxx in the request header, server will convert the output to the specified format and return it. image/png image/jpeg image/webp image/jpg are supported.

Describe image

POST /v1/tools/describe-image

Root

GET /

Components

Model

CommonRequest

Lora

UpscaleOrVaryMethod

ImagePrompt

DescribeImageResponse

RecordResponse

Thanks

This project is based on Fooocus-API, thanks all the developers who participated in this project.

Contribute