sd_api_start: Start sd2R REST API server

View source: R/api.R

sd_api_startR Documentation

Start sd2R REST API server

Description

Launches a plumber-based REST API for image generation. Optionally pre-loads a model at startup.

Usage

sd_api_start(
  model_path = NULL,
  model_type = "sd1",
  model_id = NULL,
  vae_decode_only = TRUE,
  host = "0.0.0.0",
  port = 8080L,
  api_key = NULL,
  ...
)

Arguments

model_path

Optional path to model file to load at startup

model_type

Model type for the pre-loaded model (default "sd1")

model_id

Identifier for the pre-loaded model (default: basename of model_path)

vae_decode_only

VAE decode only for the pre-loaded model (default TRUE)

host

Host to bind to (default "0.0.0.0")

port

Port to listen on (default 8080)

api_key

Optional API key string. When set, non-localhost requests must include X-API-Key or Authorization: Bearer <key> header. Default NULL (no auth).

...

Additional arguments passed to sd_ctx for the pre-loaded model

Value

Invisibly returns the plumber router object

Examples

## Not run: 
# Start with a pre-loaded model
sd_api_start("model.safetensors", model_type = "flux", port = 8080)

# Start empty, load models via API
sd_api_start(port = 8080)

# With API key
sd_api_start("model.safetensors", api_key = "my-secret-key")

## End(Not run)

sd2R documentation built on March 30, 2026, 5:08 p.m.