kiapi 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kiapi/__init__.py +3 -0
- kiapi/__main__.py +4 -0
- kiapi/api/__init__.py +26 -0
- kiapi/api/_constants/require_auth.py +14 -0
- kiapi/api/_helpers/build_job_responses.py +73 -0
- kiapi/api/_helpers/build_openapi.py +55 -0
- kiapi/api/_helpers/build_train_responses.py +21 -0
- kiapi/api/_helpers/get_accept.py +20 -0
- kiapi/api/_helpers/get_ctx.py +7 -0
- kiapi/api/_helpers/get_worker.py +7 -0
- kiapi/api/_helpers/register_capability_endpoints.py +70 -0
- kiapi/api/_helpers/submit_and_maybe_wait.py +113 -0
- kiapi/api/_settings.py +50 -0
- kiapi/api/_views/async_job_response.py +21 -0
- kiapi/api/_views/capability_model_spec.py +49 -0
- kiapi/api/app.py +150 -0
- kiapi/api/audio/acestep/_views/extract_response.py +57 -0
- kiapi/api/audio/acestep/_views/track_response.py +57 -0
- kiapi/api/audio/acestep/router.py +190 -0
- kiapi/api/audio/audiogen/_views/audio_response.py +46 -0
- kiapi/api/audio/audiogen/router.py +77 -0
- kiapi/api/chat/_views/chat_completion_response.py +71 -0
- kiapi/api/chat/router.py +253 -0
- kiapi/api/embedding/_views/embedding_response.py +35 -0
- kiapi/api/embedding/router.py +82 -0
- kiapi/api/files/_operations/get_file.py +14 -0
- kiapi/api/files/_operations/get_file_id.py +18 -0
- kiapi/api/files/_views/file_delete_response.py +14 -0
- kiapi/api/files/_views/file_list_response.py +15 -0
- kiapi/api/files/router.py +105 -0
- kiapi/api/health/_views/health_response.py +26 -0
- kiapi/api/health/router.py +28 -0
- kiapi/api/image/depthpro/_views/estimate_response.py +70 -0
- kiapi/api/image/depthpro/router.py +81 -0
- kiapi/api/image/ernie/_views/image_response.py +50 -0
- kiapi/api/image/ernie/router.py +181 -0
- kiapi/api/image/flux2/_views/image_response.py +53 -0
- kiapi/api/image/flux2/router.py +197 -0
- kiapi/api/image/ideogram4/_views/image_response.py +55 -0
- kiapi/api/image/ideogram4/router.py +87 -0
- kiapi/api/image/qwen/_views/image_response.py +47 -0
- kiapi/api/image/qwen/router.py +141 -0
- kiapi/api/image/seedvr2/_views/image_response.py +50 -0
- kiapi/api/image/seedvr2/router.py +83 -0
- kiapi/api/image/zimage/_views/image_response.py +49 -0
- kiapi/api/image/zimage/router.py +131 -0
- kiapi/api/jobs/_operations/get_job_id.py +18 -0
- kiapi/api/jobs/_views/job_delete_response.py +19 -0
- kiapi/api/jobs/_views/job_list_response.py +15 -0
- kiapi/api/jobs/router.py +62 -0
- kiapi/api/models/_schemas/openai_model_spec.py +26 -0
- kiapi/api/models/_views/model_list_response.py +15 -0
- kiapi/api/models/router.py +29 -0
- kiapi/api/video/ltx2/_views/__init__.py +1 -0
- kiapi/api/video/ltx2/_views/video_response.py +59 -0
- kiapi/api/video/ltx2/router.py +89 -0
- kiapi/api/web/_views/__init__.py +7 -0
- kiapi/api/web/_views/fetch_api_request.py +26 -0
- kiapi/api/web/_views/fetch_error_response.py +25 -0
- kiapi/api/web/router.py +302 -0
- kiapi/capabilities/__init__.py +24 -0
- kiapi/capabilities/_exceptions/CapabilityError.py +2 -0
- kiapi/capabilities/_exceptions/ValidationError.py +2 -0
- kiapi/capabilities/_helpers/attach_mflux_progress.py +50 -0
- kiapi/capabilities/_helpers/get_file_path.py +20 -0
- kiapi/capabilities/_helpers/resolve_file_ref.py +16 -0
- kiapi/capabilities/acestep/README.ja.md +174 -0
- kiapi/capabilities/acestep/README.md +167 -0
- kiapi/capabilities/acestep/__init__.py +37 -0
- kiapi/capabilities/acestep/_constants/description.py +122 -0
- kiapi/capabilities/acestep/_exceptions/ace_step_engine_error.py +2 -0
- kiapi/capabilities/acestep/_helpers/register.py +96 -0
- kiapi/capabilities/acestep/_models/acestep.py +105 -0
- kiapi/capabilities/acestep/_operations/handle_cover.py +23 -0
- kiapi/capabilities/acestep/_operations/handle_extract.py +38 -0
- kiapi/capabilities/acestep/_operations/handle_generate.py +18 -0
- kiapi/capabilities/acestep/_operations/handle_repaint.py +25 -0
- kiapi/capabilities/acestep/_operations/resolve_ace_step_paths.py +30 -0
- kiapi/capabilities/acestep/_operations/resolve_cover_params.py +21 -0
- kiapi/capabilities/acestep/_operations/resolve_engine.py +10 -0
- kiapi/capabilities/acestep/_operations/resolve_extract_params.py +24 -0
- kiapi/capabilities/acestep/_operations/resolve_generate_params.py +18 -0
- kiapi/capabilities/acestep/_operations/resolve_repaint_params.py +22 -0
- kiapi/capabilities/acestep/_schemas/ace_step_paths.py +29 -0
- kiapi/capabilities/acestep/_services/ace_step_engine.py +143 -0
- kiapi/capabilities/acestep/_settings.py +82 -0
- kiapi/capabilities/acestep/_views/ace_step_base.py +61 -0
- kiapi/capabilities/acestep/_views/cover_params.py +26 -0
- kiapi/capabilities/acestep/_views/cover_request.py +49 -0
- kiapi/capabilities/acestep/_views/extract_params.py +24 -0
- kiapi/capabilities/acestep/_views/extract_request.py +33 -0
- kiapi/capabilities/acestep/_views/generate_params.py +25 -0
- kiapi/capabilities/acestep/_views/generate_request.py +54 -0
- kiapi/capabilities/acestep/_views/repaint_params.py +27 -0
- kiapi/capabilities/acestep/_views/repaint_request.py +51 -0
- kiapi/capabilities/acestep/_views/track_params.py +7 -0
- kiapi/capabilities/acestep/worker_subprocess.py +247 -0
- kiapi/capabilities/audiogen/README.ja.md +49 -0
- kiapi/capabilities/audiogen/README.md +48 -0
- kiapi/capabilities/audiogen/__init__.py +25 -0
- kiapi/capabilities/audiogen/_constants/description.py +60 -0
- kiapi/capabilities/audiogen/_helpers/attach_audiogen_progress.py +27 -0
- kiapi/capabilities/audiogen/_helpers/register.py +42 -0
- kiapi/capabilities/audiogen/_helpers/validate_generate.py +14 -0
- kiapi/capabilities/audiogen/_models/audiogen.py +98 -0
- kiapi/capabilities/audiogen/_operations/handle_generate.py +27 -0
- kiapi/capabilities/audiogen/_operations/resolve_generate_params.py +25 -0
- kiapi/capabilities/audiogen/_settings.py +34 -0
- kiapi/capabilities/audiogen/_views/generate_params.py +14 -0
- kiapi/capabilities/audiogen/_views/generate_request.py +96 -0
- kiapi/capabilities/chat/README.ja.md +822 -0
- kiapi/capabilities/chat/README.md +806 -0
- kiapi/capabilities/chat/__init__.py +25 -0
- kiapi/capabilities/chat/_constants/description.py +163 -0
- kiapi/capabilities/chat/_helpers/register.py +67 -0
- kiapi/capabilities/chat/_models/qwen3_5.py +183 -0
- kiapi/capabilities/chat/_models/qwen3_omni.py +242 -0
- kiapi/capabilities/chat/_operations/apply_template.py +74 -0
- kiapi/capabilities/chat/_operations/completed_hermes_tool_call_text.py +9 -0
- kiapi/capabilities/chat/_operations/emit_streaming_response.py +297 -0
- kiapi/capabilities/chat/_operations/ensure_streaming_detokenizer_compat.py +49 -0
- kiapi/capabilities/chat/_operations/format_response.py +72 -0
- kiapi/capabilities/chat/_operations/handle_chat.py +25 -0
- kiapi/capabilities/chat/_operations/parse_hermes_tool_calls.py +63 -0
- kiapi/capabilities/chat/_operations/parse_json_tool_calls.py +66 -0
- kiapi/capabilities/chat/_operations/parse_messages.py +326 -0
- kiapi/capabilities/chat/_operations/resolve_chat_params.py +50 -0
- kiapi/capabilities/chat/_operations/stream_text_from_tokens.py +32 -0
- kiapi/capabilities/chat/_operations/strip_tool_calls.py +15 -0
- kiapi/capabilities/chat/_settings.py +74 -0
- kiapi/capabilities/chat/_utils/apply_parallel_tool_call_policy.py +17 -0
- kiapi/capabilities/chat/_utils/apply_seed.py +8 -0
- kiapi/capabilities/chat/_utils/load_audio_mono.py +31 -0
- kiapi/capabilities/chat/_utils/load_mlx_vlm.py +12 -0
- kiapi/capabilities/chat/_utils/warmup_params.py +26 -0
- kiapi/capabilities/chat/_views/chat_params.py +34 -0
- kiapi/capabilities/chat/_views/chat_request.py +153 -0
- kiapi/capabilities/depthpro/README.ja.md +131 -0
- kiapi/capabilities/depthpro/README.md +124 -0
- kiapi/capabilities/depthpro/__init__.py +23 -0
- kiapi/capabilities/depthpro/_constants/description.py +39 -0
- kiapi/capabilities/depthpro/_helpers/register.py +46 -0
- kiapi/capabilities/depthpro/_helpers/validate_estimate.py +32 -0
- kiapi/capabilities/depthpro/_models/depthpro.py +144 -0
- kiapi/capabilities/depthpro/_operations/handle_estimate.py +50 -0
- kiapi/capabilities/depthpro/_operations/is_quantize_override.py +12 -0
- kiapi/capabilities/depthpro/_operations/resolve_estimate_params.py +24 -0
- kiapi/capabilities/depthpro/_settings.py +46 -0
- kiapi/capabilities/depthpro/_views/estimate_params.py +21 -0
- kiapi/capabilities/depthpro/_views/estimate_request.py +63 -0
- kiapi/capabilities/embedding/README.ja.md +137 -0
- kiapi/capabilities/embedding/README.md +128 -0
- kiapi/capabilities/embedding/__init__.py +24 -0
- kiapi/capabilities/embedding/_constants/description.py +47 -0
- kiapi/capabilities/embedding/_helpers/register.py +66 -0
- kiapi/capabilities/embedding/_models/qwen3_text.py +53 -0
- kiapi/capabilities/embedding/_models/qwen3_vl.py +97 -0
- kiapi/capabilities/embedding/_operations/format_response.py +24 -0
- kiapi/capabilities/embedding/_operations/handle_embed.py +24 -0
- kiapi/capabilities/embedding/_operations/parse_inputs.py +108 -0
- kiapi/capabilities/embedding/_operations/resolve_embed_params.py +18 -0
- kiapi/capabilities/embedding/_settings.py +27 -0
- kiapi/capabilities/embedding/_utils/to_vector.py +20 -0
- kiapi/capabilities/embedding/_views/embed_params.py +17 -0
- kiapi/capabilities/embedding/_views/embed_request.py +39 -0
- kiapi/capabilities/ernie/README.ja.md +242 -0
- kiapi/capabilities/ernie/README.md +223 -0
- kiapi/capabilities/ernie/__init__.py +34 -0
- kiapi/capabilities/ernie/_constants/description.py +71 -0
- kiapi/capabilities/ernie/_helpers/register.py +60 -0
- kiapi/capabilities/ernie/_helpers/validate_edit.py +19 -0
- kiapi/capabilities/ernie/_helpers/validate_generate.py +8 -0
- kiapi/capabilities/ernie/_models/ernie.py +356 -0
- kiapi/capabilities/ernie/_operations/handle_edit.py +39 -0
- kiapi/capabilities/ernie/_operations/handle_generate.py +38 -0
- kiapi/capabilities/ernie/_operations/handle_train.py +77 -0
- kiapi/capabilities/ernie/_operations/is_quantize_override.py +16 -0
- kiapi/capabilities/ernie/_operations/resolve_edit_params.py +44 -0
- kiapi/capabilities/ernie/_operations/resolve_generate_params.py +40 -0
- kiapi/capabilities/ernie/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/ernie/_operations/resolve_train_params.py +43 -0
- kiapi/capabilities/ernie/_operations/validate_common.py +33 -0
- kiapi/capabilities/ernie/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/ernie/_settings.py +151 -0
- kiapi/capabilities/ernie/_views/edit_params.py +36 -0
- kiapi/capabilities/ernie/_views/edit_request.py +142 -0
- kiapi/capabilities/ernie/_views/generate_params.py +32 -0
- kiapi/capabilities/ernie/_views/generate_request.py +127 -0
- kiapi/capabilities/ernie/_views/train_params.py +28 -0
- kiapi/capabilities/ernie/_views/train_request.py +96 -0
- kiapi/capabilities/flux2/README.ja.md +260 -0
- kiapi/capabilities/flux2/README.md +241 -0
- kiapi/capabilities/flux2/__init__.py +36 -0
- kiapi/capabilities/flux2/_constants/description.py +81 -0
- kiapi/capabilities/flux2/_helpers/register.py +98 -0
- kiapi/capabilities/flux2/_helpers/validate_edit.py +12 -0
- kiapi/capabilities/flux2/_helpers/validate_generate.py +8 -0
- kiapi/capabilities/flux2/_models/flux2.py +396 -0
- kiapi/capabilities/flux2/_operations/handle_edit.py +44 -0
- kiapi/capabilities/flux2/_operations/handle_generate.py +46 -0
- kiapi/capabilities/flux2/_operations/handle_train.py +105 -0
- kiapi/capabilities/flux2/_operations/is_quantize_override.py +16 -0
- kiapi/capabilities/flux2/_operations/resolve_edit_params.py +43 -0
- kiapi/capabilities/flux2/_operations/resolve_generate_params.py +44 -0
- kiapi/capabilities/flux2/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/flux2/_operations/resolve_train_params.py +42 -0
- kiapi/capabilities/flux2/_operations/role_spec.py +13 -0
- kiapi/capabilities/flux2/_operations/split_repo.py +11 -0
- kiapi/capabilities/flux2/_operations/validate_common.py +35 -0
- kiapi/capabilities/flux2/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/flux2/_settings.py +181 -0
- kiapi/capabilities/flux2/_views/edit_params.py +36 -0
- kiapi/capabilities/flux2/_views/edit_request.py +145 -0
- kiapi/capabilities/flux2/_views/generate_params.py +36 -0
- kiapi/capabilities/flux2/_views/generate_request.py +150 -0
- kiapi/capabilities/flux2/_views/train_params.py +32 -0
- kiapi/capabilities/flux2/_views/train_request.py +102 -0
- kiapi/capabilities/ideogram4/README.ja.md +230 -0
- kiapi/capabilities/ideogram4/README.md +219 -0
- kiapi/capabilities/ideogram4/__init__.py +24 -0
- kiapi/capabilities/ideogram4/_constants/description.py +65 -0
- kiapi/capabilities/ideogram4/_helpers/register.py +44 -0
- kiapi/capabilities/ideogram4/_helpers/validate_generate.py +31 -0
- kiapi/capabilities/ideogram4/_models/ideogram4.py +120 -0
- kiapi/capabilities/ideogram4/_operations/handle_generate.py +30 -0
- kiapi/capabilities/ideogram4/_operations/is_quantize_override.py +12 -0
- kiapi/capabilities/ideogram4/_operations/resolve_generate_params.py +30 -0
- kiapi/capabilities/ideogram4/_settings.py +89 -0
- kiapi/capabilities/ideogram4/_views/generate_params.py +27 -0
- kiapi/capabilities/ideogram4/_views/generate_request.py +118 -0
- kiapi/capabilities/ltx2/README.ja.md +287 -0
- kiapi/capabilities/ltx2/README.md +274 -0
- kiapi/capabilities/ltx2/__init__.py +26 -0
- kiapi/capabilities/ltx2/_constants/description.py +81 -0
- kiapi/capabilities/ltx2/_helpers/register.py +58 -0
- kiapi/capabilities/ltx2/_helpers/validate_generate.py +42 -0
- kiapi/capabilities/ltx2/_models/ltx2.py +106 -0
- kiapi/capabilities/ltx2/_operations/detect_mode.py +19 -0
- kiapi/capabilities/ltx2/_operations/handle_generate.py +52 -0
- kiapi/capabilities/ltx2/_operations/resolve_generate_params.py +31 -0
- kiapi/capabilities/ltx2/_settings.py +93 -0
- kiapi/capabilities/ltx2/_views/generate_params.py +34 -0
- kiapi/capabilities/ltx2/_views/generate_request.py +151 -0
- kiapi/capabilities/qwen/README.ja.md +251 -0
- kiapi/capabilities/qwen/README.md +235 -0
- kiapi/capabilities/qwen/__init__.py +30 -0
- kiapi/capabilities/qwen/_constants/description.py +53 -0
- kiapi/capabilities/qwen/_helpers/register.py +60 -0
- kiapi/capabilities/qwen/_helpers/validate_edit.py +12 -0
- kiapi/capabilities/qwen/_helpers/validate_generate.py +12 -0
- kiapi/capabilities/qwen/_models/qwen.py +224 -0
- kiapi/capabilities/qwen/_operations/handle_edit.py +44 -0
- kiapi/capabilities/qwen/_operations/handle_generate.py +46 -0
- kiapi/capabilities/qwen/_operations/is_quantize_override.py +15 -0
- kiapi/capabilities/qwen/_operations/resolve_edit_params.py +35 -0
- kiapi/capabilities/qwen/_operations/resolve_generate_params.py +39 -0
- kiapi/capabilities/qwen/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/qwen/_operations/validate_common.py +32 -0
- kiapi/capabilities/qwen/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/qwen/_settings.py +107 -0
- kiapi/capabilities/qwen/_views/edit_params.py +36 -0
- kiapi/capabilities/qwen/_views/edit_request.py +138 -0
- kiapi/capabilities/qwen/_views/generate_params.py +37 -0
- kiapi/capabilities/qwen/_views/generate_request.py +149 -0
- kiapi/capabilities/seedvr2/README.ja.md +234 -0
- kiapi/capabilities/seedvr2/README.md +219 -0
- kiapi/capabilities/seedvr2/__init__.py +24 -0
- kiapi/capabilities/seedvr2/_constants/description.py +46 -0
- kiapi/capabilities/seedvr2/_helpers/register.py +60 -0
- kiapi/capabilities/seedvr2/_helpers/validate_upscale.py +52 -0
- kiapi/capabilities/seedvr2/_models/seedvr2.py +140 -0
- kiapi/capabilities/seedvr2/_operations/handle_upscale.py +42 -0
- kiapi/capabilities/seedvr2/_operations/is_quantize_override.py +12 -0
- kiapi/capabilities/seedvr2/_operations/resolve_upscale_params.py +30 -0
- kiapi/capabilities/seedvr2/_settings.py +74 -0
- kiapi/capabilities/seedvr2/_views/upscale_params.py +27 -0
- kiapi/capabilities/seedvr2/_views/upscale_request.py +94 -0
- kiapi/capabilities/web/README.ja.md +187 -0
- kiapi/capabilities/web/README.md +171 -0
- kiapi/capabilities/web/__init__.py +30 -0
- kiapi/capabilities/web/_constants/description.py +38 -0
- kiapi/capabilities/web/_exceptions/FetchError.py +24 -0
- kiapi/capabilities/web/_exceptions/SearchBackendError.py +11 -0
- kiapi/capabilities/web/_helpers/register.py +59 -0
- kiapi/capabilities/web/_models/crawl4ai.py +32 -0
- kiapi/capabilities/web/_models/searxng.py +44 -0
- kiapi/capabilities/web/_operations/handle_fetch.py +145 -0
- kiapi/capabilities/web/_operations/handle_search.py +56 -0
- kiapi/capabilities/web/_operations/resolve_fetch_params.py +19 -0
- kiapi/capabilities/web/_operations/resolve_search_params.py +34 -0
- kiapi/capabilities/web/_operations/resolve_searxng_config_dir.py +21 -0
- kiapi/capabilities/web/_services/__init__.py +1 -0
- kiapi/capabilities/web/_services/web_backend_process.py +144 -0
- kiapi/capabilities/web/_settings.py +138 -0
- kiapi/capabilities/web/_views/fetch_params.py +27 -0
- kiapi/capabilities/web/_views/fetch_request.py +29 -0
- kiapi/capabilities/web/_views/fetch_result.py +20 -0
- kiapi/capabilities/web/_views/search_params.py +43 -0
- kiapi/capabilities/web/_views/search_request.py +93 -0
- kiapi/capabilities/web/_views/search_response.py +49 -0
- kiapi/capabilities/web/resources/__init__.py +0 -0
- kiapi/capabilities/web/resources/searxng/__init__.py +0 -0
- kiapi/capabilities/web/resources/searxng/settings.yml +11 -0
- kiapi/capabilities/zimage/README.ja.md +249 -0
- kiapi/capabilities/zimage/README.md +231 -0
- kiapi/capabilities/zimage/__init__.py +34 -0
- kiapi/capabilities/zimage/_constants/description.py +73 -0
- kiapi/capabilities/zimage/_helpers/register.py +62 -0
- kiapi/capabilities/zimage/_helpers/validate_generate.py +37 -0
- kiapi/capabilities/zimage/_models/zimage.py +278 -0
- kiapi/capabilities/zimage/_operations/handle_generate.py +38 -0
- kiapi/capabilities/zimage/_operations/handle_train.py +78 -0
- kiapi/capabilities/zimage/_operations/is_quantize_override.py +11 -0
- kiapi/capabilities/zimage/_operations/resolve_generate_params.py +39 -0
- kiapi/capabilities/zimage/_operations/resolve_lora_params.py +23 -0
- kiapi/capabilities/zimage/_operations/resolve_train_params.py +38 -0
- kiapi/capabilities/zimage/_schemas/lora_ref.py +27 -0
- kiapi/capabilities/zimage/_settings.py +166 -0
- kiapi/capabilities/zimage/_views/generate_params.py +23 -0
- kiapi/capabilities/zimage/_views/generate_request.py +127 -0
- kiapi/capabilities/zimage/_views/train_params.py +22 -0
- kiapi/capabilities/zimage/_views/train_request.py +101 -0
- kiapi/cli/__init__.py +11 -0
- kiapi/cli/_helpers/dedupe_resources.py +12 -0
- kiapi/cli/_helpers/register_all_capabilities.py +36 -0
- kiapi/cli/_helpers/run_resources.py +24 -0
- kiapi/cli/_helpers/select_specs.py +67 -0
- kiapi/cli/activate/_operations/preflight_hf_access.py +129 -0
- kiapi/cli/activate/cli.py +37 -0
- kiapi/cli/check/_helpers/check_audio_acestep_turbo.py +22 -0
- kiapi/cli/check/_helpers/check_audio_acestep_xl_base.py +22 -0
- kiapi/cli/check/_helpers/check_audio_audiogen_medium.py +24 -0
- kiapi/cli/check/_helpers/check_chat_chat_qwen3_6_27b.py +19 -0
- kiapi/cli/check/_helpers/check_chat_chat_qwen3_omni.py +19 -0
- kiapi/cli/check/_helpers/check_embedding_embedding_qwen3_embedding_8b.py +14 -0
- kiapi/cli/check/_helpers/check_embedding_embedding_qwen3_vl_embedding_2b.py +19 -0
- kiapi/cli/check/_helpers/check_image_depthpro_base.py +21 -0
- kiapi/cli/check/_helpers/check_image_ernie_base.py +23 -0
- kiapi/cli/check/_helpers/check_image_ernie_turbo.py +23 -0
- kiapi/cli/check/_helpers/check_image_flux2_klein_9b.py +23 -0
- kiapi/cli/check/_helpers/check_image_flux2_klein_base_4b.py +23 -0
- kiapi/cli/check/_helpers/check_image_flux2_klein_base_9b.py +23 -0
- kiapi/cli/check/_helpers/check_image_ideogram4_fp8.py +23 -0
- kiapi/cli/check/_helpers/check_image_qwen_edit_2509.py +27 -0
- kiapi/cli/check/_helpers/check_image_qwen_image.py +23 -0
- kiapi/cli/check/_helpers/check_image_seedvr2_3b.py +23 -0
- kiapi/cli/check/_helpers/check_image_seedvr2_7b.py +23 -0
- kiapi/cli/check/_helpers/check_image_zimage_base.py +23 -0
- kiapi/cli/check/_helpers/check_image_zimage_turbo.py +23 -0
- kiapi/cli/check/_helpers/check_video_ltx2_distilled.py +26 -0
- kiapi/cli/check/_helpers/check_web_web_fetch.py +14 -0
- kiapi/cli/check/_helpers/check_web_web_search.py +14 -0
- kiapi/cli/check/_operations/build_check_result.py +20 -0
- kiapi/cli/check/_operations/check_context.py +10 -0
- kiapi/cli/check/_operations/create_sample_image.py +46 -0
- kiapi/cli/check/_schemas/check_result.py +12 -0
- kiapi/cli/check/cli.py +89 -0
- kiapi/cli/cli.py +29 -0
- kiapi/cli/config/cli.py +17 -0
- kiapi/cli/config/edit/cli.py +32 -0
- kiapi/cli/config/init/cli.py +33 -0
- kiapi/cli/config/show/cli.py +13 -0
- kiapi/cli/config/template/cli.py +36 -0
- kiapi/cli/deactivate/cli.py +49 -0
- kiapi/cli/run/asgi.py +16 -0
- kiapi/cli/run/cli.py +59 -0
- kiapi/cli/service/__init__.py +5 -0
- kiapi/cli/service/_services/service_manager.py +107 -0
- kiapi/cli/service/cli.py +19 -0
- kiapi/cli/service/install/cli.py +17 -0
- kiapi/cli/service/start/cli.py +22 -0
- kiapi/cli/service/status/cli.py +81 -0
- kiapi/cli/service/stop/cli.py +19 -0
- kiapi/cli/service/uninstall/cli.py +16 -0
- kiapi/cli/status/cli.py +226 -0
- kiapi/core/app/__init__.py +16 -0
- kiapi/core/app/_schemas/app_context.py +28 -0
- kiapi/core/app/_services/user_directory.py +59 -0
- kiapi/core/app/_settings.py +46 -0
- kiapi/core/capability/__init__.py +11 -0
- kiapi/core/capability/_schemas/capability_spec.py +17 -0
- kiapi/core/capability/_services/capability_spec_registry.py +21 -0
- kiapi/core/config/__init__.py +11 -0
- kiapi/core/config/_exceptions/user_config_error.py +2 -0
- kiapi/core/config/_helpers/get_user_settings_path.py +7 -0
- kiapi/core/config/_helpers/load_user_settings.py +54 -0
- kiapi/core/file/__init__.py +37 -0
- kiapi/core/file/_helpers/create_file_store.py +7 -0
- kiapi/core/file/_helpers/resolve_file_ref.py +90 -0
- kiapi/core/file/_schemas/file_data_url_ref.py +19 -0
- kiapi/core/file/_schemas/file_id_ref.py +16 -0
- kiapi/core/file/_schemas/file_record.py +46 -0
- kiapi/core/file/_schemas/file_url_ref.py +16 -0
- kiapi/core/file/_services/file_store.py +138 -0
- kiapi/core/file/_settings.py +22 -0
- kiapi/core/file/_types/file_id.py +2 -0
- kiapi/core/file/_types/file_ref.py +12 -0
- kiapi/core/file/_views/resolved_file_ref.py +16 -0
- kiapi/core/job/__init__.py +24 -0
- kiapi/core/job/_enums/job_status.py +9 -0
- kiapi/core/job/_helpers/creep_progress.py +123 -0
- kiapi/core/job/_models/job.py +121 -0
- kiapi/core/job/_services/job_store.py +33 -0
- kiapi/core/job/_services/progress_reporter.py +79 -0
- kiapi/core/job/_types/job_id.py +3 -0
- kiapi/core/job/_types/job_result.py +5 -0
- kiapi/core/job/_types/job_type.py +4 -0
- kiapi/core/logging/__init__.py +14 -0
- kiapi/core/logging/_helpers/get_log_level.py +8 -0
- kiapi/core/logging/_helpers/setup_logger.py +14 -0
- kiapi/core/logging/_settings.py +34 -0
- kiapi/core/logging/_types/log_level.py +3 -0
- kiapi/core/memory/__init__.py +21 -0
- kiapi/core/memory/_exceptions/memory_budget_error.py +2 -0
- kiapi/core/memory/_helpers/create_memory_manager.py +17 -0
- kiapi/core/memory/_operations/log_memory_limit.py +29 -0
- kiapi/core/memory/_operations/resolve_effective_memory_limit_gb.py +13 -0
- kiapi/core/memory/_operations/resolve_framework_strategy.py +42 -0
- kiapi/core/memory/_schemas/framework_strategy.py +14 -0
- kiapi/core/memory/_schemas/memory_stats.py +24 -0
- kiapi/core/memory/_schemas/resident_model.py +14 -0
- kiapi/core/memory/_schemas/resident_model_stats.py +49 -0
- kiapi/core/memory/_services/memory_manager.py +257 -0
- kiapi/core/memory/_settings.py +36 -0
- kiapi/core/memory/_types/framework_name.py +4 -0
- kiapi/core/memory/_types/resident_key.py +4 -0
- kiapi/core/model/__init__.py +36 -0
- kiapi/core/model/_exceptions/unknown_model_error.py +2 -0
- kiapi/core/model/_schemas/model_spec.py +145 -0
- kiapi/core/model/_services/model_registry.py +85 -0
- kiapi/core/model/_types/model_alias.py +2 -0
- kiapi/core/model/_types/model_domain.py +6 -0
- kiapi/core/model/_types/model_family.py +5 -0
- kiapi/core/model/_types/model_key.py +8 -0
- kiapi/core/model/_types/model_name.py +4 -0
- kiapi/core/model/_types/model_repo.py +3 -0
- kiapi/core/net/__init__.py +16 -0
- kiapi/core/net/_exceptions/unsafe_url_error.py +7 -0
- kiapi/core/net/_helpers/verify_public_url.py +68 -0
- kiapi/core/net/_settings.py +28 -0
- kiapi/core/setup/__init__.py +25 -0
- kiapi/core/setup/_exceptions/setup_required_error.py +2 -0
- kiapi/core/setup/_schemas/docker_image_resource.py +37 -0
- kiapi/core/setup/_schemas/hf_snapshot_resource.py +50 -0
- kiapi/core/setup/_schemas/local_path_resource.py +43 -0
- kiapi/core/setup/_schemas/python_package_resource.py +58 -0
- kiapi/core/setup/_schemas/python_venv_resource.py +63 -0
- kiapi/core/setup/_schemas/setup_status.py +7 -0
- kiapi/core/setup/_schemas/url_file_resource.py +43 -0
- kiapi/core/setup/_services/setup_manager.py +331 -0
- kiapi/core/setup/_types/setup_resource.py +21 -0
- kiapi/core/setup/_types/setup_target.py +11 -0
- kiapi/core/workdir/__init__.py +8 -0
- kiapi/core/workdir/_helpers/create_work_dir.py +11 -0
- kiapi/core/workdir/_settings.py +21 -0
- kiapi/core/worker/__init__.py +23 -0
- kiapi/core/worker/_helpers/create_worker.py +9 -0
- kiapi/core/worker/_services/worker.py +165 -0
- kiapi/core/worker/_settings.py +36 -0
- kiapi/core/worker/_types/job_thunk.py +6 -0
- kiapi-0.1.0.dist-info/METADATA +337 -0
- kiapi-0.1.0.dist-info/RECORD +465 -0
- kiapi-0.1.0.dist-info/WHEEL +4 -0
- kiapi-0.1.0.dist-info/entry_points.txt +2 -0
- kiapi-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# ideogram4
|
|
2
|
+
|
|
3
|
+
**English** | [日本語](README.ja.md)
|
|
4
|
+
|
|
5
|
+
[mflux Ideogram 4 FP8](https://github.com/filipstrand/mflux/blob/main/src/mflux/models/ideogram4/README.md) provides typography-friendly text image generation functionality.
|
|
6
|
+
Ideogram 4 is a model suitable for situations where you want to handle text, signs, labels, logo-like text, etc. in images.
|
|
7
|
+
kiapi only exposes txt2img and saves the generated results as Files API artifacts.
|
|
8
|
+
|
|
9
|
+
- **generate**:
|
|
10
|
+
- Generate images from Ideogram 4's JSON caption or regular text prompts
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## API
|
|
14
|
+
|
|
15
|
+
| Endpoint | Name | Description |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| `POST /v1/image/ideogram4/generate` | Image generation | Generate one image from JSON caption or text prompt. |
|
|
18
|
+
| `GET /v1/image/ideogram4/models` | Model list | Returns a list of available models. |
|
|
19
|
+
| `GET /v1/image/ideogram4/openapi.json` | OpenAPI | Returns detailed input/output specifications, prompt shapes, constraints, and TIPS. |
|
|
20
|
+
|
|
21
|
+
## API Docs
|
|
22
|
+
|
|
23
|
+
- [OpenAPI JSON](https://kiarina.github.io/kiapi/v1/image/ideogram4/openapi.json)
|
|
24
|
+
- [Swagger UI](https://kiarina.github.io/kiapi/v1/image/ideogram4/docs.html)
|
|
25
|
+
- [ReDoc](https://kiarina.github.io/kiapi/v1/image/ideogram4/redoc.html)
|
|
26
|
+
|
|
27
|
+
## Dependencies
|
|
28
|
+
|
|
29
|
+
| Package | License | Description |
|
|
30
|
+
|---|---|---|
|
|
31
|
+
| [mflux](https://github.com/filipstrand/mflux) | MIT | Uses the MLX implementation of Ideogram 4 FP8. |
|
|
32
|
+
|
|
33
|
+
## Models
|
|
34
|
+
|
|
35
|
+
| Model | License | Terms | Size | Description |
|
|
36
|
+
|---|---|---|---:|---|
|
|
37
|
+
| [ideogram-ai/ideogram-4-fp8](https://huggingface.co/ideogram-ai/ideogram-4-fp8) | Ideogram license (non-commercial) | Required | 27.5 GB | `fp8` (default). Hugging Face's gated repo. Default is `1024x1024`, `preset: V4_DEFAULT_20`, `quantize: null`. |
|
|
38
|
+
|
|
39
|
+
## Notes
|
|
40
|
+
|
|
41
|
+
- **Hugging Face's gated repo**:
|
|
42
|
+
The model weights are obtained from `ideogram-ai/ideogram-4-fp8`.
|
|
43
|
+
Before running it for the first time, you need to approve access on Hugging Face and authenticate in the local environment.
|
|
44
|
+
- **JSON caption recommended**:
|
|
45
|
+
Although it accepts regular string prompts, Ideogram 4 performs best with structured JSON captions.
|
|
46
|
+
If you want to target the text in the image, set `type: "text"` to `compositional_deconstruction.elements[]`,
|
|
47
|
+
The basics are to include `bbox`, `text`, and `desc`.
|
|
48
|
+
- **bbox coordinates**:
|
|
49
|
+
`bbox` in JSON caption has the format `[x1, y1, x2, y2]`.
|
|
50
|
+
Ideogram 4's prompting guide treats them as normalized layout coordinates from 0-1000.
|
|
51
|
+
- **Preset**:
|
|
52
|
+
`preset` is one of `V4_DEFAULT_20` / `V4_QUALITY_48` / `V4_TURBO_12`.
|
|
53
|
+
Default is `V4_DEFAULT_20`. If quality is your priority, use `V4_QUALITY_48`, and if speed is your priority, use `V4_TURBO_12`.
|
|
54
|
+
- **Image size**:
|
|
55
|
+
`width` / `height` are multiples of 16, defaulting to `1024x1024`.
|
|
56
|
+
The default upper limit is `2048x2048` and the lower limit is `256x256`.
|
|
57
|
+
- **quantize override**:
|
|
58
|
+
`quantize` is `3` / `4` / `5` / `6` / `8` / `null`.
|
|
59
|
+
If you specify `quantize` that is different from the default value in the request, it will be loaded, executed, and released as a one-time temporary model.
|
|
60
|
+
- **Response format**:
|
|
61
|
+
If you generate one artifact with sync, it will return the raw image bytes unless you specify `Accept: application/json`.
|
|
62
|
+
You can reference saved artifacts and Jobs from the `X-Kiapi-File-Id` and `X-Kiapi-Job-Id` headers.
|
|
63
|
+
If you want Job JSON or async, use `Accept: application/json`.
|
|
64
|
+
- **Output format**:
|
|
65
|
+
`format` is `png` / `jpeg` / `webp`. Default is `png`.
|
|
66
|
+
`quality` is the encoding quality of `jpeg` / `webp`, `1..100`, default is `90`.
|
|
67
|
+
- **Safety Filter**:
|
|
68
|
+
Some prompts may return `Image blocked by safety filter` images, including false positives.
|
|
69
|
+
kiapi does not make this an HTTP error, but instead stores the returned image as an artifact.
|
|
70
|
+
- **Not supported**:
|
|
71
|
+
We do not publish image-to-image, image editing, LoRA learning, hosted Magic Prompt API, or checkpoint layouts other than FP8.
|
|
72
|
+
|
|
73
|
+
## Prompt JSON
|
|
74
|
+
|
|
75
|
+
This is the recommended basic form of JSON caption.
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"high_level_description": "Overall scene description.",
|
|
79
|
+
"style_description": "Optional style, lighting, medium, and color guidance.",
|
|
80
|
+
"compositional_deconstruction": {
|
|
81
|
+
"background": "Background and layout description.",
|
|
82
|
+
"elements": [
|
|
83
|
+
{
|
|
84
|
+
"type": "text",
|
|
85
|
+
"bbox": [360, 420, 640, 560],
|
|
86
|
+
"text": "HELLO",
|
|
87
|
+
"desc": "Crisp black uppercase letters centered on the sign."
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
For detailed instructions, please also refer to [Ideogram 4 prompting guide](https://github.com/ideogram-oss/ideogram4/blob/main/docs/prompting.md).
|
|
94
|
+
|
|
95
|
+
## Quickstart
|
|
96
|
+
|
|
97
|
+
### generate - Generate an image with text using JSON caption
|
|
98
|
+
|
|
99
|
+
Returns Job JSON:
|
|
100
|
+
```bash
|
|
101
|
+
PARAMS=$(jq -n '{
|
|
102
|
+
model: "fp8",
|
|
103
|
+
mode: "sync",
|
|
104
|
+
prompt: {
|
|
105
|
+
high_level_description: "A clean studio photo of a white notebook with the word MFLUX on the cover.",
|
|
106
|
+
style_description: "Minimal product photography, soft window light, realistic paper texture.",
|
|
107
|
+
compositional_deconstruction: {
|
|
108
|
+
background: "Warm wooden desk with soft shadows.",
|
|
109
|
+
elements: [
|
|
110
|
+
{
|
|
111
|
+
type: "text",
|
|
112
|
+
bbox: [390, 430, 610, 560],
|
|
113
|
+
text: "MFLUX",
|
|
114
|
+
desc: "Crisp black uppercase letters centered on the notebook cover."
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
width: 1024,
|
|
120
|
+
height: 1024,
|
|
121
|
+
preset: "V4_DEFAULT_20",
|
|
122
|
+
seed: 42
|
|
123
|
+
}')
|
|
124
|
+
|
|
125
|
+
curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/ideogram4/generate \
|
|
126
|
+
-H 'Accept: application/json' \
|
|
127
|
+
-H 'Content-Type: application/json' \
|
|
128
|
+
--data-binary "$PARAMS" |
|
|
129
|
+
jq .
|
|
130
|
+
```
|
|
131
|
+
Save only the image:
|
|
132
|
+
```bash
|
|
133
|
+
PARAMS=$(jq -n '{
|
|
134
|
+
model: "fp8",
|
|
135
|
+
mode: "sync",
|
|
136
|
+
prompt: {
|
|
137
|
+
high_level_description: "A square cafe poster with the large word KIASA.",
|
|
138
|
+
style_description: "Clean editorial poster, warm morning colors, sharp typography.",
|
|
139
|
+
compositional_deconstruction: {
|
|
140
|
+
background: "Cream wall with a simple coffee cup illustration.",
|
|
141
|
+
elements: [
|
|
142
|
+
{
|
|
143
|
+
type: "text",
|
|
144
|
+
bbox: [260, 320, 740, 500],
|
|
145
|
+
text: "KIASA",
|
|
146
|
+
desc: "Large bold serif letters, perfectly readable."
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
width: 1024,
|
|
152
|
+
height: 1024,
|
|
153
|
+
seed: 7
|
|
154
|
+
}')
|
|
155
|
+
|
|
156
|
+
curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/ideogram4/generate \
|
|
157
|
+
-H 'Content-Type: application/json' \
|
|
158
|
+
--data-binary "$PARAMS" \
|
|
159
|
+
-o ideogram4.png
|
|
160
|
+
```
|
|
161
|
+
### generate - plain text
|
|
162
|
+
```bash
|
|
163
|
+
PARAMS=$(jq -n '{
|
|
164
|
+
mode: "sync",
|
|
165
|
+
prompt: "A vintage travel poster for TOKYO, the word TOKYO is large and perfectly readable, bright flat colors",
|
|
166
|
+
width: 768,
|
|
167
|
+
height: 1024,
|
|
168
|
+
preset: "V4_QUALITY_48",
|
|
169
|
+
seed: 11
|
|
170
|
+
}')
|
|
171
|
+
|
|
172
|
+
curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/ideogram4/generate \
|
|
173
|
+
-H 'Content-Type: application/json' \
|
|
174
|
+
--data-binary "$PARAMS" \
|
|
175
|
+
-o ideogram4-text.png
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### async
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
PARAMS=$(jq -n '{
|
|
182
|
+
mode: "async",
|
|
183
|
+
prompt: {
|
|
184
|
+
high_level_description: "A clean packaging mockup for a tea box labeled HIKARI.",
|
|
185
|
+
compositional_deconstruction: {
|
|
186
|
+
background: "Soft green studio backdrop.",
|
|
187
|
+
elements: [
|
|
188
|
+
{
|
|
189
|
+
type: "text",
|
|
190
|
+
bbox: [330, 360, 670, 520],
|
|
191
|
+
text: "HIKARI",
|
|
192
|
+
desc: "Elegant uppercase letters printed on the front of the box."
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
width: 1024,
|
|
198
|
+
height: 1024,
|
|
199
|
+
preset: "V4_TURBO_12"
|
|
200
|
+
}')
|
|
201
|
+
|
|
202
|
+
JOB=$(curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/ideogram4/generate \
|
|
203
|
+
-H 'Accept: application/json' \
|
|
204
|
+
-H 'Content-Type: application/json' \
|
|
205
|
+
--data-binary "$PARAMS" |
|
|
206
|
+
jq -r .job_id)
|
|
207
|
+
|
|
208
|
+
curl -sS http://localhost:${PORT:-8000}/v1/jobs/$JOB | jq .
|
|
209
|
+
```
|
|
210
|
+
After completion, use the Job's `artifacts[0]` or `result.file_id` to get the image.
|
|
211
|
+
```bash
|
|
212
|
+
FID=$(curl -sS http://localhost:${PORT:-8000}/v1/jobs/$JOB | jq -r .result.file_id)
|
|
213
|
+
curl -sS http://localhost:${PORT:-8000}/v1/files/$FID/download -o ideogram4-async.png
|
|
214
|
+
```
|
|
215
|
+
### Model list and help
|
|
216
|
+
```bash
|
|
217
|
+
curl -sS http://localhost:${PORT:-8000}/v1/image/ideogram4/models | jq .
|
|
218
|
+
curl -sS http://localhost:${PORT:-8000}/v1/image/ideogram4/openapi.json | jq .
|
|
219
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""ideogram4 family — Ideogram 4 FP8 text-to-image via mflux.
|
|
2
|
+
|
|
3
|
+
Endpoint: ``POST /v1/image/ideogram4/generate``. Ideogram 4 is typography-
|
|
4
|
+
focused txt2img. It accepts plain text, but structured JSON captions are the
|
|
5
|
+
preferred prompt form and are surfaced in help. A ``quantize`` override runs on
|
|
6
|
+
a one-off transient model; otherwise the resident model is used.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from kiapi.capabilities import ValidationError
|
|
10
|
+
|
|
11
|
+
from ._helpers.register import register
|
|
12
|
+
from ._helpers.validate_generate import validate_generate
|
|
13
|
+
from ._operations.handle_generate import handle_generate
|
|
14
|
+
from ._settings import settings_manager
|
|
15
|
+
from ._views.generate_request import GenerateRequest
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"GenerateRequest", # ._views
|
|
19
|
+
"ValidationError", # kiapi.capabilities
|
|
20
|
+
"handle_generate", # ._operations
|
|
21
|
+
"register", # ._helpers
|
|
22
|
+
"settings_manager", # ._settings
|
|
23
|
+
"validate_generate", # ._helpers
|
|
24
|
+
]
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
DESCRIPTION = """Typography-focused text-to-image generation (Ideogram 4 FP8 via mflux).
|
|
2
|
+
|
|
3
|
+
One operation: `/generate` (text-to-image). Ideogram 4 excels at rendering legible
|
|
4
|
+
text and typography. There is no image-to-image, no training, and no hosted Magic
|
|
5
|
+
Prompt API.
|
|
6
|
+
|
|
7
|
+
## Upstream docs
|
|
8
|
+
- [mflux — Ideogram 4](https://github.com/filipstrand/mflux/blob/main/src/mflux/models/ideogram4/README.md) — the MLX engine kiapi runs
|
|
9
|
+
- [ideogram-ai/ideogram-4-fp8](https://huggingface.co/ideogram-ai/ideogram-4-fp8) — the `fp8` weights (gated)
|
|
10
|
+
|
|
11
|
+
## Models
|
|
12
|
+
- **fp8** (default) — `ideogram-ai/ideogram-4-fp8`. The only variant; discover it
|
|
13
|
+
at `GET /v1/image/ideogram4/models`. The Hugging Face repo is **gated**: approve
|
|
14
|
+
access to `ideogram-ai/ideogram-4-fp8` before the first download. Non-FP8
|
|
15
|
+
checkpoint layouts are not supported.
|
|
16
|
+
|
|
17
|
+
## Prompting (JSON caption preferred)
|
|
18
|
+
Ideogram 4 follows a **structured JSON caption** far better than plain text,
|
|
19
|
+
especially for laying out and spelling words. Plain text is accepted but usually
|
|
20
|
+
weaker. See the official prompt guide for the full caption schema, key-order
|
|
21
|
+
rules, bbox layout, and color-palette conditioning:
|
|
22
|
+
- [Ideogram 4 prompting guide](https://github.com/ideogram-oss/ideogram-4/blob/main/docs/prompting.md)
|
|
23
|
+
|
|
24
|
+
A caption looks like:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"high_level_description": "A clean studio photo of a white notebook with the word MFLUX on the cover.",
|
|
29
|
+
"style_description": "Soft daylight, shallow depth of field, product-photography aesthetic.",
|
|
30
|
+
"compositional_deconstruction": {
|
|
31
|
+
"background": "Warm wooden desk with soft window light.",
|
|
32
|
+
"elements": [
|
|
33
|
+
{
|
|
34
|
+
"type": "text",
|
|
35
|
+
"bbox": [420, 420, 620, 560],
|
|
36
|
+
"text": "MFLUX",
|
|
37
|
+
"desc": "Crisp black uppercase letters centered on the notebook."
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- `bbox` is `[x1, y1, x2, y2]` in normalized **0-1000** layout coordinates.
|
|
45
|
+
- `type` is `text` (needs a `text` field) or `obj`.
|
|
46
|
+
- Set `strict_caption_validation=true` to fail (400) on mflux caption-schema
|
|
47
|
+
warnings; `warn_on_caption_issues` (default true) just surfaces them.
|
|
48
|
+
|
|
49
|
+
## Presets
|
|
50
|
+
`preset` bundles steps + guidance + noise schedule. Trade speed for quality:
|
|
51
|
+
`V4_TURBO_12` (fast, 12 steps) → `V4_DEFAULT_20` (balanced) → `V4_QUALITY_48`
|
|
52
|
+
(best, 48 steps).
|
|
53
|
+
|
|
54
|
+
## TIPS
|
|
55
|
+
- For a quick image, call `sync` without `Accept: application/json` to get the raw
|
|
56
|
+
bytes straight back (`curl -o out.png`).
|
|
57
|
+
- `width`/`height` must be multiples of 16 and within 256..2048 (default 1024).
|
|
58
|
+
- First use downloads the gated FP8 weights; run `kiapi activate` ahead of time to
|
|
59
|
+
avoid a cold-start download on the first request.
|
|
60
|
+
|
|
61
|
+
## Performance
|
|
62
|
+
- **fp8**: roughly 26-28 GiB peak RSS at 1024x1024 / V4_DEFAULT_20.
|
|
63
|
+
- **first request**: may be much slower if gated weights are still being
|
|
64
|
+
downloaded from Hugging Face.
|
|
65
|
+
"""
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Register ideogram4's models + OpenAPI description in the global registries."""
|
|
2
|
+
|
|
3
|
+
from kiapi.core.capability import CapabilitySpec, capability_spec_registry
|
|
4
|
+
from kiapi.core.model import ModelSpec, model_registry
|
|
5
|
+
from kiapi.core.setup import HfSnapshotResource
|
|
6
|
+
|
|
7
|
+
from .._constants.description import DESCRIPTION
|
|
8
|
+
from .._models import ideogram4
|
|
9
|
+
from .._settings import settings_manager
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def register() -> None:
|
|
13
|
+
capability_spec_registry.register(
|
|
14
|
+
CapabilitySpec(
|
|
15
|
+
name="ideogram4",
|
|
16
|
+
domain="image",
|
|
17
|
+
title="kiapi Ideogram 4 API",
|
|
18
|
+
summary="Generate images from text prompts with Ideogram 4.",
|
|
19
|
+
description=DESCRIPTION,
|
|
20
|
+
openapi_path="/v1/image/ideogram4/openapi.json",
|
|
21
|
+
docs_path="/v1/image/ideogram4/docs",
|
|
22
|
+
redoc_path="/v1/image/ideogram4/redoc",
|
|
23
|
+
path_prefixes=("/v1/image/ideogram4",),
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
_s = settings_manager.get_settings()
|
|
28
|
+
|
|
29
|
+
model_registry.register(
|
|
30
|
+
ModelSpec(
|
|
31
|
+
name="fp8",
|
|
32
|
+
family="ideogram4",
|
|
33
|
+
domain="image",
|
|
34
|
+
repo=_s.model_repo,
|
|
35
|
+
module=ideogram4,
|
|
36
|
+
weight_gb=26.0,
|
|
37
|
+
peak_headroom_gb=4.0,
|
|
38
|
+
framework="mlx",
|
|
39
|
+
priority=0,
|
|
40
|
+
aliases=("ideogram4", "ideogram-4", "ideogram-ai/ideogram-4-fp8"),
|
|
41
|
+
default=True,
|
|
42
|
+
setup_resources=(HfSnapshotResource(repo=_s.model_repo, disk_gb=27.5),),
|
|
43
|
+
)
|
|
44
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from kiapi.capabilities import ValidationError
|
|
2
|
+
|
|
3
|
+
from .._settings import settings_manager
|
|
4
|
+
from .._views.generate_request import GenerateRequest
|
|
5
|
+
|
|
6
|
+
_MULTIPLE = 16
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def validate_generate(req: GenerateRequest) -> None:
|
|
10
|
+
settings = settings_manager.get_settings()
|
|
11
|
+
width = req.width if req.width is not None else settings.default_width
|
|
12
|
+
height = req.height if req.height is not None else settings.default_height
|
|
13
|
+
|
|
14
|
+
if width < settings.min_width or height < settings.min_height:
|
|
15
|
+
raise ValidationError(
|
|
16
|
+
f"width and height must be >= {settings.min_width}x{settings.min_height}"
|
|
17
|
+
)
|
|
18
|
+
if width % _MULTIPLE or height % _MULTIPLE:
|
|
19
|
+
raise ValidationError(f"width and height must be multiples of {_MULTIPLE}")
|
|
20
|
+
if width > settings.max_width or height > settings.max_height:
|
|
21
|
+
raise ValidationError(
|
|
22
|
+
f"size {width}x{height} exceeds the cap {settings.max_width}x{settings.max_height}"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if req.quantize is not None and req.quantize not in (3, 4, 5, 6, 8):
|
|
26
|
+
raise ValidationError("quantize must be one of 3, 4, 5, 6, 8")
|
|
27
|
+
|
|
28
|
+
if isinstance(req.prompt, str) and not req.prompt.strip():
|
|
29
|
+
raise ValidationError("prompt must not be empty")
|
|
30
|
+
if isinstance(req.prompt, dict) and not req.prompt:
|
|
31
|
+
raise ValidationError("prompt JSON must not be empty")
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Handler for Ideogram 4 FP8 txt2img via mflux."""
|
|
2
|
+
|
|
3
|
+
import gc
|
|
4
|
+
import time
|
|
5
|
+
from types import SimpleNamespace
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from kiapi.capabilities import attach_mflux_progress
|
|
9
|
+
from kiapi.core.file import FileStore
|
|
10
|
+
from kiapi.core.model import ModelSpec
|
|
11
|
+
from kiapi.core.workdir import create_work_dir
|
|
12
|
+
|
|
13
|
+
from .._views.generate_params import GenerateParams
|
|
14
|
+
|
|
15
|
+
FEATURES = {"text"}
|
|
16
|
+
|
|
17
|
+
_SAFETY_FILTER_NOTE = (
|
|
18
|
+
"Ideogram 4 may return an 'Image blocked by safety filter' image; "
|
|
19
|
+
"kiapi stores the returned image as-is."
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def build_model(spec: ModelSpec, *, quantize: int | None) -> Any:
|
|
24
|
+
from mflux.models.common.config import ModelConfig # type: ignore
|
|
25
|
+
from mflux.models.ideogram4 import Ideogram4 # type: ignore
|
|
26
|
+
|
|
27
|
+
return Ideogram4(
|
|
28
|
+
quantize=quantize,
|
|
29
|
+
model_path=spec.repo,
|
|
30
|
+
model_config=ModelConfig.ideogram4_fp8(),
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def load(spec: ModelSpec) -> SimpleNamespace:
|
|
35
|
+
from .._settings import settings_manager
|
|
36
|
+
|
|
37
|
+
quantize = settings_manager.get_settings().default_quantize
|
|
38
|
+
model = build_model(spec, quantize=quantize)
|
|
39
|
+
return SimpleNamespace(model=model, spec=spec, quantize=quantize)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _store_image(
|
|
43
|
+
image: Any,
|
|
44
|
+
*,
|
|
45
|
+
fmt: str,
|
|
46
|
+
quality: int,
|
|
47
|
+
files: FileStore,
|
|
48
|
+
meta: dict[str, Any],
|
|
49
|
+
) -> dict[str, Any]:
|
|
50
|
+
pil = getattr(image, "image", image)
|
|
51
|
+
ext = "jpg" if fmt == "jpeg" else fmt
|
|
52
|
+
tmp_dir = create_work_dir("image/ideogram4")
|
|
53
|
+
out_path = tmp_dir / f"image.{ext}"
|
|
54
|
+
save_kwargs: dict[str, Any] = {}
|
|
55
|
+
if fmt in ("jpeg", "webp"):
|
|
56
|
+
save_kwargs["quality"] = quality
|
|
57
|
+
if fmt == "jpeg":
|
|
58
|
+
pil = pil.convert("RGB")
|
|
59
|
+
pil.save(out_path, format=fmt.upper(), **save_kwargs)
|
|
60
|
+
if not out_path.exists():
|
|
61
|
+
raise RuntimeError("generation finished but no image file was produced")
|
|
62
|
+
rec = files.put_path(
|
|
63
|
+
out_path,
|
|
64
|
+
filename=f"ideogram4_{int(time.time())}.{ext}",
|
|
65
|
+
content_type=f"image/{fmt}",
|
|
66
|
+
meta=meta,
|
|
67
|
+
move=True,
|
|
68
|
+
)
|
|
69
|
+
return {"file_id": rec.file_id, "image_bytes": rec.size, **meta}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _generate(model: Any, params: GenerateParams, files: FileStore) -> dict[str, Any]:
|
|
73
|
+
t0 = time.time()
|
|
74
|
+
attach_mflux_progress(model)
|
|
75
|
+
image = model.generate_image(
|
|
76
|
+
seed=params.seed,
|
|
77
|
+
prompt=params.prompt,
|
|
78
|
+
width=params.width,
|
|
79
|
+
height=params.height,
|
|
80
|
+
preset=params.preset,
|
|
81
|
+
strict_caption_validation=params.strict_caption_validation,
|
|
82
|
+
warn_on_caption_issues=params.warn_on_caption_issues,
|
|
83
|
+
)
|
|
84
|
+
total_s = round(time.time() - t0, 2)
|
|
85
|
+
meta = {
|
|
86
|
+
"model": params.model,
|
|
87
|
+
"prompt": params.prompt,
|
|
88
|
+
"params": params.model_dump(),
|
|
89
|
+
"width": params.width,
|
|
90
|
+
"height": params.height,
|
|
91
|
+
"safety_filter_note": _SAFETY_FILTER_NOTE,
|
|
92
|
+
"timings": {"total_s": total_s},
|
|
93
|
+
}
|
|
94
|
+
return _store_image(
|
|
95
|
+
image, fmt=params.format, quality=params.quality, files=files, meta=meta
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def run_generate(
|
|
100
|
+
payload: SimpleNamespace, params: GenerateParams, files: FileStore
|
|
101
|
+
) -> dict[str, Any]:
|
|
102
|
+
return _generate(payload.model, params, files)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def run_generate_transient(
|
|
106
|
+
spec: ModelSpec, params: GenerateParams, files: FileStore
|
|
107
|
+
) -> dict[str, Any]:
|
|
108
|
+
model = build_model(spec, quantize=params.quantize)
|
|
109
|
+
try:
|
|
110
|
+
return _generate(model, params, files)
|
|
111
|
+
finally:
|
|
112
|
+
_free(model)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _free(model: Any) -> None:
|
|
116
|
+
del model
|
|
117
|
+
gc.collect()
|
|
118
|
+
import mlx.core as mx
|
|
119
|
+
|
|
120
|
+
mx.clear_cache()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Ideogram 4 text-to-image service entry (worker-thread thunk body)."""
|
|
2
|
+
|
|
3
|
+
from kiapi.core.app import AppContext
|
|
4
|
+
from kiapi.core.file import FileID
|
|
5
|
+
from kiapi.core.job import JobResult
|
|
6
|
+
from kiapi.core.model import model_registry
|
|
7
|
+
|
|
8
|
+
from .._settings import settings_manager
|
|
9
|
+
from .._views.generate_request import GenerateRequest
|
|
10
|
+
from .is_quantize_override import is_quantize_override
|
|
11
|
+
from .resolve_generate_params import resolve_generate_params
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def handle_generate(
|
|
15
|
+
ctx: AppContext, req: GenerateRequest
|
|
16
|
+
) -> tuple[JobResult, list[FileID]]:
|
|
17
|
+
settings = settings_manager.get_settings()
|
|
18
|
+
spec = model_registry.resolve("ideogram4", req.model)
|
|
19
|
+
ctx.ensure_model_ready(spec)
|
|
20
|
+
override = is_quantize_override(settings, req)
|
|
21
|
+
params = resolve_generate_params(settings, req, variant=spec.name)
|
|
22
|
+
|
|
23
|
+
if override:
|
|
24
|
+
ctx.memory_manager.reserve(spec.weight_gb + spec.peak_headroom_gb)
|
|
25
|
+
result = spec.module.run_generate_transient(spec, params, ctx.file_store)
|
|
26
|
+
else:
|
|
27
|
+
payload = ctx.memory_manager.acquire(spec)
|
|
28
|
+
result = spec.module.run_generate(payload, params, ctx.file_store)
|
|
29
|
+
|
|
30
|
+
return result, [result["file_id"]]
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Decide whether a request's quantize differs from the variant default.
|
|
2
|
+
|
|
3
|
+
A True result means the resident model (quantized at its default) can't serve the
|
|
4
|
+
request, so ``handle_generate`` runs a one-off transient model instead.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .._settings import Ideogram4Settings
|
|
8
|
+
from .._views.generate_request import GenerateRequest
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def is_quantize_override(settings: Ideogram4Settings, req: GenerateRequest) -> bool:
|
|
12
|
+
return req.quantize is not None and req.quantize != settings.default_quantize
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Merge a generate request with settings defaults into the complete GenerateParams."""
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
|
|
5
|
+
from .._settings import Ideogram4Settings
|
|
6
|
+
from .._views.generate_params import GenerateParams
|
|
7
|
+
from .._views.generate_request import GenerateRequest
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def resolve_generate_params(
|
|
11
|
+
settings: Ideogram4Settings,
|
|
12
|
+
req: GenerateRequest,
|
|
13
|
+
*,
|
|
14
|
+
variant: str,
|
|
15
|
+
) -> GenerateParams:
|
|
16
|
+
return GenerateParams(
|
|
17
|
+
model=variant,
|
|
18
|
+
prompt=req.prompt,
|
|
19
|
+
preset=req.preset,
|
|
20
|
+
seed=req.seed if req.seed is not None else random.randint(0, 2**31 - 1),
|
|
21
|
+
width=req.width if req.width is not None else settings.default_width,
|
|
22
|
+
height=req.height if req.height is not None else settings.default_height,
|
|
23
|
+
quantize=req.quantize
|
|
24
|
+
if req.quantize is not None
|
|
25
|
+
else settings.default_quantize,
|
|
26
|
+
strict_caption_validation=req.strict_caption_validation,
|
|
27
|
+
warn_on_caption_issues=req.warn_on_caption_issues,
|
|
28
|
+
format=req.format,
|
|
29
|
+
quality=req.quality,
|
|
30
|
+
)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Ideogram 4 capability defaults + caps, read from ``KIAPI_IDEOGRAM4_`` env vars."""
|
|
2
|
+
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
5
|
+
from pydantic_settings_manager import SettingsManager
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Ideogram4Settings(BaseSettings):
|
|
9
|
+
"""Settings for the Ideogram 4 model, image sizes, presets, and quantization."""
|
|
10
|
+
|
|
11
|
+
model_config = SettingsConfigDict(
|
|
12
|
+
env_prefix="KIAPI_IDEOGRAM4_",
|
|
13
|
+
extra="ignore",
|
|
14
|
+
protected_namespaces=(),
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
model_repo: str = Field(
|
|
18
|
+
default="ideogram-ai/ideogram-4-fp8",
|
|
19
|
+
title="Ideogram 4 model repo",
|
|
20
|
+
description="Hugging Face repo ID for the Ideogram 4 model used for image generation.",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# --------------------------------------------------
|
|
24
|
+
# generate
|
|
25
|
+
# --------------------------------------------------
|
|
26
|
+
|
|
27
|
+
default_width: int = Field(
|
|
28
|
+
default=1024,
|
|
29
|
+
title="Default width",
|
|
30
|
+
description="Output image width in pixels used when a request omits width.",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
default_height: int = Field(
|
|
34
|
+
default=1024,
|
|
35
|
+
title="Default height",
|
|
36
|
+
description="Output image height in pixels used when a request omits height.",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
min_width: int = Field(
|
|
40
|
+
default=256,
|
|
41
|
+
title="Minimum width",
|
|
42
|
+
description="Lower pixel limit for the output image width accepted in a request.",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
min_height: int = Field(
|
|
46
|
+
default=256,
|
|
47
|
+
title="Minimum height",
|
|
48
|
+
description="Lower pixel limit for the output image height accepted in a request.",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
max_width: int = Field(
|
|
52
|
+
default=2048,
|
|
53
|
+
title="Maximum width",
|
|
54
|
+
description="Upper pixel limit for the output image width accepted in a request.",
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
max_height: int = Field(
|
|
58
|
+
default=2048,
|
|
59
|
+
title="Maximum height",
|
|
60
|
+
description="Upper pixel limit for the output image height accepted in a request.",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
default_preset: str = Field(
|
|
64
|
+
default="V4_DEFAULT_20",
|
|
65
|
+
title="Default preset",
|
|
66
|
+
description=(
|
|
67
|
+
"Ideogram 4 preset name used when a request omits preset.\n"
|
|
68
|
+
"The value must be included in presets."
|
|
69
|
+
),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
presets: tuple[str, ...] = Field(
|
|
73
|
+
default=("V4_DEFAULT_20", "V4_QUALITY_48", "V4_TURBO_12"),
|
|
74
|
+
title="Available presets",
|
|
75
|
+
description="List of Ideogram 4 preset names accepted by the API.",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
default_quantize: int | None = Field(
|
|
79
|
+
default=None,
|
|
80
|
+
title="Default quantization bits",
|
|
81
|
+
description=(
|
|
82
|
+
"Default quantization bit count used when loading the Ideogram 4 model.\n"
|
|
83
|
+
"When None, the model repo's default precision is used. A numeric "
|
|
84
|
+
"value quantizes to that bit count."
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
settings_manager = SettingsManager(Ideogram4Settings)
|