class

MJ::RunwareClient

Inherits MJ::Generator < Reference < Object

Constructors

new(api_key : String)
Source

Class methods

read_timeout

Generous, because normal latency here is seconds and the tail is long — this is a backstop against an indefinite hang, not a latency budget. Callers that need a tight budget should impose it themselves.

Source
retries
Source

Instance methods

edit_references(reference_bytes : Array(Bytes), prompt : String, width : Int32, height : Int32, model : String, extra : Hash(String, JSON::Any) | Nil = nil, format : String = "PNG") : GenerationResult

Reference-image editing (Nano Banana / Gemini Flash Image, google:4@x). positivePrompt is a natural-language instruction; the model regenerates the whole output guided by the reference images and instruction (no mask). extra carries per-model parameters (steps, CFGScale, seed, …). Runware SILENTLY ACCEPTS unknown fields — a misspelled parameter returns 200 and does nothing — so anything passed here must be verified with a same-seed A/B before it is trusted. See notes/verify_param.py.

format is PNG by default because that is what every existing caller expects back. WEBP is several times smaller for the same picture, which matters when the result has to cross a process boundary as base64 rather than being written to a local file.

Source
generate(request : GenerationRequest) : GenerationResult
Source
inpaint(seed_bytes : Bytes, mask_bytes : Bytes, prompt : String, width : Int32, height : Int32, model : String, steps : Int32 = 30, strength : Float64 = 1.0, cfg_scale : Float64 = 3.5, mask_margin : Int32 | Nil = nil, negative_prompt : String = "") : GenerationResult

Inpaint a region of a seed image. seed_bytes is the composite canvas, mask_bytes is the black/white mask (white = regenerate). Both are uploaded before the inference call. Used to invent transition terrain in strip gaps.

Source
name
Source
preprocess_pose(image_uuid : String, width : Int32, height : Int32) : Tuple(String, String)

Extract OpenPose skeleton from an image via ControlNet preprocessing

Source
remove_background(image_bytes : Bytes, model : String | Nil = nil, alpha_matting : Bool = false) : GenerationResult

Background removal via Runware's imageBackgroundRemoval task (Tier 3 matting — GPU-backed, heavier models than the local CPU tier). Uploads the image, runs the remover, downloads the transparent PNG. model is an optional AIR id for a specific remover (nil = Runware default); alpha_matting turns on edge refinement for crisper fine detail.

Source
text_to_image(prompt : String, width : Int32, height : Int32, model : String, extra : Hash(String, JSON::Any) | Nil = nil, format : String = "PNG") : GenerationResult

Text-to-image: the same imageInference task with no references at all. Before this existed, mj:camera's Runware transport gave an unreferenced shot a flat grey canvas to edit, and the grey survived into the picture (a flat grey sky on klein, 2026-10-14).

Source
upload_image(file_path : String) : String

Upload an image file and get back a UUID

Source
upload_image_bytes(image_data : Bytes) : String

Upload raw PNG bytes and get back a UUID

Source