Download the PHP package minhyung/sdwebui without Composer

On this page you can find all versions of the php package minhyung/sdwebui. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sdwebui

minhyung/sdwebui

CI Latest version PHP version License

A fluent PHP SDK for the Stable Diffusion WebUI API.

Built on PSR interfaces only — no HTTP client is bundled or required. If you do not inject one, it is discovered from whatever your project already has.

Requirements

Installation

This package deliberately bundles no HTTP client, so you must supply one. Install it alongside:

or, with Guzzle:

composer require minhyung/sdwebui on its own is not enough. It will install cleanly — php-http/discovery satisfies the PSR implementation requirements on paper — but the first call then fails with a ConfigurationException, because there is no actual client to discover.

Alternative: let php-http/discovery install one for you `php-http/discovery` ships a Composer plugin that installs a suitable client automatically, but plugins must be allowed explicitly: That pulls in `nyholm/psr7` and `symfony/http-client` for you. Installing a client yourself is still the more predictable route — and you need your own client instance anyway to set a timeout, which the next section explains is not optional here.

Already set up? A bare composer require minhyung/sdwebui is fine if the project has both a PSR-18 client and a PSR-7/17 implementation. Those are two separate things, and some packages only bring one:

Installed PSR-18 client PSR-17 factories Enough on its own
guzzlehttp/guzzle yes yes (guzzlehttp/psr7) yes
symfony/http-client only with a PSR-7 impl no no — add nyholm/psr7
nyholm/psr7 no yes no — add a client

Timeouts — read this first

PSR-18 has no concept of a timeout, so this SDK cannot set one. Generation runs synchronously on the server behind a lock, and a large batch or a slow model takes minutes. With a default client timeout of 30 seconds, your requests will fail long before the image is ready.

Inject a client configured for it:

Authentication

For a server started with --api-auth user:pass:

Two things worth knowing:

Generating images

txt2img

Enums are a convenience, never a constraint — every setter that takes one also takes a plain string, so sampler names added by extensions keep working. Ask the server what it actually has with $sd->catalog()->samplerNames().

Hires fix

img2img and inpainting

Per-request settings

Convenient, but slow in bulk: the server reloads the model and unloads it again on every request. Generating many images against one checkpoint is much faster if you set it once:

Images

Image handles the encoding so you do not have to:

Response images are not necessarily PNG — the server encodes them according to its samples_format setting. extension() and mimeType() reflect what actually arrived.

Postprocessing

Reading metadata

The server restores only the fields the WebUI tags for the API, which is fewer than an infotext contains. On txt2img that covers the prompts, size, CFG scale, batch size, styles, denoising strength, the hires-fix block, steps, sampler, scheduler, seed and the refiner. On img2img the tab's own fields are untagged, so denoising_strength, inpainting_fill, inpaint_full_res, cfg_scale and the size are not restored there — set them yourself. Anything you set explicitly always wins over the infotext.

If the server answers HTTP 500 ... cannot be used with isinstance(), it types one of those fields as Any, which makes its own restore step raise before it applies anything. Setting the field explicitly makes the server skip it. On Forge Neo the field is styles:

Extensions

ControlNet and ADetailer have typed helpers:

Call controlNet() more than once for multi-unit setups.

These helpers are best-effort. Argument layouts belong to the installed version of each extension, and the server silently discards arguments it does not expect — a wrong layout produces an image that quietly ignored your settings rather than an error. When something has no effect, check what the instance actually declares:

Any script can be driven directly:

Progress

Generation blocks until it finishes, so progress has to be watched from somewhere else. Every request carries a task id for exactly this:

Then, from anywhere:

This is per-task, so it stays correct when several clients share an instance. $sd->progress()->current() gives the server-wide snapshot instead.

isFinished() is the only positive signal that the work is done. isUnknown() means two opposite things depending on when it arrives: before the task has ever been seen it is "not submitted yet", because the id is published ahead of send(); after it has been seen it is "gone", since the server remembers only the last 16 finished tasks. A poll loop has to end on both, plus a deadline for the first sighting — examples/progress.php has the shape.

Single-process polling

If you would rather stay in one process, onProgress() can do it — but it needs a client that both sends asynchronously and can be advanced in bounded slices, since a plain Promise::wait() would block until the image is done and defeat the purpose. Symfony\Component\HttpClient\HttplugClient qualifies, and needs all four of these:

guzzlehttp/promises is easy to miss — Symfony's HttplugClient only reports it missing at the moment of the first async send.

Clients that cannot be ticked are rejected with a clear error rather than hanging.

Inspecting the server

Group What it covers
$sd->catalog() samplers, schedulers, checkpoints, VAEs, upscalers, LoRAs, styles, embeddings, hypernetworks, face restorers, extensions
$sd->options() read and write the server's settings
$sd->models() rescan model directories, unload and reload weights
$sd->progress() current progress, per-task progress, interrupt, skip, memory
$sd->scripts() installed scripts and their argument layouts
$sd->server() ping, diagnostics, shutdown

$sd->server()->ping() answers false for any failure, including bad credentials — it is built for a health check, where the only question is whether to route traffic. For a "test connection" screen that has to tell the user what went wrong, call something real and let the typed exceptions through instead:

examples/inspect.php summarises a running instance: its sample format, and the total count plus first 20 entries of each of its checkpoints, samplers, schedulers, upscalers, LoRAs, and always-on scripts.

Writes through $sd->options() are persistent — they are saved to the server's config.json, not scoped to your session. Use overrideSetting() on a request for per-request changes. Note also that options flagged restrict_api server-side are ignored without an error, so read back anything that matters.

Error handling

Exception When
BadRequestException 400 — unknown sampler
AuthenticationException 401/403
NotFoundException 404 — also a missing init_images, or an unknown interrogate model
ValidationException 422 — both FastAPI's itemised shape and the WebUI's own
ServerException 5xx — also an undecodable input image, or an unknown options key
TransportException No response at all
JsonException, ImageException, ConfigurationException Client-side

Endpoints not modelled here

Extension routes and anything newer than this SDK can go through the transport directly:

Individual request fields have an escape hatch too:

Hooking into requests

There is no middleware layer. Everything goes out through the PSR-18 client you inject, so decorate that — one implementation of sendRequest() covers retries, metrics, tracing, or an egress allowlist for every call this SDK makes:

The base URL is validated as an absolute http/https URL with a host. Credentials embedded in it are rejected — use basicAuth(), which sends them as a header rather than as part of a URI that reaches every log line — and so are a query string and a fragment, since every request path is appended to the base URL and would land inside them. Validation does not resolve the host or restrict where it points; if untrusted input can reach the base URL, do that check yourself in a decorator like the one above.

API quirks this SDK handles for you

The WebUI API has a number of sharp edges. These are absorbed so you do not have to think about them:

Logging

Requests and responses are logged at debug. Long strings — base64 images, mostly — are replaced with a size marker so logs stay readable, and the cmd-flags response is never logged at all.

Building that context is not free: the body is materialised, decoded, walked and re-encoded, which on a request carrying a base64 image is megabytes of work. PSR-3 offers no way to ask a logger whether debug is enabled, so injecting a framework logger configured at info would pay all of it and discard the result. Say so explicitly:

Nothing is built after that. With no logger injected at all the cost is already skipped.

Contributing

Unit tests use a mock HTTP client and never touch the network.

License

MIT. See LICENSE.


All versions of sdwebui with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
ext-mbstring Version *
php-http/discovery Version ^1.20
psr/http-client Version ^1.0
psr/http-client-implementation Version *
psr/http-factory Version ^1.0
psr/http-factory-implementation Version *
psr/http-message Version ^1.1 || ^2.0
psr/log Version ^2.0 || ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package minhyung/sdwebui contains the following files

Loading the files please wait ...