Kokon

v0.13.0
io.github.GabrieleLozupone/kokon Checked 3 hours ago Published 4 days ago

Generate and edit images offline with Qwen-Image 2.1 on your GPU.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

generate_image Generate image

Generate an image from a text prompt with the local Qwen-Image 2.1 model, optionally using reference images (a person, a product, a style) in a new scene. Write the full, detailed prompt yourself (see the prompt field): it is used as is. Dimensions are chosen automatically (aspect ratio can be inferred from the prompt, e.g. '16:9 hero image') unless width/height or aspect_ratio are given. Returns the absolute path of the saved PNG. Runs fully offline; typically 45 s–4 min.

ParameterTypeDescription
prompt *stringThe final prompt, written by you in English and used as is (Kokon does not rewrite it): one paragraph of about 60-200 words describing the finished image: medium and style first, the subject and what…
aspect_ratiostringAspect ratio such as 1:1, 4:3, 3:4, 16:9, 9:16, or auto (inferred from the prompt)
heightintegerOutput height in pixels (needs width too).
include_previewbooleanAlso return a small JPEG preview in the tool result. Default false: images stay local and are not sent to the model.
output_pathstringOptional destination (absolute, or relative to the project). Must be inside the project or the app output folder. Existing files are never overwritten; a numbered name is used instead.
qualitystringAll run Qwen-Image 2.1 Turbo (8 steps): fast = ~1 MP (the default, fastest); balanced = ~1.5K; quality = native 2K (slowest; edits share 2K with their references)
reference_imagesarrayOptional images the new image uses (a person, a product, a place, a style), in order; refer to them as image 1, image 2, ... in the prompt. The output is sized like any new image, not like the referen…
seedintegerSeed for reproducible results; omit or -1 for random
widthintegerOutput width in pixels (needs height too). Omit to choose automatically.

edit_image Edit image

Edit an existing image with a natural-language instruction (e.g. 'make the background nighttime, keep the foreground unchanged'). Preserves the input's width, height and aspect ratio by default. The input file is never overwritten.

ParameterTypeDescription
image_path *stringImage to edit (absolute, or relative to the project)
prompt *stringThe edit instruction, written by you in English and used as is (Kokon does not rewrite it): start with the operation (Change, Replace, Remove, Add, Turn...), say exactly what changes, where, and what…
include_previewbooleanAlso return a small JPEG preview in the tool result. Default false: images stay local and are not sent to the model.
output_pathstringOptional destination (absolute, or relative to the project). Must be inside the project or the app output folder. Existing files are never overwritten; a numbered name is used instead.
preserve_dimensionsbooleanKeep the input's exact width/height (default true)
qualitystringAll run Qwen-Image 2.1 Turbo (8 steps): fast = ~1 MP (the default, fastest); balanced = ~1.5K; quality = native 2K (slowest; edits share 2K with their references)
seedintegerSeed for reproducible results; omit or -1 for random. Never reuse the seed the source image was generated with: use a different one or omit it

edit_images Edit with multiple references

Edit image 1 with the help of other images (up to 10 in all) and an instruction, e.g. put the product from image 2 in the hand of the person in image 1. Order matters: refer to them as image 1, image 2, ... in the prompt. The output follows image 1's aspect ratio unless width/height or aspect_ratio are given. For a new scene that only uses the images as references, use generate_image with reference_images.

ParameterTypeDescription
image_paths *arrayReference images in order; refer to them as image 1, image 2, ... in the prompt
prompt *stringThe edit instruction, written by you in English and used as is (Kokon does not rewrite it): image 1 is the image being changed; start with Place or Combine, say what is taken from each image (image 2,…
aspect_ratiostringAspect ratio such as 1:1, 4:3, 3:4, 16:9, 9:16, or auto (inferred from the prompt)
heightinteger
include_previewbooleanAlso return a small JPEG preview in the tool result. Default false: images stay local and are not sent to the model.
output_pathstringOptional destination (absolute, or relative to the project). Must be inside the project or the app output folder. Existing files are never overwritten; a numbered name is used instead.
qualitystringAll run Qwen-Image 2.1 Turbo (8 steps): fast = ~1 MP (the default, fastest); balanced = ~1.5K; quality = native 2K (slowest; edits share 2K with their references)
seedintegerSeed for reproducible results; omit or -1 for random. Never reuse the seed the source image was generated with: use a different one or omit it
widthinteger

outpaint_image Expand image (outpaint)

Extend an image beyond its borders. Give the expansion per side in pixels or percent; the canvas, mask and model-aligned sizes are built automatically and the original pixels are preserved exactly.

ParameterTypeDescription
image_path *string
prompt *stringWhat the extended area should contain
bottomnumber
include_previewbooleanAlso return a small JPEG preview in the tool result. Default false: images stay local and are not sent to the model.
leftnumber
output_pathstringOptional destination (absolute, or relative to the project). Must be inside the project or the app output folder. Existing files are never overwritten; a numbered name is used instead.
qualitystringAll run Qwen-Image 2.1 Turbo (8 steps): fast = ~1 MP (the default, fastest); balanced = ~1.5K; quality = native 2K (slowest; edits share 2K with their references)
rightnumber
seedintegerSeed for reproducible results; omit or -1 for random. Never reuse the seed the source image was generated with: use a different one or omit it
topnumber
unitsstringUnits for left/right/top/bottom; percent is relative to the image width (left/right) or height (top/bottom)

inpaint_image Inpaint image

Change only the masked area of an image (mask: white = change, black = keep): edit it, remove what is there, replace it, or add something inside it. The model is shown the area marked on a copy of the image; pixels outside the mask are preserved exactly.

ParameterTypeDescription
image_path *string
mask_path *stringMask image: white = area to change, black = keep (or opaque strokes on a transparent layer)
actionstringedit: change the area as the prompt says; remove: erase what is there and fill with background (prompt optional, e.g. 'the bin'); replace: put the prompt's subject in its place; add: add the prompt's…
include_previewbooleanAlso return a small JPEG preview in the tool result. Default false: images stay local and are not sent to the model.
output_pathstringOptional destination (absolute, or relative to the project). Must be inside the project or the app output folder. Existing files are never overwritten; a numbered name is used instead.
promptstringThe change, or the subject to add/replace with; optional for remove
qualitystringAll run Qwen-Image 2.1 Turbo (8 steps): fast = ~1 MP (the default, fastest); balanced = ~1.5K; quality = native 2K (slowest; edits share 2K with their references)
seedintegerSeed for reproducible results; omit or -1 for random. Never reuse the seed the source image was generated with: use a different one or omit it

upscale_image Upscale image

Enlarge an image (default 2x, or to a width/height up to 8192 px). Runs the upscaler model chosen in Kokon (Superscale-SP by default; seconds on a PC GPU, longer on a Mac; adds no new content). Saves a new file; the input is never overwritten.

ParameterTypeDescription
image_path *stringImage to upscale (absolute, or relative to the project)
heightintegerTarget height in pixels; width follows the aspect ratio unless also given
include_previewbooleanAlso return a small JPEG preview in the tool result. Default false: images stay local and are not sent to the model.
output_pathstringOptional destination (absolute, or relative to the project). Must be inside the project or the app output folder. Existing files are never overwritten; a numbered name is used instead.
scalenumberEnlargement factor, e.g. 2 (default 2 when no width/height is given)
widthintegerTarget width in pixels; height follows the aspect ratio unless also given

get_image_info Image info

Width, height, aspect ratio, file type and, for images made by Kokon, the generation metadata (prompt, seed, model, steps...).

ParameterTypeDescription
image_path *string

get_generator_status Generator status

Whether the local inference server is running and the model loaded, GPU and VRAM, the active job and the queue.