Skip to content
GitHub

API Reference

Submits a filled-in workflow to ComfyUI, polls history, fetches output.
__init__
def __init__(
    base_url: str,
    checkpoint: str,
    workflow_path: str | None = None,
    steps: int = 20,
    cfg_scale: float = 7.0,
    poll_interval: float = 1.0,
    timeout: float = 60.0,
    retry: RetryPolicyProtocol | None = None,
    circuit_breaker: CircuitBreakerProtocol | None = None
) -> None
generate
async def generate(request: ImageRequest) -> Result[MediaAsset, ImageGenerationError]

Configuration for the image generation subsystem.

Provider that registers a configured ImageProvider backend.
__init__
def __init__(config: ImageConfig | None = None) -> None
register
async def register(container: ContainerRegistrarProtocol) -> None
boot
async def boot(container: ContainerResolverProtocol) -> None

No async I/O needed at boot beyond what register() already did.

health_check
async def health_check(timeout: float = 5.0) -> HealthCheckResult

Callable task handler — wraps an ImageProvider backend for lexigram-tasks.

Returns a plain dict (never raw MediaAsset bytes) because lexigram-tasks’ result store JSON-serializes JobResult. The umbrella wraps this handler during MultimediaProvider.register() to persist any bytes to lexigram-storage BEFORE this dict is constructed — see the “Async job model” section of the design spec.

__init__
def __init__(backend: ImageProvider) -> None
run
async def run(params: dict[str, Any]) -> dict[str, Any]

Image generation integration.
configure
def configure(
    cls,
    config: ImageConfig | None = None
) -> DynamicModule
stub
def stub(
    cls,
    config: ImageConfig | None = None
) -> DynamicModule

Talks to a self-hosted image generation HTTP server.

No SDK dependency — this is the always-available zero-extra backend.

__init__
def __init__(
    base_url: str,
    timeout: float = 60.0,
    retry: RetryPolicyProtocol | None = None,
    circuit_breaker: CircuitBreakerProtocol | None = None
) -> None
generate
async def generate(request: ImageRequest) -> Result[MediaAsset, ImageGenerationError]

Calls the OpenAI (or an OpenAI-compatible-gateway) Images API.

base_url is configurable rather than hardcoded to api.openai.com so this can point at a self-hosted or third-party gateway that speaks the same /v1/images/generations wire shape behind a different model, including non-OpenAI models routed through a compatible gateway.

__init__
def __init__(
    api_key: str,
    model: str = 'dall-e-3',
    base_url: str = 'https://api.openai.com',
    timeout: float = 60.0,
    retry: RetryPolicyProtocol | None = None,
    circuit_breaker: CircuitBreakerProtocol | None = None
) -> None
generate
async def generate(request: ImageRequest) -> Result[MediaAsset, ImageGenerationError]

Calls the Stability AI stable-image generation API.

The API returns base64-encoded image bytes in the response body — they are decoded before constructing the MediaAsset.

__init__
def __init__(
    api_key: str,
    timeout: float = 60.0,
    retry: RetryPolicyProtocol | None = None,
    circuit_breaker: CircuitBreakerProtocol | None = None
) -> None
generate
async def generate(request: ImageRequest) -> Result[MediaAsset, ImageGenerationError]

Raised when the image backend rejects the configured API credentials.

Base for still-image generation errors.

Raised when an image generation operation exceeds its timeout.