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.
Files changed (465) hide show
  1. kiapi/__init__.py +3 -0
  2. kiapi/__main__.py +4 -0
  3. kiapi/api/__init__.py +26 -0
  4. kiapi/api/_constants/require_auth.py +14 -0
  5. kiapi/api/_helpers/build_job_responses.py +73 -0
  6. kiapi/api/_helpers/build_openapi.py +55 -0
  7. kiapi/api/_helpers/build_train_responses.py +21 -0
  8. kiapi/api/_helpers/get_accept.py +20 -0
  9. kiapi/api/_helpers/get_ctx.py +7 -0
  10. kiapi/api/_helpers/get_worker.py +7 -0
  11. kiapi/api/_helpers/register_capability_endpoints.py +70 -0
  12. kiapi/api/_helpers/submit_and_maybe_wait.py +113 -0
  13. kiapi/api/_settings.py +50 -0
  14. kiapi/api/_views/async_job_response.py +21 -0
  15. kiapi/api/_views/capability_model_spec.py +49 -0
  16. kiapi/api/app.py +150 -0
  17. kiapi/api/audio/acestep/_views/extract_response.py +57 -0
  18. kiapi/api/audio/acestep/_views/track_response.py +57 -0
  19. kiapi/api/audio/acestep/router.py +190 -0
  20. kiapi/api/audio/audiogen/_views/audio_response.py +46 -0
  21. kiapi/api/audio/audiogen/router.py +77 -0
  22. kiapi/api/chat/_views/chat_completion_response.py +71 -0
  23. kiapi/api/chat/router.py +253 -0
  24. kiapi/api/embedding/_views/embedding_response.py +35 -0
  25. kiapi/api/embedding/router.py +82 -0
  26. kiapi/api/files/_operations/get_file.py +14 -0
  27. kiapi/api/files/_operations/get_file_id.py +18 -0
  28. kiapi/api/files/_views/file_delete_response.py +14 -0
  29. kiapi/api/files/_views/file_list_response.py +15 -0
  30. kiapi/api/files/router.py +105 -0
  31. kiapi/api/health/_views/health_response.py +26 -0
  32. kiapi/api/health/router.py +28 -0
  33. kiapi/api/image/depthpro/_views/estimate_response.py +70 -0
  34. kiapi/api/image/depthpro/router.py +81 -0
  35. kiapi/api/image/ernie/_views/image_response.py +50 -0
  36. kiapi/api/image/ernie/router.py +181 -0
  37. kiapi/api/image/flux2/_views/image_response.py +53 -0
  38. kiapi/api/image/flux2/router.py +197 -0
  39. kiapi/api/image/ideogram4/_views/image_response.py +55 -0
  40. kiapi/api/image/ideogram4/router.py +87 -0
  41. kiapi/api/image/qwen/_views/image_response.py +47 -0
  42. kiapi/api/image/qwen/router.py +141 -0
  43. kiapi/api/image/seedvr2/_views/image_response.py +50 -0
  44. kiapi/api/image/seedvr2/router.py +83 -0
  45. kiapi/api/image/zimage/_views/image_response.py +49 -0
  46. kiapi/api/image/zimage/router.py +131 -0
  47. kiapi/api/jobs/_operations/get_job_id.py +18 -0
  48. kiapi/api/jobs/_views/job_delete_response.py +19 -0
  49. kiapi/api/jobs/_views/job_list_response.py +15 -0
  50. kiapi/api/jobs/router.py +62 -0
  51. kiapi/api/models/_schemas/openai_model_spec.py +26 -0
  52. kiapi/api/models/_views/model_list_response.py +15 -0
  53. kiapi/api/models/router.py +29 -0
  54. kiapi/api/video/ltx2/_views/__init__.py +1 -0
  55. kiapi/api/video/ltx2/_views/video_response.py +59 -0
  56. kiapi/api/video/ltx2/router.py +89 -0
  57. kiapi/api/web/_views/__init__.py +7 -0
  58. kiapi/api/web/_views/fetch_api_request.py +26 -0
  59. kiapi/api/web/_views/fetch_error_response.py +25 -0
  60. kiapi/api/web/router.py +302 -0
  61. kiapi/capabilities/__init__.py +24 -0
  62. kiapi/capabilities/_exceptions/CapabilityError.py +2 -0
  63. kiapi/capabilities/_exceptions/ValidationError.py +2 -0
  64. kiapi/capabilities/_helpers/attach_mflux_progress.py +50 -0
  65. kiapi/capabilities/_helpers/get_file_path.py +20 -0
  66. kiapi/capabilities/_helpers/resolve_file_ref.py +16 -0
  67. kiapi/capabilities/acestep/README.ja.md +174 -0
  68. kiapi/capabilities/acestep/README.md +167 -0
  69. kiapi/capabilities/acestep/__init__.py +37 -0
  70. kiapi/capabilities/acestep/_constants/description.py +122 -0
  71. kiapi/capabilities/acestep/_exceptions/ace_step_engine_error.py +2 -0
  72. kiapi/capabilities/acestep/_helpers/register.py +96 -0
  73. kiapi/capabilities/acestep/_models/acestep.py +105 -0
  74. kiapi/capabilities/acestep/_operations/handle_cover.py +23 -0
  75. kiapi/capabilities/acestep/_operations/handle_extract.py +38 -0
  76. kiapi/capabilities/acestep/_operations/handle_generate.py +18 -0
  77. kiapi/capabilities/acestep/_operations/handle_repaint.py +25 -0
  78. kiapi/capabilities/acestep/_operations/resolve_ace_step_paths.py +30 -0
  79. kiapi/capabilities/acestep/_operations/resolve_cover_params.py +21 -0
  80. kiapi/capabilities/acestep/_operations/resolve_engine.py +10 -0
  81. kiapi/capabilities/acestep/_operations/resolve_extract_params.py +24 -0
  82. kiapi/capabilities/acestep/_operations/resolve_generate_params.py +18 -0
  83. kiapi/capabilities/acestep/_operations/resolve_repaint_params.py +22 -0
  84. kiapi/capabilities/acestep/_schemas/ace_step_paths.py +29 -0
  85. kiapi/capabilities/acestep/_services/ace_step_engine.py +143 -0
  86. kiapi/capabilities/acestep/_settings.py +82 -0
  87. kiapi/capabilities/acestep/_views/ace_step_base.py +61 -0
  88. kiapi/capabilities/acestep/_views/cover_params.py +26 -0
  89. kiapi/capabilities/acestep/_views/cover_request.py +49 -0
  90. kiapi/capabilities/acestep/_views/extract_params.py +24 -0
  91. kiapi/capabilities/acestep/_views/extract_request.py +33 -0
  92. kiapi/capabilities/acestep/_views/generate_params.py +25 -0
  93. kiapi/capabilities/acestep/_views/generate_request.py +54 -0
  94. kiapi/capabilities/acestep/_views/repaint_params.py +27 -0
  95. kiapi/capabilities/acestep/_views/repaint_request.py +51 -0
  96. kiapi/capabilities/acestep/_views/track_params.py +7 -0
  97. kiapi/capabilities/acestep/worker_subprocess.py +247 -0
  98. kiapi/capabilities/audiogen/README.ja.md +49 -0
  99. kiapi/capabilities/audiogen/README.md +48 -0
  100. kiapi/capabilities/audiogen/__init__.py +25 -0
  101. kiapi/capabilities/audiogen/_constants/description.py +60 -0
  102. kiapi/capabilities/audiogen/_helpers/attach_audiogen_progress.py +27 -0
  103. kiapi/capabilities/audiogen/_helpers/register.py +42 -0
  104. kiapi/capabilities/audiogen/_helpers/validate_generate.py +14 -0
  105. kiapi/capabilities/audiogen/_models/audiogen.py +98 -0
  106. kiapi/capabilities/audiogen/_operations/handle_generate.py +27 -0
  107. kiapi/capabilities/audiogen/_operations/resolve_generate_params.py +25 -0
  108. kiapi/capabilities/audiogen/_settings.py +34 -0
  109. kiapi/capabilities/audiogen/_views/generate_params.py +14 -0
  110. kiapi/capabilities/audiogen/_views/generate_request.py +96 -0
  111. kiapi/capabilities/chat/README.ja.md +822 -0
  112. kiapi/capabilities/chat/README.md +806 -0
  113. kiapi/capabilities/chat/__init__.py +25 -0
  114. kiapi/capabilities/chat/_constants/description.py +163 -0
  115. kiapi/capabilities/chat/_helpers/register.py +67 -0
  116. kiapi/capabilities/chat/_models/qwen3_5.py +183 -0
  117. kiapi/capabilities/chat/_models/qwen3_omni.py +242 -0
  118. kiapi/capabilities/chat/_operations/apply_template.py +74 -0
  119. kiapi/capabilities/chat/_operations/completed_hermes_tool_call_text.py +9 -0
  120. kiapi/capabilities/chat/_operations/emit_streaming_response.py +297 -0
  121. kiapi/capabilities/chat/_operations/ensure_streaming_detokenizer_compat.py +49 -0
  122. kiapi/capabilities/chat/_operations/format_response.py +72 -0
  123. kiapi/capabilities/chat/_operations/handle_chat.py +25 -0
  124. kiapi/capabilities/chat/_operations/parse_hermes_tool_calls.py +63 -0
  125. kiapi/capabilities/chat/_operations/parse_json_tool_calls.py +66 -0
  126. kiapi/capabilities/chat/_operations/parse_messages.py +326 -0
  127. kiapi/capabilities/chat/_operations/resolve_chat_params.py +50 -0
  128. kiapi/capabilities/chat/_operations/stream_text_from_tokens.py +32 -0
  129. kiapi/capabilities/chat/_operations/strip_tool_calls.py +15 -0
  130. kiapi/capabilities/chat/_settings.py +74 -0
  131. kiapi/capabilities/chat/_utils/apply_parallel_tool_call_policy.py +17 -0
  132. kiapi/capabilities/chat/_utils/apply_seed.py +8 -0
  133. kiapi/capabilities/chat/_utils/load_audio_mono.py +31 -0
  134. kiapi/capabilities/chat/_utils/load_mlx_vlm.py +12 -0
  135. kiapi/capabilities/chat/_utils/warmup_params.py +26 -0
  136. kiapi/capabilities/chat/_views/chat_params.py +34 -0
  137. kiapi/capabilities/chat/_views/chat_request.py +153 -0
  138. kiapi/capabilities/depthpro/README.ja.md +131 -0
  139. kiapi/capabilities/depthpro/README.md +124 -0
  140. kiapi/capabilities/depthpro/__init__.py +23 -0
  141. kiapi/capabilities/depthpro/_constants/description.py +39 -0
  142. kiapi/capabilities/depthpro/_helpers/register.py +46 -0
  143. kiapi/capabilities/depthpro/_helpers/validate_estimate.py +32 -0
  144. kiapi/capabilities/depthpro/_models/depthpro.py +144 -0
  145. kiapi/capabilities/depthpro/_operations/handle_estimate.py +50 -0
  146. kiapi/capabilities/depthpro/_operations/is_quantize_override.py +12 -0
  147. kiapi/capabilities/depthpro/_operations/resolve_estimate_params.py +24 -0
  148. kiapi/capabilities/depthpro/_settings.py +46 -0
  149. kiapi/capabilities/depthpro/_views/estimate_params.py +21 -0
  150. kiapi/capabilities/depthpro/_views/estimate_request.py +63 -0
  151. kiapi/capabilities/embedding/README.ja.md +137 -0
  152. kiapi/capabilities/embedding/README.md +128 -0
  153. kiapi/capabilities/embedding/__init__.py +24 -0
  154. kiapi/capabilities/embedding/_constants/description.py +47 -0
  155. kiapi/capabilities/embedding/_helpers/register.py +66 -0
  156. kiapi/capabilities/embedding/_models/qwen3_text.py +53 -0
  157. kiapi/capabilities/embedding/_models/qwen3_vl.py +97 -0
  158. kiapi/capabilities/embedding/_operations/format_response.py +24 -0
  159. kiapi/capabilities/embedding/_operations/handle_embed.py +24 -0
  160. kiapi/capabilities/embedding/_operations/parse_inputs.py +108 -0
  161. kiapi/capabilities/embedding/_operations/resolve_embed_params.py +18 -0
  162. kiapi/capabilities/embedding/_settings.py +27 -0
  163. kiapi/capabilities/embedding/_utils/to_vector.py +20 -0
  164. kiapi/capabilities/embedding/_views/embed_params.py +17 -0
  165. kiapi/capabilities/embedding/_views/embed_request.py +39 -0
  166. kiapi/capabilities/ernie/README.ja.md +242 -0
  167. kiapi/capabilities/ernie/README.md +223 -0
  168. kiapi/capabilities/ernie/__init__.py +34 -0
  169. kiapi/capabilities/ernie/_constants/description.py +71 -0
  170. kiapi/capabilities/ernie/_helpers/register.py +60 -0
  171. kiapi/capabilities/ernie/_helpers/validate_edit.py +19 -0
  172. kiapi/capabilities/ernie/_helpers/validate_generate.py +8 -0
  173. kiapi/capabilities/ernie/_models/ernie.py +356 -0
  174. kiapi/capabilities/ernie/_operations/handle_edit.py +39 -0
  175. kiapi/capabilities/ernie/_operations/handle_generate.py +38 -0
  176. kiapi/capabilities/ernie/_operations/handle_train.py +77 -0
  177. kiapi/capabilities/ernie/_operations/is_quantize_override.py +16 -0
  178. kiapi/capabilities/ernie/_operations/resolve_edit_params.py +44 -0
  179. kiapi/capabilities/ernie/_operations/resolve_generate_params.py +40 -0
  180. kiapi/capabilities/ernie/_operations/resolve_lora_params.py +23 -0
  181. kiapi/capabilities/ernie/_operations/resolve_train_params.py +43 -0
  182. kiapi/capabilities/ernie/_operations/validate_common.py +33 -0
  183. kiapi/capabilities/ernie/_schemas/lora_ref.py +27 -0
  184. kiapi/capabilities/ernie/_settings.py +151 -0
  185. kiapi/capabilities/ernie/_views/edit_params.py +36 -0
  186. kiapi/capabilities/ernie/_views/edit_request.py +142 -0
  187. kiapi/capabilities/ernie/_views/generate_params.py +32 -0
  188. kiapi/capabilities/ernie/_views/generate_request.py +127 -0
  189. kiapi/capabilities/ernie/_views/train_params.py +28 -0
  190. kiapi/capabilities/ernie/_views/train_request.py +96 -0
  191. kiapi/capabilities/flux2/README.ja.md +260 -0
  192. kiapi/capabilities/flux2/README.md +241 -0
  193. kiapi/capabilities/flux2/__init__.py +36 -0
  194. kiapi/capabilities/flux2/_constants/description.py +81 -0
  195. kiapi/capabilities/flux2/_helpers/register.py +98 -0
  196. kiapi/capabilities/flux2/_helpers/validate_edit.py +12 -0
  197. kiapi/capabilities/flux2/_helpers/validate_generate.py +8 -0
  198. kiapi/capabilities/flux2/_models/flux2.py +396 -0
  199. kiapi/capabilities/flux2/_operations/handle_edit.py +44 -0
  200. kiapi/capabilities/flux2/_operations/handle_generate.py +46 -0
  201. kiapi/capabilities/flux2/_operations/handle_train.py +105 -0
  202. kiapi/capabilities/flux2/_operations/is_quantize_override.py +16 -0
  203. kiapi/capabilities/flux2/_operations/resolve_edit_params.py +43 -0
  204. kiapi/capabilities/flux2/_operations/resolve_generate_params.py +44 -0
  205. kiapi/capabilities/flux2/_operations/resolve_lora_params.py +23 -0
  206. kiapi/capabilities/flux2/_operations/resolve_train_params.py +42 -0
  207. kiapi/capabilities/flux2/_operations/role_spec.py +13 -0
  208. kiapi/capabilities/flux2/_operations/split_repo.py +11 -0
  209. kiapi/capabilities/flux2/_operations/validate_common.py +35 -0
  210. kiapi/capabilities/flux2/_schemas/lora_ref.py +27 -0
  211. kiapi/capabilities/flux2/_settings.py +181 -0
  212. kiapi/capabilities/flux2/_views/edit_params.py +36 -0
  213. kiapi/capabilities/flux2/_views/edit_request.py +145 -0
  214. kiapi/capabilities/flux2/_views/generate_params.py +36 -0
  215. kiapi/capabilities/flux2/_views/generate_request.py +150 -0
  216. kiapi/capabilities/flux2/_views/train_params.py +32 -0
  217. kiapi/capabilities/flux2/_views/train_request.py +102 -0
  218. kiapi/capabilities/ideogram4/README.ja.md +230 -0
  219. kiapi/capabilities/ideogram4/README.md +219 -0
  220. kiapi/capabilities/ideogram4/__init__.py +24 -0
  221. kiapi/capabilities/ideogram4/_constants/description.py +65 -0
  222. kiapi/capabilities/ideogram4/_helpers/register.py +44 -0
  223. kiapi/capabilities/ideogram4/_helpers/validate_generate.py +31 -0
  224. kiapi/capabilities/ideogram4/_models/ideogram4.py +120 -0
  225. kiapi/capabilities/ideogram4/_operations/handle_generate.py +30 -0
  226. kiapi/capabilities/ideogram4/_operations/is_quantize_override.py +12 -0
  227. kiapi/capabilities/ideogram4/_operations/resolve_generate_params.py +30 -0
  228. kiapi/capabilities/ideogram4/_settings.py +89 -0
  229. kiapi/capabilities/ideogram4/_views/generate_params.py +27 -0
  230. kiapi/capabilities/ideogram4/_views/generate_request.py +118 -0
  231. kiapi/capabilities/ltx2/README.ja.md +287 -0
  232. kiapi/capabilities/ltx2/README.md +274 -0
  233. kiapi/capabilities/ltx2/__init__.py +26 -0
  234. kiapi/capabilities/ltx2/_constants/description.py +81 -0
  235. kiapi/capabilities/ltx2/_helpers/register.py +58 -0
  236. kiapi/capabilities/ltx2/_helpers/validate_generate.py +42 -0
  237. kiapi/capabilities/ltx2/_models/ltx2.py +106 -0
  238. kiapi/capabilities/ltx2/_operations/detect_mode.py +19 -0
  239. kiapi/capabilities/ltx2/_operations/handle_generate.py +52 -0
  240. kiapi/capabilities/ltx2/_operations/resolve_generate_params.py +31 -0
  241. kiapi/capabilities/ltx2/_settings.py +93 -0
  242. kiapi/capabilities/ltx2/_views/generate_params.py +34 -0
  243. kiapi/capabilities/ltx2/_views/generate_request.py +151 -0
  244. kiapi/capabilities/qwen/README.ja.md +251 -0
  245. kiapi/capabilities/qwen/README.md +235 -0
  246. kiapi/capabilities/qwen/__init__.py +30 -0
  247. kiapi/capabilities/qwen/_constants/description.py +53 -0
  248. kiapi/capabilities/qwen/_helpers/register.py +60 -0
  249. kiapi/capabilities/qwen/_helpers/validate_edit.py +12 -0
  250. kiapi/capabilities/qwen/_helpers/validate_generate.py +12 -0
  251. kiapi/capabilities/qwen/_models/qwen.py +224 -0
  252. kiapi/capabilities/qwen/_operations/handle_edit.py +44 -0
  253. kiapi/capabilities/qwen/_operations/handle_generate.py +46 -0
  254. kiapi/capabilities/qwen/_operations/is_quantize_override.py +15 -0
  255. kiapi/capabilities/qwen/_operations/resolve_edit_params.py +35 -0
  256. kiapi/capabilities/qwen/_operations/resolve_generate_params.py +39 -0
  257. kiapi/capabilities/qwen/_operations/resolve_lora_params.py +23 -0
  258. kiapi/capabilities/qwen/_operations/validate_common.py +32 -0
  259. kiapi/capabilities/qwen/_schemas/lora_ref.py +27 -0
  260. kiapi/capabilities/qwen/_settings.py +107 -0
  261. kiapi/capabilities/qwen/_views/edit_params.py +36 -0
  262. kiapi/capabilities/qwen/_views/edit_request.py +138 -0
  263. kiapi/capabilities/qwen/_views/generate_params.py +37 -0
  264. kiapi/capabilities/qwen/_views/generate_request.py +149 -0
  265. kiapi/capabilities/seedvr2/README.ja.md +234 -0
  266. kiapi/capabilities/seedvr2/README.md +219 -0
  267. kiapi/capabilities/seedvr2/__init__.py +24 -0
  268. kiapi/capabilities/seedvr2/_constants/description.py +46 -0
  269. kiapi/capabilities/seedvr2/_helpers/register.py +60 -0
  270. kiapi/capabilities/seedvr2/_helpers/validate_upscale.py +52 -0
  271. kiapi/capabilities/seedvr2/_models/seedvr2.py +140 -0
  272. kiapi/capabilities/seedvr2/_operations/handle_upscale.py +42 -0
  273. kiapi/capabilities/seedvr2/_operations/is_quantize_override.py +12 -0
  274. kiapi/capabilities/seedvr2/_operations/resolve_upscale_params.py +30 -0
  275. kiapi/capabilities/seedvr2/_settings.py +74 -0
  276. kiapi/capabilities/seedvr2/_views/upscale_params.py +27 -0
  277. kiapi/capabilities/seedvr2/_views/upscale_request.py +94 -0
  278. kiapi/capabilities/web/README.ja.md +187 -0
  279. kiapi/capabilities/web/README.md +171 -0
  280. kiapi/capabilities/web/__init__.py +30 -0
  281. kiapi/capabilities/web/_constants/description.py +38 -0
  282. kiapi/capabilities/web/_exceptions/FetchError.py +24 -0
  283. kiapi/capabilities/web/_exceptions/SearchBackendError.py +11 -0
  284. kiapi/capabilities/web/_helpers/register.py +59 -0
  285. kiapi/capabilities/web/_models/crawl4ai.py +32 -0
  286. kiapi/capabilities/web/_models/searxng.py +44 -0
  287. kiapi/capabilities/web/_operations/handle_fetch.py +145 -0
  288. kiapi/capabilities/web/_operations/handle_search.py +56 -0
  289. kiapi/capabilities/web/_operations/resolve_fetch_params.py +19 -0
  290. kiapi/capabilities/web/_operations/resolve_search_params.py +34 -0
  291. kiapi/capabilities/web/_operations/resolve_searxng_config_dir.py +21 -0
  292. kiapi/capabilities/web/_services/__init__.py +1 -0
  293. kiapi/capabilities/web/_services/web_backend_process.py +144 -0
  294. kiapi/capabilities/web/_settings.py +138 -0
  295. kiapi/capabilities/web/_views/fetch_params.py +27 -0
  296. kiapi/capabilities/web/_views/fetch_request.py +29 -0
  297. kiapi/capabilities/web/_views/fetch_result.py +20 -0
  298. kiapi/capabilities/web/_views/search_params.py +43 -0
  299. kiapi/capabilities/web/_views/search_request.py +93 -0
  300. kiapi/capabilities/web/_views/search_response.py +49 -0
  301. kiapi/capabilities/web/resources/__init__.py +0 -0
  302. kiapi/capabilities/web/resources/searxng/__init__.py +0 -0
  303. kiapi/capabilities/web/resources/searxng/settings.yml +11 -0
  304. kiapi/capabilities/zimage/README.ja.md +249 -0
  305. kiapi/capabilities/zimage/README.md +231 -0
  306. kiapi/capabilities/zimage/__init__.py +34 -0
  307. kiapi/capabilities/zimage/_constants/description.py +73 -0
  308. kiapi/capabilities/zimage/_helpers/register.py +62 -0
  309. kiapi/capabilities/zimage/_helpers/validate_generate.py +37 -0
  310. kiapi/capabilities/zimage/_models/zimage.py +278 -0
  311. kiapi/capabilities/zimage/_operations/handle_generate.py +38 -0
  312. kiapi/capabilities/zimage/_operations/handle_train.py +78 -0
  313. kiapi/capabilities/zimage/_operations/is_quantize_override.py +11 -0
  314. kiapi/capabilities/zimage/_operations/resolve_generate_params.py +39 -0
  315. kiapi/capabilities/zimage/_operations/resolve_lora_params.py +23 -0
  316. kiapi/capabilities/zimage/_operations/resolve_train_params.py +38 -0
  317. kiapi/capabilities/zimage/_schemas/lora_ref.py +27 -0
  318. kiapi/capabilities/zimage/_settings.py +166 -0
  319. kiapi/capabilities/zimage/_views/generate_params.py +23 -0
  320. kiapi/capabilities/zimage/_views/generate_request.py +127 -0
  321. kiapi/capabilities/zimage/_views/train_params.py +22 -0
  322. kiapi/capabilities/zimage/_views/train_request.py +101 -0
  323. kiapi/cli/__init__.py +11 -0
  324. kiapi/cli/_helpers/dedupe_resources.py +12 -0
  325. kiapi/cli/_helpers/register_all_capabilities.py +36 -0
  326. kiapi/cli/_helpers/run_resources.py +24 -0
  327. kiapi/cli/_helpers/select_specs.py +67 -0
  328. kiapi/cli/activate/_operations/preflight_hf_access.py +129 -0
  329. kiapi/cli/activate/cli.py +37 -0
  330. kiapi/cli/check/_helpers/check_audio_acestep_turbo.py +22 -0
  331. kiapi/cli/check/_helpers/check_audio_acestep_xl_base.py +22 -0
  332. kiapi/cli/check/_helpers/check_audio_audiogen_medium.py +24 -0
  333. kiapi/cli/check/_helpers/check_chat_chat_qwen3_6_27b.py +19 -0
  334. kiapi/cli/check/_helpers/check_chat_chat_qwen3_omni.py +19 -0
  335. kiapi/cli/check/_helpers/check_embedding_embedding_qwen3_embedding_8b.py +14 -0
  336. kiapi/cli/check/_helpers/check_embedding_embedding_qwen3_vl_embedding_2b.py +19 -0
  337. kiapi/cli/check/_helpers/check_image_depthpro_base.py +21 -0
  338. kiapi/cli/check/_helpers/check_image_ernie_base.py +23 -0
  339. kiapi/cli/check/_helpers/check_image_ernie_turbo.py +23 -0
  340. kiapi/cli/check/_helpers/check_image_flux2_klein_9b.py +23 -0
  341. kiapi/cli/check/_helpers/check_image_flux2_klein_base_4b.py +23 -0
  342. kiapi/cli/check/_helpers/check_image_flux2_klein_base_9b.py +23 -0
  343. kiapi/cli/check/_helpers/check_image_ideogram4_fp8.py +23 -0
  344. kiapi/cli/check/_helpers/check_image_qwen_edit_2509.py +27 -0
  345. kiapi/cli/check/_helpers/check_image_qwen_image.py +23 -0
  346. kiapi/cli/check/_helpers/check_image_seedvr2_3b.py +23 -0
  347. kiapi/cli/check/_helpers/check_image_seedvr2_7b.py +23 -0
  348. kiapi/cli/check/_helpers/check_image_zimage_base.py +23 -0
  349. kiapi/cli/check/_helpers/check_image_zimage_turbo.py +23 -0
  350. kiapi/cli/check/_helpers/check_video_ltx2_distilled.py +26 -0
  351. kiapi/cli/check/_helpers/check_web_web_fetch.py +14 -0
  352. kiapi/cli/check/_helpers/check_web_web_search.py +14 -0
  353. kiapi/cli/check/_operations/build_check_result.py +20 -0
  354. kiapi/cli/check/_operations/check_context.py +10 -0
  355. kiapi/cli/check/_operations/create_sample_image.py +46 -0
  356. kiapi/cli/check/_schemas/check_result.py +12 -0
  357. kiapi/cli/check/cli.py +89 -0
  358. kiapi/cli/cli.py +29 -0
  359. kiapi/cli/config/cli.py +17 -0
  360. kiapi/cli/config/edit/cli.py +32 -0
  361. kiapi/cli/config/init/cli.py +33 -0
  362. kiapi/cli/config/show/cli.py +13 -0
  363. kiapi/cli/config/template/cli.py +36 -0
  364. kiapi/cli/deactivate/cli.py +49 -0
  365. kiapi/cli/run/asgi.py +16 -0
  366. kiapi/cli/run/cli.py +59 -0
  367. kiapi/cli/service/__init__.py +5 -0
  368. kiapi/cli/service/_services/service_manager.py +107 -0
  369. kiapi/cli/service/cli.py +19 -0
  370. kiapi/cli/service/install/cli.py +17 -0
  371. kiapi/cli/service/start/cli.py +22 -0
  372. kiapi/cli/service/status/cli.py +81 -0
  373. kiapi/cli/service/stop/cli.py +19 -0
  374. kiapi/cli/service/uninstall/cli.py +16 -0
  375. kiapi/cli/status/cli.py +226 -0
  376. kiapi/core/app/__init__.py +16 -0
  377. kiapi/core/app/_schemas/app_context.py +28 -0
  378. kiapi/core/app/_services/user_directory.py +59 -0
  379. kiapi/core/app/_settings.py +46 -0
  380. kiapi/core/capability/__init__.py +11 -0
  381. kiapi/core/capability/_schemas/capability_spec.py +17 -0
  382. kiapi/core/capability/_services/capability_spec_registry.py +21 -0
  383. kiapi/core/config/__init__.py +11 -0
  384. kiapi/core/config/_exceptions/user_config_error.py +2 -0
  385. kiapi/core/config/_helpers/get_user_settings_path.py +7 -0
  386. kiapi/core/config/_helpers/load_user_settings.py +54 -0
  387. kiapi/core/file/__init__.py +37 -0
  388. kiapi/core/file/_helpers/create_file_store.py +7 -0
  389. kiapi/core/file/_helpers/resolve_file_ref.py +90 -0
  390. kiapi/core/file/_schemas/file_data_url_ref.py +19 -0
  391. kiapi/core/file/_schemas/file_id_ref.py +16 -0
  392. kiapi/core/file/_schemas/file_record.py +46 -0
  393. kiapi/core/file/_schemas/file_url_ref.py +16 -0
  394. kiapi/core/file/_services/file_store.py +138 -0
  395. kiapi/core/file/_settings.py +22 -0
  396. kiapi/core/file/_types/file_id.py +2 -0
  397. kiapi/core/file/_types/file_ref.py +12 -0
  398. kiapi/core/file/_views/resolved_file_ref.py +16 -0
  399. kiapi/core/job/__init__.py +24 -0
  400. kiapi/core/job/_enums/job_status.py +9 -0
  401. kiapi/core/job/_helpers/creep_progress.py +123 -0
  402. kiapi/core/job/_models/job.py +121 -0
  403. kiapi/core/job/_services/job_store.py +33 -0
  404. kiapi/core/job/_services/progress_reporter.py +79 -0
  405. kiapi/core/job/_types/job_id.py +3 -0
  406. kiapi/core/job/_types/job_result.py +5 -0
  407. kiapi/core/job/_types/job_type.py +4 -0
  408. kiapi/core/logging/__init__.py +14 -0
  409. kiapi/core/logging/_helpers/get_log_level.py +8 -0
  410. kiapi/core/logging/_helpers/setup_logger.py +14 -0
  411. kiapi/core/logging/_settings.py +34 -0
  412. kiapi/core/logging/_types/log_level.py +3 -0
  413. kiapi/core/memory/__init__.py +21 -0
  414. kiapi/core/memory/_exceptions/memory_budget_error.py +2 -0
  415. kiapi/core/memory/_helpers/create_memory_manager.py +17 -0
  416. kiapi/core/memory/_operations/log_memory_limit.py +29 -0
  417. kiapi/core/memory/_operations/resolve_effective_memory_limit_gb.py +13 -0
  418. kiapi/core/memory/_operations/resolve_framework_strategy.py +42 -0
  419. kiapi/core/memory/_schemas/framework_strategy.py +14 -0
  420. kiapi/core/memory/_schemas/memory_stats.py +24 -0
  421. kiapi/core/memory/_schemas/resident_model.py +14 -0
  422. kiapi/core/memory/_schemas/resident_model_stats.py +49 -0
  423. kiapi/core/memory/_services/memory_manager.py +257 -0
  424. kiapi/core/memory/_settings.py +36 -0
  425. kiapi/core/memory/_types/framework_name.py +4 -0
  426. kiapi/core/memory/_types/resident_key.py +4 -0
  427. kiapi/core/model/__init__.py +36 -0
  428. kiapi/core/model/_exceptions/unknown_model_error.py +2 -0
  429. kiapi/core/model/_schemas/model_spec.py +145 -0
  430. kiapi/core/model/_services/model_registry.py +85 -0
  431. kiapi/core/model/_types/model_alias.py +2 -0
  432. kiapi/core/model/_types/model_domain.py +6 -0
  433. kiapi/core/model/_types/model_family.py +5 -0
  434. kiapi/core/model/_types/model_key.py +8 -0
  435. kiapi/core/model/_types/model_name.py +4 -0
  436. kiapi/core/model/_types/model_repo.py +3 -0
  437. kiapi/core/net/__init__.py +16 -0
  438. kiapi/core/net/_exceptions/unsafe_url_error.py +7 -0
  439. kiapi/core/net/_helpers/verify_public_url.py +68 -0
  440. kiapi/core/net/_settings.py +28 -0
  441. kiapi/core/setup/__init__.py +25 -0
  442. kiapi/core/setup/_exceptions/setup_required_error.py +2 -0
  443. kiapi/core/setup/_schemas/docker_image_resource.py +37 -0
  444. kiapi/core/setup/_schemas/hf_snapshot_resource.py +50 -0
  445. kiapi/core/setup/_schemas/local_path_resource.py +43 -0
  446. kiapi/core/setup/_schemas/python_package_resource.py +58 -0
  447. kiapi/core/setup/_schemas/python_venv_resource.py +63 -0
  448. kiapi/core/setup/_schemas/setup_status.py +7 -0
  449. kiapi/core/setup/_schemas/url_file_resource.py +43 -0
  450. kiapi/core/setup/_services/setup_manager.py +331 -0
  451. kiapi/core/setup/_types/setup_resource.py +21 -0
  452. kiapi/core/setup/_types/setup_target.py +11 -0
  453. kiapi/core/workdir/__init__.py +8 -0
  454. kiapi/core/workdir/_helpers/create_work_dir.py +11 -0
  455. kiapi/core/workdir/_settings.py +21 -0
  456. kiapi/core/worker/__init__.py +23 -0
  457. kiapi/core/worker/_helpers/create_worker.py +9 -0
  458. kiapi/core/worker/_services/worker.py +165 -0
  459. kiapi/core/worker/_settings.py +36 -0
  460. kiapi/core/worker/_types/job_thunk.py +6 -0
  461. kiapi-0.1.0.dist-info/METADATA +337 -0
  462. kiapi-0.1.0.dist-info/RECORD +465 -0
  463. kiapi-0.1.0.dist-info/WHEEL +4 -0
  464. kiapi-0.1.0.dist-info/entry_points.txt +2 -0
  465. kiapi-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,153 @@
1
+ """OpenAI-compatible chat request model.
2
+
3
+ ``messages`` / ``tools`` are kept as loose dicts on purpose: OpenAI's multimodal
4
+ ``content`` parts vary by client and we parse them leniently in
5
+ ``_operations/parse_messages``. Unknown top-level fields are tolerated
6
+ (``extra="allow"``). ``model`` selects which registered chat model answers
7
+ (see core/model).
8
+ """
9
+
10
+ from typing import Any
11
+
12
+ from pydantic import BaseModel, ConfigDict, Field, model_validator
13
+
14
+
15
+ class ChatRequest(BaseModel):
16
+ model_config = ConfigDict(
17
+ extra="allow",
18
+ json_schema_extra={
19
+ "examples": [
20
+ {
21
+ "model": "qwen3-omni",
22
+ "messages": [
23
+ {"role": "system", "content": "You are a helpful assistant."},
24
+ {
25
+ "role": "user",
26
+ "content": [
27
+ {"type": "text", "text": "What is in this image?"},
28
+ {
29
+ "type": "image_url",
30
+ "image_url": {"url": "https://example.com/cat.png"},
31
+ },
32
+ ],
33
+ },
34
+ ],
35
+ }
36
+ ]
37
+ },
38
+ )
39
+
40
+ messages: list[dict[str, Any]] = Field(
41
+ ...,
42
+ min_length=1,
43
+ description=(
44
+ "OpenAI-style conversation turns. Each item is "
45
+ "`{role, content}` where `role` is `system` / `user` / "
46
+ "`assistant` / `tool`. `content` is either a plain string or a "
47
+ "list of typed parts for multimodal input: `{type: 'text', text}`, "
48
+ "`{type: 'image_url', image_url: {url}}`, "
49
+ "`{type: 'audio_url', audio_url: {url}}`, "
50
+ "`{type: 'video_url', video_url: {url}}`, or inline base64 via "
51
+ "`{type: 'input_audio', input_audio: {data, format}}`. A media `url` "
52
+ "accepts an http(s) URL or a `data:` URL; `input_audio.data` is bare "
53
+ "base64. Which modalities are accepted depends on the resolved model "
54
+ "(see GET /v1/models)."
55
+ ),
56
+ )
57
+ model: str | None = Field(
58
+ default=None,
59
+ description=(
60
+ "Registered chat model name, alias, or repo id. When omitted, the "
61
+ "family default chat model answers. See GET /v1/models for the "
62
+ "servable list and each model's accepted input modalities."
63
+ ),
64
+ examples=["qwen3-omni"],
65
+ )
66
+ tools: list[dict[str, Any]] | None = Field(
67
+ default=None,
68
+ description=(
69
+ "OpenAI function-tool definitions: "
70
+ "`{type: 'function', function: {name, description, parameters}}` "
71
+ "where `parameters` is a JSON Schema object. Tool calls are parsed "
72
+ "from the model output and returned as `message.tool_calls`."
73
+ ),
74
+ )
75
+ tool_choice: Any | None = Field(
76
+ default=None,
77
+ description=(
78
+ "How the model may call tools: `'auto'` (default when tools are "
79
+ "given — model decides), `'none'` (never call a tool), "
80
+ "`'required'`/`'any'` (must call at least one tool), or a specific "
81
+ "tool `{type: 'function', function: {name}}`."
82
+ ),
83
+ )
84
+ parallel_tool_calls: bool = Field(
85
+ default=True,
86
+ description=(
87
+ "OpenAI-compatible. When false, at most one tool call is returned "
88
+ "even if the model emits several."
89
+ ),
90
+ )
91
+
92
+ max_completion_tokens: int | None = Field(
93
+ default=None,
94
+ ge=1,
95
+ description=(
96
+ "Upper bound on generated tokens. Replaces the deprecated "
97
+ "`max_tokens`, which is rejected."
98
+ ),
99
+ )
100
+ temperature: float | None = Field(
101
+ default=None,
102
+ description="Sampling temperature. Higher is more random; 0 is greedy.",
103
+ )
104
+ top_p: float | None = Field(
105
+ default=None,
106
+ description="Nucleus sampling cutoff in (0, 1].",
107
+ )
108
+ seed: int | None = Field(
109
+ default=None,
110
+ description="Seed for reproducible sampling when set.",
111
+ )
112
+
113
+ # Extensions (not in the OpenAI spec):
114
+ fps: float | None = Field(
115
+ default=None,
116
+ description=(
117
+ "kiapi extension (non-OpenAI). Frame sampling rate for video "
118
+ "inputs, in frames per second."
119
+ ),
120
+ )
121
+ use_audio_in_video: bool | None = Field(
122
+ default=None,
123
+ description=(
124
+ "kiapi extension (non-OpenAI). Demux a video's audio track and feed "
125
+ "it as audio alongside the frames. Overrides the server default."
126
+ ),
127
+ )
128
+ chat_template_kwargs: dict[str, Any] | None = Field(
129
+ default=None,
130
+ description=(
131
+ "kiapi extension (non-OpenAI). Extra kwargs forwarded verbatim to "
132
+ "the tokenizer's `apply_chat_template`, e.g. "
133
+ "`{'enable_thinking': false}` to turn off Qwen3.6's reasoning. "
134
+ "Mirrors the vLLM/SGLang "
135
+ "`extra_body={'chat_template_kwargs': {...}}` convention."
136
+ ),
137
+ )
138
+
139
+ stream: bool = Field(
140
+ default=False,
141
+ description=(
142
+ "When true, stream the answer as OpenAI-style "
143
+ "`text/event-stream` `chat.completion.chunk` events ending with "
144
+ "`data: [DONE]`. When false, wait for and return the full "
145
+ "`chat.completion` object."
146
+ ),
147
+ )
148
+
149
+ @model_validator(mode="after")
150
+ def reject_deprecated_max_tokens(self): # type: ignore
151
+ if self.model_extra and "max_tokens" in self.model_extra:
152
+ raise ValueError("max_tokens is deprecated; use max_completion_tokens")
153
+ return self
@@ -0,0 +1,131 @@
1
+ # depthpro
2
+
3
+ [English](README.md) | **日本語**
4
+
5
+ [mflux Depth Pro](https://github.com/filipstrand/mflux/blob/main/src/mflux/models/depth_pro/README.md) で、単一画像から深度マップを推定し、下記を生成します。
6
+
7
+ - グレースケール PNG の深度マップ
8
+ - 任意で、生の深度配列と min/max を含む圧縮 NPZ
9
+
10
+ ## API
11
+
12
+ | Endpoint | Name | Description |
13
+ |---|---|---|
14
+ | `POST /v1/image/depthpro/estimate` | 深度推定 | Files API の画像から深度マップを推定。 |
15
+ | `GET /v1/image/depthpro/models` | モデル一覧 | 利用可能なモデルの一覧を返す。 |
16
+ | `GET /v1/image/depthpro/openapi.json` | OpenAPI | 詳細な入出力仕様、使い方、TIPS を返す。 |
17
+
18
+ ## API Docs
19
+
20
+ - [OpenAPI JSON](https://kiarina.github.io/kiapi/v1/image/depthpro/openapi.json)
21
+ - [Swagger UI](https://kiarina.github.io/kiapi/v1/image/depthpro/docs.html)
22
+ - [ReDoc](https://kiarina.github.io/kiapi/v1/image/depthpro/redoc.html)
23
+
24
+ ## Dependencies
25
+
26
+ | Package | License | Description |
27
+ |---|---|---|
28
+ | [mflux](https://github.com/filipstrand/mflux) | MIT | Depth Pro の MLX 実装を利用。 |
29
+
30
+ ## Models
31
+
32
+ | Model | License | Terms | Size | Description |
33
+ |---|---|---|---:|---|
34
+ | [apple/DepthPro](https://huggingface.co/apple/DepthPro) | Apple Depth Pro License | 不要 | 1.8 GB | `base`(デフォルト)。単一画像から相対深度を推定。既定は `quantize: 8`。初回利用時にモデルをダウンロードすることがある。 |
35
+
36
+ ## Notes
37
+
38
+ - **レスポンス形式**:
39
+ `include_depth_data: true`(デフォルト)では PNG と NPZ の 2 成果物を作るため、
40
+ sync でも Job JSON を返す。`include_depth_data: false` では PNG のみになり、
41
+ sync はデフォルトで生の PNG バイト列を返す。Job JSON が必要な場合は
42
+ `Accept: application/json` を付ける。
43
+ - **quantize override**:
44
+ `quantize` は `3` / `4` / `5` / `6` / `8` / `null`。通常は常駐モデルを使うが、
45
+ リクエストで既定値と異なる `quantize` を指定した場合は、一回限りの一時モデルとして
46
+ ロード・実行・解放する。
47
+ - **入力サイズ上限**:
48
+ 既定では入力画像は `4096 * 4096` pixels まで。Depth Pro は内部でリサイズするが、
49
+ 大きすぎる入力でキューを長時間占有しないように制限している。
50
+ - **進捗**:
51
+ Depth Pro は単一 forward pass で細かいステップ通知を持たないため、実行中は時間ベースの
52
+ synthetic progress を流す。
53
+
54
+ ## Quickstart
55
+
56
+ ### estimate — 深度推定
57
+
58
+ 先にソース画像をアップロードする:
59
+
60
+ ```bash
61
+ IMG=$(curl -sS -X POST http://localhost:${PORT:-8000}/v1/files \
62
+ -F "file=@source.png" | jq -r .file_id)
63
+ ```
64
+
65
+ 深度 PNG と生データ NPZ の両方を作る:
66
+
67
+ ```bash
68
+ PARAMS=$(jq -n \
69
+ --arg img "$IMG" \
70
+ '{
71
+ model: "base",
72
+ mode: "sync",
73
+ image: {type: "file_id", file_id: $img},
74
+ quantize: 8,
75
+ include_depth_data: true
76
+ }')
77
+
78
+ curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/depthpro/estimate \
79
+ -H 'Accept: application/json' \
80
+ -H 'Content-Type: application/json' \
81
+ --data-binary "$PARAMS" | jq .
82
+ ```
83
+
84
+ 表示用の深度 PNG だけが欲しい場合:
85
+
86
+ ```bash
87
+ PARAMS=$(jq -n \
88
+ --arg img "$IMG" \
89
+ '{
90
+ model: "base",
91
+ mode: "sync",
92
+ image: {type: "file_id", file_id: $img},
93
+ include_depth_data: false
94
+ }')
95
+
96
+ curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/depthpro/estimate \
97
+ -H 'Content-Type: application/json' \
98
+ --data-binary "$PARAMS" \
99
+ -o depth.png
100
+ ```
101
+
102
+ ### async
103
+
104
+ ```bash
105
+ PARAMS=$(jq -n \
106
+ --arg img "$IMG" \
107
+ '{
108
+ model: "base",
109
+ mode: "async",
110
+ image: {type: "file_id", file_id: $img},
111
+ include_depth_data: true
112
+ }')
113
+
114
+ JOB=$(
115
+ curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/depthpro/estimate \
116
+ -H 'Accept: application/json' \
117
+ -H 'Content-Type: application/json' \
118
+ --data-binary "$PARAMS" |
119
+ jq -r .job_id
120
+ )
121
+
122
+ curl -sS http://localhost:${PORT:-8000}/v1/jobs/$JOB | jq .
123
+ ```
124
+
125
+ 完了後、Job の `artifacts` または `result.depth_image_file_id` /
126
+ `result.depth_data_file_id` を使って成果物を取得できます。
127
+
128
+ ```bash
129
+ FID=$(curl -sS http://localhost:${PORT:-8000}/v1/jobs/$JOB | jq -r .result.depth_image_file_id)
130
+ curl -sS http://localhost:${PORT:-8000}/v1/files/$FID/download -o depth.png
131
+ ```
@@ -0,0 +1,124 @@
1
+ # depthpro
2
+
3
+ **English** | [日本語](README.ja.md)
4
+
5
+ [mflux Depth Pro](https://github.com/filipstrand/mflux/blob/main/src/mflux/models/depth_pro/README.md) estimates a depth map from a single image and produces the following:
6
+
7
+ - Depth map in grayscale PNG
8
+ - optionally compressed NPZ with raw depth array and min/max
9
+
10
+ ## API
11
+
12
+ | Endpoint | Name | Description |
13
+ |---|---|---|
14
+ | `POST /v1/image/depthpro/estimate` | Depth estimation | Estimate depth map from Files API images. |
15
+ | `GET /v1/image/depthpro/models` | Model list | Returns a list of available models. |
16
+ | `GET /v1/image/depthpro/openapi.json` | OpenAPI | Returns detailed input/output specifications, usage, and TIPS. |
17
+
18
+ ## API Docs
19
+
20
+ - [OpenAPI JSON](https://kiarina.github.io/kiapi/v1/image/depthpro/openapi.json)
21
+ - [Swagger UI](https://kiarina.github.io/kiapi/v1/image/depthpro/docs.html)
22
+ - [ReDoc](https://kiarina.github.io/kiapi/v1/image/depthpro/redoc.html)
23
+
24
+ ## Dependencies
25
+
26
+ | Package | License | Description |
27
+ |---|---|---|
28
+ | [mflux](https://github.com/filipstrand/mflux) | MIT | Uses Depth Pro's MLX implementation. |
29
+
30
+ ## Models
31
+
32
+ | Model | License | Terms | Size | Description |
33
+ |---|---|---|---:|---|
34
+ | [apple/DepthPro](https://huggingface.co/apple/DepthPro) | Apple Depth Pro License | Not required | 1.8 GB | `base` (default). Estimating relative depth from a single image. Default is `quantize: 8`. A model may be downloaded the first time you use it. |
35
+
36
+ ## Notes
37
+
38
+ - **Response format**:
39
+ `include_depth_data: true` (default) creates two artifacts, PNG and NPZ.
40
+ sync also returns Job JSON. `include_depth_data: false` means only PNG,
41
+ sync returns raw PNG bytes by default. If you need Job JSON
42
+ Add `Accept: application/json`.
43
+ - **quantize override**:
44
+ `quantize` is `3` / `4` / `5` / `6` / `8` / `null`. Usually a resident model is used, but
45
+ If you specify `quantize` in the request that is different from the default value, it will be used as a one-time temporary model.
46
+ Load, execute, release.
47
+ - **Input size limit**:
48
+ By default, the input image is up to `4096 * 4096` pixels. Depth Pro resizes internally, but
49
+ Limits inputs that are too large to occupy the queue for too long.
50
+ - **Progress**:
51
+ Depth Pro has a single forward pass and no detailed step notification, so it uses time-based
52
+ Stream synthetic progress.
53
+
54
+ ## Quickstart
55
+
56
+ ### estimate — Depth estimation
57
+
58
+ Upload the source image first:
59
+ ```bash
60
+ IMG=$(curl -sS -X POST http://localhost:${PORT:-8000}/v1/files \
61
+ -F "file=@source.png" | jq -r .file_id)
62
+ ```
63
+ Create both depth PNG and raw data NPZ:
64
+ ```bash
65
+ PARAMS=$(jq -n \
66
+ --arg img "$IMG" \
67
+ '{
68
+ model: "base",
69
+ mode: "sync",
70
+ image: {type: "file_id", file_id: $img},
71
+ quantize: 8,
72
+ include_depth_data: true
73
+ }')
74
+
75
+ curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/depthpro/estimate \
76
+ -H 'Accept: application/json' \
77
+ -H 'Content-Type: application/json' \
78
+ --data-binary "$PARAMS" | jq .
79
+ ```
80
+ If you just want the depth PNG for display:
81
+ ```bash
82
+ PARAMS=$(jq -n \
83
+ --arg img "$IMG" \
84
+ '{
85
+ model: "base",
86
+ mode: "sync",
87
+ image: {type: "file_id", file_id: $img},
88
+ include_depth_data: false
89
+ }')
90
+
91
+ curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/depthpro/estimate \
92
+ -H 'Content-Type: application/json' \
93
+ --data-binary "$PARAMS" \
94
+ -o depth.png
95
+ ```
96
+
97
+ ### async
98
+
99
+ ```bash
100
+ PARAMS=$(jq -n \
101
+ --arg img "$IMG" \
102
+ '{
103
+ model: "base",
104
+ mode: "async",
105
+ image: {type: "file_id", file_id: $img},
106
+ include_depth_data: true
107
+ }')
108
+
109
+ JOB=$(
110
+ curl -sS -X POST http://localhost:${PORT:-8000}/v1/image/depthpro/estimate \
111
+ -H 'Accept: application/json' \
112
+ -H 'Content-Type: application/json' \
113
+ --data-binary "$PARAMS" |
114
+ jq -r .job_id
115
+ )
116
+
117
+ curl -sS http://localhost:${PORT:-8000}/v1/jobs/$JOB | jq .
118
+ ```
119
+ After completion, the Job's `artifacts` or `result.depth_image_file_id` /
120
+ You can retrieve artifacts using `result.depth_data_file_id`.
121
+ ```bash
122
+ FID=$(curl -sS http://localhost:${PORT:-8000}/v1/jobs/$JOB | jq -r .result.depth_image_file_id)
123
+ curl -sS http://localhost:${PORT:-8000}/v1/files/$FID/download -o depth.png
124
+ ```
@@ -0,0 +1,23 @@
1
+ """depthpro family — Depth Pro image → depth map estimation via mflux.
2
+
3
+ Endpoint: ``POST /v1/image/depthpro/estimate``. Depth Pro consumes one input
4
+ image from the Files API and stores a displayable grayscale depth PNG, plus an
5
+ optional compressed NPZ with the raw depth array.
6
+ """
7
+
8
+ from kiapi.capabilities import ValidationError
9
+
10
+ from ._helpers.register import register
11
+ from ._helpers.validate_estimate import validate_estimate
12
+ from ._operations.handle_estimate import handle_estimate
13
+ from ._settings import settings_manager
14
+ from ._views.estimate_request import EstimateRequest
15
+
16
+ __all__ = [
17
+ "EstimateRequest", # ._views
18
+ "ValidationError", # kiapi.capabilities
19
+ "handle_estimate", # ._operations
20
+ "register", # ._helpers
21
+ "settings_manager", # ._settings
22
+ "validate_estimate", # ._helpers
23
+ ]
@@ -0,0 +1,39 @@
1
+ DESCRIPTION = """Monocular depth estimation from a single image (Apple Depth Pro via mflux).
2
+
3
+ This is **image-to-depth**, not prompt-driven image generation: you give one
4
+ image and get back a metric depth map.
5
+
6
+ ## Upstream docs
7
+ - [mflux](https://github.com/filipstrand/mflux) — the MLX engine kiapi runs
8
+ - [apple/DepthPro](https://huggingface.co/apple/DepthPro) — model weights
9
+ - [apple/ml-depth-pro](https://github.com/apple/ml-depth-pro) — original Depth Pro code and paper
10
+
11
+ ## What you get back
12
+ - A grayscale depth **PNG** where brighter pixels are nearer and darker pixels
13
+ are farther — ready to display or overlay.
14
+ - Optionally (default on, `include_depth_data=true`) a compressed **NPZ**
15
+ containing the raw float depth array plus `min_depth` / `max_depth` in meters,
16
+ for downstream numeric use (point clouds, masking, measurement).
17
+
18
+ The depth array is loadable with NumPy: `np.load(path)["depth"]`, with scalar
19
+ `min_depth` / `max_depth` also stored in the same archive.
20
+
21
+ ## Models
22
+ - **base** (default) — `apple/DepthPro`. The only variant today.
23
+
24
+ ## Quantization
25
+ `quantize` selects the model's bit-width (one of 3, 4, 5, 6, 8; server default
26
+ 8). The warmed, resident model uses the server default; requesting a *different*
27
+ `quantize` builds a one-off transient model for that call, which loads weights
28
+ fresh and is therefore slower and not reused. Keep `quantize` unset (or equal to
29
+ the default) for the fast resident path.
30
+
31
+ ## TIPS
32
+ - For a quick visual, leave `include_depth_data=false` and call `sync` — you get
33
+ the PNG bytes straight back (`curl -o depth.png`).
34
+ - For measurement or 3D work, keep `include_depth_data=true` and read the NPZ.
35
+ - Large uploads are bounded by an input pixel cap; downscale very large images
36
+ before sending. Depth Pro resizes internally, so modest inputs are fine.
37
+ - First use downloads Apple's Depth Pro weights; run `kiapi activate` ahead of
38
+ time to avoid a cold-start download on the first request.
39
+ """
@@ -0,0 +1,46 @@
1
+ from kiapi.core.capability import CapabilitySpec, capability_spec_registry
2
+ from kiapi.core.model import ModelSpec, model_registry
3
+ from kiapi.core.setup import UrlFileResource
4
+
5
+ from .._constants.description import DESCRIPTION
6
+ from .._models import depthpro
7
+
8
+
9
+ def register() -> None:
10
+ capability_spec_registry.register(
11
+ CapabilitySpec(
12
+ name="depthpro",
13
+ domain="image",
14
+ title="kiapi DepthPro API",
15
+ summary="Estimate depth maps from input images.",
16
+ description=DESCRIPTION,
17
+ openapi_path="/v1/image/depthpro/openapi.json",
18
+ docs_path="/v1/image/depthpro/docs",
19
+ redoc_path="/v1/image/depthpro/redoc",
20
+ path_prefixes=("/v1/image/depthpro",),
21
+ )
22
+ )
23
+
24
+ depthpro_url = "https://ml-site.cdn-apple.com/models/depth-pro/depth_pro.pt"
25
+ model_registry.register(
26
+ ModelSpec(
27
+ name="base",
28
+ family="depthpro",
29
+ domain="image",
30
+ repo="apple/DepthPro",
31
+ module=depthpro,
32
+ weight_gb=2.7,
33
+ peak_headroom_gb=1.2,
34
+ framework="mlx",
35
+ priority=0,
36
+ aliases=("depthpro", "depth-pro", "DepthPro"),
37
+ default=True,
38
+ setup_resources=(
39
+ UrlFileResource(
40
+ url=depthpro_url,
41
+ path="~/.cache/mflux/depth_pro/depth_pro.pt",
42
+ disk_gb=1.8,
43
+ ),
44
+ ),
45
+ )
46
+ )
@@ -0,0 +1,32 @@
1
+ from PIL import Image
2
+
3
+ from kiapi.capabilities import ValidationError
4
+
5
+ from .._settings import settings_manager
6
+ from .._views.estimate_request import EstimateRequest
7
+
8
+
9
+ def validate_estimate(
10
+ req: EstimateRequest,
11
+ *,
12
+ image_path: str | None = None,
13
+ ) -> None:
14
+ settings = settings_manager.get_settings()
15
+
16
+ if req.quantize is not None and req.quantize not in (3, 4, 5, 6, 8):
17
+ raise ValidationError("quantize must be one of 3, 4, 5, 6, 8")
18
+
19
+ if image_path is None:
20
+ return
21
+
22
+ try:
23
+ with Image.open(image_path) as img:
24
+ width, height = img.size
25
+ except Exception as exc:
26
+ raise ValidationError(f"input image could not be opened: {exc}") # noqa: B904
27
+
28
+ pixels = width * height
29
+ if pixels > settings.max_input_pixels:
30
+ raise ValidationError(
31
+ f"input image has {pixels} pixels, exceeding the cap {settings.max_input_pixels}"
32
+ )