ORIGINAL FORGE · CORE REST API · COMMIT-BOUND

Enable, prove, and call the Forge API

Start with one local request you can inspect end to end: confirm the route exists, ask the running instance for valid names, generate a small image, then decode and verify the response.

VERIFIED Core API inspected at Original Forge commit dfdcbab. No fork routes or third-party API wrapper are attributed to Forge.

DIRECT ANSWER

The API is present, but the normal launch does not enable its core routes

Add --api to keep the UI and expose the core /sdapi/v1/* routes on the same server. Use --nowebui only when you intentionally want the API without the normal interface.

34METHOD + PATH RECORDS
ENABLED BY DEFAULT IN API MODE
33UNIQUE DEFAULT
CORE PATHS
3EXTRA SERVER-CONTROL ROUTES
BEHIND --api-server-stop
VERIFIED

/docs is a discovery surface, not the success condition. Without --api, the UI server can still show Gradio and extension routes there. Search for POST /sdapi/v1/txt2img; if it is absent, the core API was not attached to that running server.

01 · LAUNCH ROUTE

Choose the smallest access boundary that fits the client

Loopback is the clean baseline. Move to browser CORS or another machine only after the same local request passes.

VERIFIEDhttp://127.0.0.1:7860

UI + API

Best first proof. Forge keeps its normal interface and adds the core /sdapi routes to the same server. Select and prove the model in the UI, then repeat it through the API.

--api

Proof: Open /docs and find POST /sdapi/v1/txt2img.

WHERE TO PUT IT

Add the argument to the launcher your installation actually runs, then close and restart the full Forge process. Windows Git installs normally use webui-user.bat; Linux/macOS Git installs use webui-user.sh. Package managers and old archives can wrap those files.

Resolve your active launcher →
02 · FIVE PROOF GATES

Do not debug generation before the route and runtime state pass

Each gate answers one question. Stop at the first failed gate and preserve its response.

  1. 01

    Argument reached the process

    The console launch line contains --api or --nowebui. A browser refresh cannot apply it.

    PROCESS
  2. 02

    Core route exists

    Open /docs and find POST /sdapi/v1/txt2img. Its absence is an enablement problem.

    SCHEMA
  3. 03

    Read-only call works

    curl -sS http://127.0.0.1:7860/sdapi/v1/samplers returns a JSON array. Use port 7861 for default API-only mode.

    DISCOVERY
  4. 04

    Generation returns an image

    A small txt2img request returns HTTP 200 and a non-empty images[0].

    INFERENCE
  5. 05

    Response proves the intended state

    The base64 decodes to a valid image and returned info reflects the model, seed and generation controls you intended.

    RESULT
03 · FIRST REQUEST

Build one small txt2img request

The builder deliberately omits Hires. fix, scripts, LoRAs and model switching. Prove transport and decoding before adding state.

Names must match your own /samplers and /schedulers responses.
CURL · SAVES RESPONSE.JSON
RESPONSE CONTRACT
images[0]
Base64-encoded result when send_images is true.
parameters
The API request fields returned as an object.
info
A JSON-formatted string containing generation details.
DECODE THE RESULT

Turn images[0] into a file, then open the file

Save the API body as response.json, run this Python standard-library script, and confirm the output is a readable image—not merely a non-empty string.

PYTHON · STANDARD LIBRARY
import base64, json
from pathlib import Path

data = json.loads(Path("response.json").read_text(encoding="utf-8"))
if not data.get("images"):
    raise SystemExit(f"No image returned: {data}")

encoded = data["images"][0].split(",", 1)[-1]
Path("forge-api-result.png").write_bytes(base64.b64decode(encoded, validate=True))
print("Wrote forge-api-result.png")
VERIFIED

Example verification boundary: request JSON is parsed during site QA, every named field exists in the inspected request model, and the decoder is exercised against a fixture matching the response model. Live image generation was not run in this web project environment because no Forge model/GPU runtime is attached.

04 · CORE ENDPOINT LEDGER

Inspect the route before you build against it

This is the Api class at commit dfdcbab, not every Gradio, built-in, or third-party extension route on a running server.

Showing all 37 method and path records

Generate & transform

4 RECORDS
POST/sdapi/v1/txt2img

Generate from a prompt; returns base64 images, submitted parameters, and an info string.

POST/sdapi/v1/img2img

Generate from base64 init_images; a missing init image returns an error.

POST/sdapi/v1/extra-single-image

Apply the Extras post-processing path to one base64 image.

POST/sdapi/v1/extra-batch-images

Apply Extras to a named list of base64 images.

Inspect images

2 RECORDS
POST/sdapi/v1/png-info

Read generation text and parsed parameters from a base64 PNG.

POST/sdapi/v1/interrogate

Caption one base64 image with CLIP or DeepDanbooru.

Control the active job

3 RECORDS
GET/sdapi/v1/progress

Read current global progress; optionally omit the preview image.

POST/sdapi/v1/interrupt

Interrupt the current generation.

POST/sdapi/v1/skip

Skip the current item in the active job.

Discover runtime state

18 RECORDS
GET/sdapi/v1/options

Read the current settings object.

POST/sdapi/v1/options

Set named settings; treat this as shared mutable state.

GET/sdapi/v1/cmd-flags

Read parsed launch arguments.

GET/sdapi/v1/samplers

List the sampler names accepted by this running instance.

GET/sdapi/v1/schedulers

List schedulers from this running instance.

GET/sdapi/v1/upscalers

List available upscalers and their runtime metadata.

GET/sdapi/v1/latent-upscale-modes

List latent upscale modes.

GET/sdapi/v1/sd-models

List discovered checkpoints and hashes.

GET/sdapi/v1/sd-modules

List discovered VAE and text-encoder module files.

GET/sdapi/v1/hypernetworks

List discovered hypernetworks.

GET/sdapi/v1/face-restorers

List registered face restorers.

GET/sdapi/v1/realesrgan-models

List registered Real-ESRGAN models.

GET/sdapi/v1/prompt-styles

List saved prompt styles.

GET/sdapi/v1/embeddings

List loaded and skipped embeddings.

GET/sdapi/v1/memory

Read RAM and CUDA memory figures reported by Forge.

GET/sdapi/v1/scripts

List txt2img and img2img script names.

GET/sdapi/v1/script-info

Read API metadata exposed by registered scripts.

GET/sdapi/v1/extensions

List registered extensions and Git identity fields.

Change runtime state

7 RECORDS
POST/sdapi/v1/refresh-embeddings

Rescan embeddings.

POST/sdapi/v1/refresh-checkpoints

Rescan checkpoint files.

POST/sdapi/v1/refresh-vae

Refresh VAE/module state.

POST/sdapi/v1/create/embedding

Create an embedding record through the inherited API path.

POST/sdapi/v1/create/hypernetwork

Create a hypernetwork record through the inherited API path.

POST/sdapi/v1/unload-checkpoint

Unload model weights.

POST/sdapi/v1/reload-checkpoint

Send the current model back to the selected device.

Gated server control

3 RECORDS
POST/sdapi/v1/server-kill

Available only with --api-server-stop. Stops the process.

POST/sdapi/v1/server-restart

Available only with --api-server-stop; restart support is environment-dependent.

POST/sdapi/v1/server-stop

Available only with --api-server-stop. Requests server stop.

05 · SHARED STATE

Model state and the GPU queue belong to the process, not one caller

That distinction matters as soon as more than one script, person, or browser uses the instance.

VERIFIED

Generation is serialized

The inspected txt2img, img2img and Extras handlers enter a shared queue lock. A second request may wait; it is not a separate worker with isolated model state.

VERIFIED

Options are shared

POST /sdapi/v1/options changes process settings. Do not let concurrent clients switch checkpoints or companion modules without their own coordination.

COMMUNITY-REPORTED

FLUX needs an exact-state proof

Users report module-selection and black-image failures across older commits. Current code lists SD modules, but that does not certify one universal FLUX payload.

VERIFIED

UI parity is a receipt problem

A minimal API body intentionally uses many defaults. Compare the response info with a known-good UI PNG and add only the missing, attributable field.

06 · ACCESS BOUNDARY

Four flags solve four different problems

Combining them in one copied launch line hides which boundary is actually working.

--api

Attach core routes

Adds the inspected /sdapi/v1/* API to the normal UI server.

DOES NOT BIND TO THE LAN
--listen

Change the bind address

The helper returns 0.0.0.0, allowing network requests to reach the server when the surrounding network permits it.

DOES NOT AUTHENTICATE
--api-auth

Protect core API routes

Adds HTTP Basic authentication to routes registered by the core Api helper.

DOES NOT CERTIFY EXTENSION ROUTES
--cors-allow-origins

Allow one browser origin

Configures which web origin may read cross-origin responses. The origin includes scheme, host, and port.

DOES NOT BLOCK NON-BROWSER CLIENTS
SAFE EXPANSION ORDER
  1. Loopback API
  2. Exact local client
  3. Authenticated LAN
  4. Independently reviewed gateway

UNKNOWN Direct public-internet exposure is outside this guide’s verified boundary.

07 · FAILURE ROUTER

Read the first failed gate, not the last symptom

Remove optional fields and return to a read-only route before changing Python, Torch, models, or extensions.

/docs opens, but txt2img is missing

The server is alive, but the core API was not attached. Confirm the console launch line contains --api, restart the full process, and search again. For --nowebui, use port 7861 unless --port changed it.

Connection refused or the request never reaches Forge

Check the exact address printed by the running process. Verify UI+API versus API-only port, scheme, host and custom subpath. Test from the Forge machine before adding --listen, CORS, a proxy, or another client.

Diagnose startup and connection →
HTTP 401 Unauthorized

The core route expects HTTP Basic credentials from --api-auth. With curl, add -u user:password. Avoid real credentials in copied commands, screenshots, shell history, logs, or repository files.

HTTP 404 Not Found

Compare the method and path with your runtime /docs. A GET to a POST-only route, the wrong port, a reverse-proxy subpath, or a missing --api can all produce a 404-shaped symptom.

HTTP 422 validation error

Read the returned detail array and use your running /docs schema. Remove scripts, alwayson_scripts, overrides and optional fields until the minimal body passes, then restore one field at a time.

HTTP 500, black image, or no image to decode

Preserve the first Forge console traceback. Confirm send_images is true, the selected checkpoint generates in the UI, required VAE/text encoders are loaded, and the small baseline works without LoRAs, Hires. fix or scripts. Route model failures to the dedicated guides.

Browser fetch fails while curl succeeds

Transport and inference already work. Compare the browser page’s exact origin with --cors-allow-origins; http://localhost:3000 and http://127.0.0.1:3000 are different origins. Do not replace an exact origin with a broad pattern merely to silence the browser.

API image differs from a UI image with the same prompt

A prompt is not the complete generation state. Compare model and modules, seed, dimensions, sampler, scheduler, steps, guidance, styles, scripts, Hires. fix, LoRAs and extension state. Use the returned info and a known-good UI PNG as the two receipts.

08 · API QUESTIONS

Answers for the next integration decision

These questions cover enablement, ports, response decoding, runtime discovery, model state, concurrency, CORS, authentication and exposure.

How do I enable the API in Stable Diffusion WebUI Forge?

Add --api to the active launcher arguments and fully restart Forge. Then open /docs on the running address and confirm that POST /sdapi/v1/txt2img appears. The presence of /docs alone is not proof because the Gradio server exposes other routes without the core API.

What is the default Forge API URL?

With the normal UI plus --api, use the same local server, normally http://127.0.0.1:7860. With --nowebui and no explicit --port, the inspected code uses http://127.0.0.1:7861. A custom --port replaces those defaults.

Why is /sdapi/v1/txt2img missing from /docs?

The usual cause is that the running process did not receive --api. Confirm the printed launch arguments, close the full process, restart through the launcher you edited, then search /docs again. If --nowebui is active, check port 7861 unless you set --port.

Can I use curl with the Forge API?

Yes. Send JSON to POST /sdapi/v1/txt2img with Content-Type: application/json. Start with a small request, save the JSON response, verify that images[0] exists, and decode that base64 value to a file.

Why does the API return JSON instead of a PNG file?

The txt2img response model contains an images array of base64 strings plus parameters and info. Decode the first string before opening it as an image. Setting send_images to false intentionally returns no encoded images.

Does save_images control the API response?

No. In the inspected request model, send_images controls whether image strings are returned, while save_images controls whether Forge writes samples and grids through its own output path. They are separate switches.

How do I choose a sampler or scheduler safely?

Query /sdapi/v1/samplers and /sdapi/v1/schedulers on the running instance and send an exact returned name. Do not copy a name from a different build or fork. An unknown sampler is rejected by the core API.

How do I select a model through the Forge API?

For the first proof, select and test the model in the UI before calling txt2img. The API exposes /sdapi/v1/sd-models, /sdapi/v1/sd-modules and mutable settings, but checkpoint and companion-module changes affect shared process state and need an exact-build test before concurrent use.

Can the Forge API use FLUX?

Current code exposes the same txt2img processing model and module inventory used by Forge, but a universal FLUX payload is not verified here. Community reports show commit- and module-dependent behavior around checkpoint, VAE and text-encoder selection. Prove one working FLUX setup in the UI, record every module, then test the same commit through the API.

Why does API output differ from the Forge UI?

A shorter API payload leaves many fields at code defaults and may omit scripts, always-on extensions, model/module state, Hires. fix controls, styles, or other UI values. Compare the returned info and parameters with the PNG metadata from a UI baseline before adding fields.

Can several clients generate at the same time?

Generation paths use a shared queue lock in the inspected core API, so requests can wait rather than execute as independent GPU jobs. Options and model state are also shared. Serialize model-changing operations in your client and treat progress as global process state.

What does HTTP 422 mean in Forge API?

FastAPI rejected the request shape or a script name/argument failed validation. Read the response detail, compare the body with the schema shown by your own /docs page, and remove optional fields until the minimal payload passes.

What causes HTTP 401 from the Forge API?

The process was started with --api-auth and the request did not supply a matching HTTP Basic username and password. Add curl -u user:password or the equivalent client setting. Do not place real credentials in screenshots, shell history, or source control.

Is --cors-allow-origins the same as authentication?

No. CORS tells browsers which web origins may read a response. It does not stop curl, Python, another server, or a non-browser client. Use it only for a browser integration and keep access control as a separate boundary.

Is it safe to expose the Forge API to the public internet?

This guide does not certify direct public exposure. The core API can change settings, inspect paths and extensions, generate costly work, and optionally stop the server. Keep the first deployment on loopback; any network deployment needs an independently reviewed access, TLS, firewall, logging, and extension-route design.

Does --api-auth protect extension API routes?

The inspected helper adds HTTP Basic auth to the 37 routes registered through the core Api class. Built-in and third-party extensions can register routes separately, so this page does not claim that --api-auth protects every route on the server. Inspect the actual /openapi.json and extension code.

How do I see every endpoint in my installed Forge build?

Open /docs for interactive Swagger documentation or fetch /openapi.json from the running server. Treat that runtime schema as the inventory for your exact commit and enabled extensions; the ledger on this page covers only the inspected core Api class.

09 · SOURCES & LIMITS

Code defines the route; reports define what users trip over

Secondary pages and user reports were used to find integration questions. Every route, flag, default port, request field and response claim was checked against the original repository snapshot.

Research reviewed: 9 relevant source records
A04STALE SNAPSHOT

DeepWiki installation and setup

Launch-mode wording was checked; its API-only port and /api path claims were rejected against current code.

A07COMMUNITY-REPORTED

HammerAI Forge integration guide

Confirmed third-party demand for local API detection; its bundled launch and tuning advice was not generalized.

VERIFIEDVerified

37 core method/path records, 3 gated server-control records, flags, default API-only port, auth wrapper, queue lock, request and response shape.

COMMUNITY-REPORTEDReported

Historical UI/API mismatch and FLUX companion-module problems. They identify tests, not universal outcomes.

UNKNOWNNot certified

Public deployment, every extension route, a universal FLUX payload, every client library, and live generation on untested hardware.

Author Forge Field Guide editorial teamTechnical review Original Forge source at dfdcbabUpdated 2 Sep 2026Refresh trigger API route, parser, model-module, auth or server change