@henjicc/ai-sdk 0.2.8 → 0.3.0

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 (236) hide show
  1. package/CHANGELOG.md +153 -143
  2. package/README.md +486 -461
  3. package/dist/capabilities/embedding/bailian.d.ts +23 -0
  4. package/dist/capabilities/embedding/bailian.js +10 -0
  5. package/dist/capabilities/embedding/bigmodel.d.ts +9 -0
  6. package/dist/capabilities/embedding/bigmodel.js +5 -0
  7. package/dist/capabilities/embedding/index.d.ts +1 -0
  8. package/dist/capabilities/embedding/index.js +1 -0
  9. package/dist/capabilities/embedding/ppio.d.ts +7 -0
  10. package/dist/capabilities/embedding/ppio.js +5 -0
  11. package/dist/capabilities/embedding/siliconflow.d.ts +21 -0
  12. package/dist/capabilities/embedding/siliconflow.js +10 -0
  13. package/dist/capabilities/embedding/volcengine.d.ts +10 -0
  14. package/dist/capabilities/embedding/volcengine.js +6 -0
  15. package/dist/capabilities/rerank/bailian.d.ts +21 -0
  16. package/dist/capabilities/rerank/bailian.js +14 -0
  17. package/dist/capabilities/rerank/bigmodel.d.ts +9 -0
  18. package/dist/capabilities/rerank/bigmodel.js +5 -0
  19. package/dist/capabilities/rerank/index.d.ts +1 -0
  20. package/dist/capabilities/rerank/index.js +1 -0
  21. package/dist/capabilities/rerank/ppio.d.ts +7 -0
  22. package/dist/capabilities/rerank/ppio.js +5 -0
  23. package/dist/capabilities/rerank/siliconflow.d.ts +21 -0
  24. package/dist/capabilities/rerank/siliconflow.js +10 -0
  25. package/dist/capabilities/retrieval/http.d.ts +3 -0
  26. package/dist/capabilities/retrieval/http.js +48 -0
  27. package/dist/capabilities/retrieval/module.d.ts +11 -0
  28. package/dist/capabilities/retrieval/module.js +110 -0
  29. package/dist/capabilities/retrieval/types.d.ts +54 -0
  30. package/dist/capabilities/retrieval/types.js +1 -0
  31. package/dist/capabilities/retrieval/validation.d.ts +10 -0
  32. package/dist/capabilities/retrieval/validation.js +65 -0
  33. package/dist/capabilities/types.d.ts +1 -1
  34. package/dist/catalog/apimart/gpt-image-2.5.model.d.ts +2 -0
  35. package/dist/catalog/apimart/gpt-image-2.5.model.js +51 -0
  36. package/dist/catalog/fal/gpt-image-2.5.model.d.ts +2 -0
  37. package/dist/catalog/fal/gpt-image-2.5.model.js +53 -0
  38. package/dist/catalog/fal/ic-light-v2.model.js +9 -13
  39. package/dist/catalog/grsai/gpt-image-2.5.model.d.ts +2 -0
  40. package/dist/catalog/grsai/gpt-image-2.5.model.js +54 -0
  41. package/dist/catalog/grsai/gptImage25Sizes.d.ts +1 -0
  42. package/dist/catalog/grsai/gptImage25Sizes.js +76 -0
  43. package/dist/catalog/index.js +112 -104
  44. package/dist/catalog/kie/gpt-image-2.5.model.d.ts +2 -0
  45. package/dist/catalog/kie/gpt-image-2.5.model.js +38 -0
  46. package/dist/catalog/shared/gptImage25.d.ts +16 -0
  47. package/dist/catalog/shared/gptImage25.js +48 -0
  48. package/dist/catalog/shared/gptImage25Pricing.d.ts +12 -0
  49. package/dist/catalog/shared/gptImage25Pricing.js +508 -0
  50. package/dist/llm/defaults.d.ts +1 -1
  51. package/dist/llm/defaults.js +1 -1
  52. package/dist/llm/modelCatalogEntries.js +16 -0
  53. package/dist/llm/providerPresets.js +2 -2
  54. package/dist/packs/models/apimart/gpt-image-2.5.d.ts +6 -0
  55. package/dist/packs/models/apimart/gpt-image-2.5.js +7 -0
  56. package/dist/packs/models/fal/gpt-image-2.5.d.ts +6 -0
  57. package/dist/packs/models/fal/gpt-image-2.5.js +7 -0
  58. package/dist/packs/models/grsai/gpt-image-2.5.d.ts +6 -0
  59. package/dist/packs/models/grsai/gpt-image-2.5.js +7 -0
  60. package/dist/packs/models/kie/gpt-image-2.5.d.ts +6 -0
  61. package/dist/packs/models/kie/gpt-image-2.5.js +7 -0
  62. package/dist/packs/provider-packs/apimart.d.ts +1 -1
  63. package/dist/packs/provider-packs/apimart.js +21 -20
  64. package/dist/packs/provider-packs/fal.d.ts +1 -1
  65. package/dist/packs/provider-packs/fal.js +37 -36
  66. package/dist/packs/provider-packs/grsai.d.ts +1 -1
  67. package/dist/packs/provider-packs/grsai.js +6 -5
  68. package/dist/packs/provider-packs/kie.d.ts +1 -1
  69. package/dist/packs/provider-packs/kie.js +28 -27
  70. package/dist/packs/tool-models/fal/{qwen-image-edit-2509-multiple-angles.d.ts → qwen-image-edit-2511-multiple-angles.d.ts} +1 -1
  71. package/dist/packs/tool-models/fal/{qwen-image-edit-2509-multiple-angles.js → qwen-image-edit-2511-multiple-angles.js} +1 -1
  72. package/dist/packs/tool-packs/fal-multi-angle-tools.js +1 -1
  73. package/dist/tool-packs/fal-multi-angle/models/qwen-image-edit-2511-multiple-angles.model.d.ts +2 -0
  74. package/dist/tool-packs/fal-multi-angle/models/{qwen-image-edit-2509-multiple-angles.model.js → qwen-image-edit-2511-multiple-angles.model.js} +20 -17
  75. package/docs/README.md +26 -26
  76. package/docs/consumers.md +54 -48
  77. package/docs/llm-adaptation/README.md +139 -139
  78. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206/DeepSeek.md +103 -91
  79. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206/Kimi.md +75 -75
  80. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206/MiniMax.md +84 -84
  81. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206//345/260/217/347/261/263MiMo.md +85 -85
  82. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206//346/231/272/350/260/261GLM.md +232 -232
  83. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206//347/201/253/345/261/261/345/274/225/346/223/216.md +87 -87
  84. package/docs/llm-adaptation//344/276/233/345/272/224/345/225/206//347/231/276/347/202/274Qwen.md +84 -84
  85. package/docs/llm-adaptation//346/226/207/346/241/243/351/207/207/351/233/206/346/211/213/345/206/214.md +88 -88
  86. package/docs/model-adaptation/Bria-Eraser/Bria-Eraser_Fal.md +32 -32
  87. package/docs/model-adaptation/Bria-/345/210/233/346/204/217/346/224/276/345/244/247/Bria-/345/210/233/346/204/217/346/224/276/345/244/247_Fal.md +31 -31
  88. package/docs/model-adaptation/ControlLight/ControlLight_Fal.md +85 -85
  89. package/docs/model-adaptation/FLUX-2-/345/244/232/350/247/222/345/272/246/FLUX-2-/345/244/232/350/247/222/345/272/246_Fal.md +107 -107
  90. package/docs/model-adaptation/Finegrain-Eraser/Finegrain-Eraser_Fal.md +31 -31
  91. package/docs/model-adaptation/Flux-Pro-Erase/Flux-Pro-Erase_Fal.md +34 -34
  92. package/docs/model-adaptation/Fun-ASR/Fun-ASR_/347/231/276/347/202/274.md +43 -43
  93. package/docs/model-adaptation/Fun-ASR-Flash-2026-06-15/Fun-ASR-Flash-2026-06-15_/347/231/276/347/202/274.md +41 -41
  94. package/docs/model-adaptation/Fun-ASR-Realtime/Fun-ASR-Realtime_/347/231/276/347/202/274.md +37 -37
  95. package/docs/model-adaptation/Fun-ASR-Realtime-2026-02-28/Fun-ASR-Realtime-2026-02-28_/347/231/276/347/202/274.md +39 -39
  96. package/docs/model-adaptation/GLM-5.3-Flash/GLM-5.3-Flash_/346/231/272/350/260/261.md +207 -207
  97. package/docs/model-adaptation/GPT-Image-2/GPT-Image-2_APIMart.md +173 -173
  98. package/docs/model-adaptation/GPT-Image-2/GPT-Image-2_Fal.md +94 -94
  99. package/docs/model-adaptation/GPT-Image-2/GPT-Image-2_Grsai.md +137 -137
  100. package/docs/model-adaptation/GPT-Image-2/GPT-Image-2_KIE.md +93 -93
  101. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_APIMart.md +66 -0
  102. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_Fal.md +55 -0
  103. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_Grsai.md +53 -0
  104. package/docs/model-adaptation/GPT-Image-2.5/GPT-Image-2.5_KIE.md +55 -0
  105. package/docs/model-adaptation/GPT-OSS-20B/GPT-OSS-20B_Groq.md +62 -62
  106. package/docs/model-adaptation/Gemini-Omni-Flash/Gemini-Omni-Flash_APIMart.md +124 -124
  107. package/docs/model-adaptation/Gemini-Omni-Flash/Gemini-Omni-Flash_Fal.md +84 -84
  108. package/docs/model-adaptation/Gemini-Omni-Flash/Gemini-Omni-Flash_KIE.md +129 -129
  109. package/docs/model-adaptation/Grok-Imagine/Grok-Imagine_KIE.md +36 -36
  110. package/docs/model-adaptation/Grok-Imagine-2.0/Grok-Imagine-2.0_APIMart.md +250 -250
  111. package/docs/model-adaptation/Grok-Imagine-2.0/Grok-Imagine-2.0_Fal.md +84 -84
  112. package/docs/model-adaptation/Grok-Imagine-2.0/Grok-Imagine-2.0_KIE.md +105 -105
  113. package/docs/model-adaptation/Hailuo-02/Hailuo-02_Fal.md +93 -93
  114. package/docs/model-adaptation/Hailuo-02/Hailuo-02_KIE.md +56 -56
  115. package/docs/model-adaptation/Hailuo-2.3/Hailuo-2.3_Fal.md +88 -88
  116. package/docs/model-adaptation/Hailuo-2.3/Hailuo-2.3_KIE.md +51 -51
  117. package/docs/model-adaptation/Hailuo-2.3/Hailuo-2.3_/346/264/276/346/254/247/344/272/221.md +70 -70
  118. package/docs/model-adaptation/IC-Light-v2/IC-Light-v2_Fal.md +97 -94
  119. package/docs/model-adaptation/Ideogram-/345/233/276/347/211/207/346/224/276/345/244/247/Ideogram-/345/233/276/347/211/207/346/224/276/345/244/247_Fal.md +41 -41
  120. package/docs/model-adaptation/Image-Apps-v2-/345/225/206/345/223/201/346/221/204/345/275/261/Image-Apps-v2-/345/225/206/345/223/201/346/221/204/345/275/261_Fal.md +72 -72
  121. package/docs/model-adaptation/Image-Apps-v2-/346/211/251/345/233/276/Image-Apps-v2-/346/211/251/345/233/276_Fal.md +93 -93
  122. package/docs/model-adaptation/Image-Apps-v2-/347/205/247/347/211/207/344/277/256/345/244/215/Image-Apps-v2-/347/205/247/347/211/207/344/277/256/345/244/215_Fal.md +86 -86
  123. package/docs/model-adaptation/Image-Apps-v2-/351/207/215/346/211/223/345/205/211/Image-Apps-v2-/351/207/215/346/211/223/345/205/211_Fal.md +84 -84
  124. package/docs/model-adaptation/Kling-3.0/Kling-3.0_APIMart.md +112 -112
  125. package/docs/model-adaptation/Kling-3.0/Kling-3.0_Fal.md +89 -89
  126. package/docs/model-adaptation/Kling-3.0/Kling-3.0_KIE.md +106 -106
  127. package/docs/model-adaptation/Kling-3.0/Kling-3.0_/346/264/276/346/254/247/344/272/221.md +119 -119
  128. package/docs/model-adaptation/Kling-3.0-Omni/Kling-3.0-Omni_APIMart.md +125 -125
  129. package/docs/model-adaptation/Kling-3.0-Omni/Kling-3.0-Omni_Fal.md +107 -107
  130. package/docs/model-adaptation/Kling-3.0-Omni/Kling-3.0-Omni_KIE.md +143 -143
  131. package/docs/model-adaptation/Kling-3.0-Turbo/Kling-3.0-Turbo_APIMart.md +85 -85
  132. package/docs/model-adaptation/Kling-3.0-Turbo/Kling-3.0-Turbo_Fal.md +83 -83
  133. package/docs/model-adaptation/Kling-3.0-Turbo/Kling-3.0-Turbo_KIE.md +84 -84
  134. package/docs/model-adaptation/Midjourney/Midjourney_APIMart.md +396 -396
  135. package/docs/model-adaptation/MiniMax-H3/MiniMax-H3_APIMart.md +234 -234
  136. package/docs/model-adaptation/MiniMax-H3/MiniMax-H3_Fal.md +108 -108
  137. package/docs/model-adaptation/MiniMax-H3/MiniMax-H3_KIE.md +111 -111
  138. package/docs/model-adaptation/MiniMax-Speech/MiniMax-Speech_/346/264/276/346/254/247/344/272/221.md +170 -170
  139. package/docs/model-adaptation/Nano-Banana-2/Nano-Banana-2_APIMart.md +89 -89
  140. package/docs/model-adaptation/Nano-Banana-2/Nano-Banana-2_Fal.md +99 -99
  141. package/docs/model-adaptation/Nano-Banana-2/Nano-Banana-2_Grsai.md +82 -82
  142. package/docs/model-adaptation/Nano-Banana-2/Nano-Banana-2_KIE.md +70 -70
  143. package/docs/model-adaptation/Nano-Banana-2-Lite/Nano-Banana-2-Lite_APIMart.md +79 -79
  144. package/docs/model-adaptation/Nano-Banana-2-Lite/Nano-Banana-2-Lite_Grsai.md +65 -65
  145. package/docs/model-adaptation/Nano-Banana-2-Lite/Nano-Banana-2-Lite_KIE.md +64 -64
  146. package/docs/model-adaptation/Nano-Banana-Pro/Nano-Banana-Pro_APIMart.md +83 -83
  147. package/docs/model-adaptation/Nano-Banana-Pro/Nano-Banana-Pro_Fal.md +89 -89
  148. package/docs/model-adaptation/Nano-Banana-Pro/Nano-Banana-Pro_Grsai.md +82 -82
  149. package/docs/model-adaptation/Nano-Banana-Pro/Nano-Banana-Pro_KIE.md +64 -64
  150. package/docs/model-adaptation/Pixelcut-/350/203/214/346/231/257/347/247/273/351/231/244/Pixelcut-/350/203/214/346/231/257/347/247/273/351/231/244_Fal.md +79 -79
  151. package/docs/model-adaptation/Qwen-Image-3.0/Qwen-Image-3.0_APIMart.md +117 -117
  152. package/docs/model-adaptation/Qwen-Image-3.0/Qwen-Image-3.0_Fal.md +84 -84
  153. package/docs/model-adaptation/Qwen-Image-3.0/Qwen-Image-3.0_KIE.md +103 -103
  154. package/docs/model-adaptation/Qwen-Image-3.0/Qwen-Image-3.0_/347/231/276/347/202/274.md +138 -138
  155. package/docs/model-adaptation/Qwen-Image-Edit-2511-/345/244/232/350/247/222/345/272/246/Qwen-Image-Edit-2511-/345/244/232/350/247/222/345/272/246_Fal.md +57 -0
  156. package/docs/model-adaptation/Qwen-MT-Flash/Qwen-MT-Flash_/347/231/276/347/202/274.md +47 -47
  157. package/docs/model-adaptation/Qwen-MT-Lite/Qwen-MT-Lite_/347/231/276/347/202/274.md +39 -39
  158. package/docs/model-adaptation/Qwen-MT-Plus/Qwen-MT-Plus_/347/231/276/347/202/274.md +39 -39
  159. package/docs/model-adaptation/Qwen3-ASR-Flash/Qwen3-ASR-Flash_/347/231/276/347/202/274.md +40 -40
  160. package/docs/model-adaptation/Qwen3-ASR-Flash-2026-02-10/Qwen3-ASR-Flash-2026-02-10_/347/231/276/347/202/274.md +33 -33
  161. package/docs/model-adaptation/Qwen3-ASR-Flash-Filetrans/Qwen3-ASR-Flash-Filetrans_/347/231/276/347/202/274.md +41 -41
  162. package/docs/model-adaptation/Qwen3-ASR-Flash-Realtime/Qwen3-ASR-Flash-Realtime_/347/231/276/347/202/274.md +35 -35
  163. package/docs/model-adaptation/Qwen3-ASR-Flash-Realtime-2026-02-10/Qwen3-ASR-Flash-Realtime-2026-02-10_/347/231/276/347/202/274.md +37 -37
  164. package/docs/model-adaptation/README.md +313 -295
  165. package/docs/model-adaptation/SeedASR-2.0-File/SeedASR-2.0-File_/347/201/253/345/261/261/345/274/225/346/223/216.md +115 -115
  166. package/docs/model-adaptation/SeedASR-2.0-Realtime/SeedASR-2.0-Realtime_/347/201/253/345/261/261/345/274/225/346/223/216.md +143 -143
  167. package/docs/model-adaptation/SeedVR2-/345/233/276/347/211/207/346/224/276/345/244/247/SeedVR2-/345/233/276/347/211/207/346/224/276/345/244/247_Fal.md +45 -45
  168. package/docs/model-adaptation/Seedance-2.0/Seedance-2.0_APIMart.md +121 -121
  169. package/docs/model-adaptation/Seedance-2.0/Seedance-2.0_Fal.md +97 -97
  170. package/docs/model-adaptation/Seedance-2.0/Seedance-2.0_KIE.md +86 -86
  171. package/docs/model-adaptation/Seedance-2.0-Fast/Seedance-2.0-Fast_APIMart.md +89 -89
  172. package/docs/model-adaptation/Seedance-2.0-Fast/Seedance-2.0-Fast_Fal.md +95 -95
  173. package/docs/model-adaptation/Seedance-2.0-Fast/Seedance-2.0-Fast_KIE.md +78 -78
  174. package/docs/model-adaptation/Seedance-2.0-Mini/Seedance-2.0-Mini_APIMart.md +89 -89
  175. package/docs/model-adaptation/Seedance-2.0-Mini/Seedance-2.0-Mini_Fal.md +96 -96
  176. package/docs/model-adaptation/Seedance-2.0-Mini/Seedance-2.0-Mini_KIE.md +78 -78
  177. package/docs/model-adaptation/Seedance-2.5/Seedance-2.5_APIMart.md +212 -212
  178. package/docs/model-adaptation/Seedance-2.5/Seedance-2.5_Fal.md +94 -94
  179. package/docs/model-adaptation/Seedance-2.5/Seedance-2.5_KIE.md +89 -89
  180. package/docs/model-adaptation/Seedream-5.0-Lite/Seedream-5.0-Lite_APIMart.md +106 -106
  181. package/docs/model-adaptation/Seedream-5.0-Lite/Seedream-5.0-Lite_Fal.md +91 -91
  182. package/docs/model-adaptation/Seedream-5.0-Lite/Seedream-5.0-Lite_KIE.md +89 -89
  183. package/docs/model-adaptation/Seedream-5.0-Lite/Seedream-5.0-Lite_/347/201/253/345/261/261/345/274/225/346/223/216.md +108 -108
  184. package/docs/model-adaptation/Seedream-5.0-Pro/Seedream-5.0-Pro_APIMart.md +194 -194
  185. package/docs/model-adaptation/Seedream-5.0-Pro/Seedream-5.0-Pro_Fal.md +100 -100
  186. package/docs/model-adaptation/Seedream-5.0-Pro/Seedream-5.0-Pro_KIE.md +141 -141
  187. package/docs/model-adaptation/Seedream-5.0-Pro/Seedream-5.0-Pro_/347/201/253/345/261/261/345/274/225/346/223/216.md +137 -137
  188. package/docs/model-adaptation/SenseVoiceSmall/SenseVoiceSmall_/347/241/205/345/237/272/346/265/201/345/212/250.md +69 -69
  189. package/docs/model-adaptation/TeleSpeechASR/TeleSpeechASR_/347/241/205/345/237/272/346/265/201/345/212/250.md +72 -72
  190. package/docs/model-adaptation/Topaz-/345/233/276/347/211/207/346/224/276/345/244/247/Topaz-/345/233/276/347/211/207/346/224/276/345/244/247_Fal.md +87 -87
  191. package/docs/model-adaptation/Topaz-/351/200/217/346/230/216/345/233/276/346/224/276/345/244/247/Topaz-/351/200/217/346/230/216/345/233/276/346/224/276/345/244/247_Fal.md +34 -34
  192. package/docs/model-adaptation/Wan-2.5-Preview/Wan-2.5-Preview_/346/264/276/346/254/247/344/272/221.md +82 -82
  193. package/docs/model-adaptation/Wan-2.6/Wan-2.6_/346/264/276/346/254/247/344/272/221.md +84 -84
  194. package/docs/model-adaptation/Wan-2.7/Wan-2.7_/346/264/276/346/254/247/344/272/221.md +122 -122
  195. package/docs/model-adaptation/Whisper-Large-v3/Whisper-Large-v3_Groq.md +76 -76
  196. package/docs/model-adaptation/Whisper-Large-v3-Turbo/Whisper-Large-v3-Turbo_Groq.md +75 -75
  197. package/docs/model-adaptation/Z-Image-Turbo/Z-Image-Turbo_APIMart.md +88 -88
  198. package/docs/model-adaptation/Z-Image-Turbo/Z-Image-Turbo_Fal.md +95 -95
  199. package/docs/model-adaptation/Z-Image-Turbo/Z-Image-Turbo_KIE.md +71 -71
  200. package/docs/model-adaptation/Z-Image-Turbo/Z-Image-Turbo_/347/231/276/347/202/274.md +122 -122
  201. package/docs/model-adaptation/Z-Image-Turbo/Z-Image-Turbo_/351/255/224/346/220/255.md +97 -97
  202. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206/APIMart.md +238 -238
  203. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206/Fal.md +172 -172
  204. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206/Groq.md +121 -121
  205. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206/Grsai.md +217 -217
  206. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206/KIE.md +131 -131
  207. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//345/200/231/351/200/211/344/276/233/345/272/224/345/225/206/350/260/203/347/240/224-/345/233/276/347/211/207/345/267/245/345/205/267.md +151 -151
  208. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//345/277/253/351/200/237/351/200/202/351/205/215/344/276/233/345/272/224/345/225/206.md +65 -65
  209. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//346/264/276/346/254/247/344/272/221.md +147 -138
  210. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//347/201/253/345/261/261/345/274/225/346/223/216.md +181 -171
  211. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//347/231/276/347/202/274.md +237 -227
  212. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//347/241/205/345/237/272/346/265/201/345/212/250.md +110 -88
  213. package/docs/model-adaptation//344/276/233/345/272/224/345/225/206//351/255/224/346/220/255.md +207 -207
  214. package/docs/model-adaptation//346/226/207/346/241/243/351/207/207/351/233/206/346/211/213/345/206/214.md +338 -311
  215. package/docs/model-adaptation//351/200/217/350/247/206/345/217/230/346/215/242//351/200/217/350/247/206/345/217/230/346/215/242_Fal.md +59 -59
  216. package/docs//346/216/245/345/205/245/346/214/207/345/215/227/Electron.md +77 -77
  217. package/docs//346/216/245/345/205/245/346/214/207/345/215/227/Tauri.md +81 -81
  218. package/docs//346/216/245/345/205/245/346/214/207/345/215/227/UXP.md +169 -169
  219. package/docs//346/216/245/345/205/245/346/214/207/345/215/227//344/276/233/345/272/224/345/225/206/345/237/237/345/220/215.md +83 -83
  220. package/docs//346/216/245/345/205/245/346/214/207/345/215/227//351/224/231/350/257/257/345/244/204/347/220/206.md +72 -72
  221. package/examples/form-renderer/README.md +17 -17
  222. package/examples/form-renderer/cli.ts +32 -32
  223. package/examples/form-renderer/index.ts +144 -144
  224. package/examples/form-renderer/package.json +16 -16
  225. package/examples/form-renderer/tsconfig.json +14 -14
  226. package/examples/llm-chat/README.md +32 -32
  227. package/examples/llm-chat/index.ts +100 -100
  228. package/examples/llm-chat/package.json +19 -19
  229. package/examples/llm-chat/tsconfig.json +14 -14
  230. package/examples/minimal-node/README.md +31 -31
  231. package/examples/minimal-node/index.ts +138 -138
  232. package/examples/minimal-node/package.json +17 -17
  233. package/examples/minimal-node/tsconfig.json +14 -14
  234. package/package.json +252 -197
  235. package/dist/tool-packs/fal-multi-angle/models/qwen-image-edit-2509-multiple-angles.model.d.ts +0 -2
  236. package/docs/model-adaptation/Qwen-Image-Edit-2509-/345/244/232/350/247/222/345/272/246/Qwen-Image-Edit-2509-/345/244/232/350/247/222/345/272/246_Fal.md +0 -116
@@ -0,0 +1,23 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const bailianEmbeddingPresets: {
3
+ readonly 'qwen3.7-text-embedding': {
4
+ readonly modelId: "qwen3.7-text-embedding";
5
+ readonly maxBatchSize: 20;
6
+ readonly dimensions: readonly [256, 512, 768, 1024, 1536, 2048, 2560];
7
+ };
8
+ readonly 'qwen3.7-text-embedding-flash': {
9
+ readonly modelId: "qwen3.7-text-embedding-flash";
10
+ readonly maxBatchSize: 20;
11
+ readonly dimensions: readonly [256, 512, 768, 1024];
12
+ };
13
+ readonly 'text-embedding-v4': {
14
+ readonly modelId: "text-embedding-v4";
15
+ readonly maxBatchSize: 10;
16
+ readonly dimensions: readonly [64, 128, 256, 512, 768, 1024, 1536, 2048];
17
+ };
18
+ };
19
+ /** baseUrl is the actual workspace/region API root, without the endpoint path. */
20
+ export declare function createBailianEmbeddingModule(config: RetrievalModuleConfig & {
21
+ baseUrl: string;
22
+ model?: keyof typeof bailianEmbeddingPresets;
23
+ }): import("./index.js").EmbeddingModule;
@@ -0,0 +1,10 @@
1
+ import { embeddingModule } from '../retrieval/module.js';
2
+ export const bailianEmbeddingPresets = {
3
+ 'qwen3.7-text-embedding': { modelId: 'qwen3.7-text-embedding', maxBatchSize: 20, dimensions: [256, 512, 768, 1024, 1536, 2048, 2560] },
4
+ 'qwen3.7-text-embedding-flash': { modelId: 'qwen3.7-text-embedding-flash', maxBatchSize: 20, dimensions: [256, 512, 768, 1024] },
5
+ 'text-embedding-v4': { modelId: 'text-embedding-v4', maxBatchSize: 10, dimensions: [64, 128, 256, 512, 768, 1024, 1536, 2048] },
6
+ };
7
+ /** baseUrl is the actual workspace/region API root, without the endpoint path. */
8
+ export function createBailianEmbeddingModule(config) {
9
+ return embeddingModule(bailianEmbeddingPresets[config.model ?? 'qwen3.7-text-embedding'], { providerId: 'bailian', path: '/compatible-mode/v1/embeddings' }, config);
10
+ }
@@ -0,0 +1,9 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const bigmodelEmbeddingPresets: {
3
+ readonly 'embedding-3': {
4
+ readonly modelId: "embedding-3";
5
+ readonly maxBatchSize: 64;
6
+ readonly dimensions: readonly [256, 512, 1024, 2048];
7
+ };
8
+ };
9
+ export declare function createBigmodelEmbeddingModule(config?: RetrievalModuleConfig): import("./index.js").EmbeddingModule;
@@ -0,0 +1,5 @@
1
+ import { embeddingModule } from '../retrieval/module.js';
2
+ export const bigmodelEmbeddingPresets = { 'embedding-3': { modelId: 'embedding-3', maxBatchSize: 64, dimensions: [256, 512, 1024, 2048] } };
3
+ export function createBigmodelEmbeddingModule(config = {}) {
4
+ return embeddingModule(bigmodelEmbeddingPresets['embedding-3'], { providerId: 'bigmodel', baseUrl: 'https://open.bigmodel.cn', path: '/api/paas/v4/embeddings', floatEncoding: false }, config);
5
+ }
@@ -0,0 +1 @@
1
+ export type { EmbeddingInput, EmbeddingOutput, EmbeddingModule, EmbeddingPreset, RetrievalUsage, RetrievalModuleConfig } from '../retrieval/types.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const ppioEmbeddingPresets: {
3
+ readonly 'baai/bge-m3': {
4
+ readonly modelId: "baai/bge-m3";
5
+ };
6
+ };
7
+ export declare function createPpioEmbeddingModule(config?: RetrievalModuleConfig): import("./index.js").EmbeddingModule;
@@ -0,0 +1,5 @@
1
+ import { embeddingModule } from '../retrieval/module.js';
2
+ export const ppioEmbeddingPresets = { 'baai/bge-m3': { modelId: 'baai/bge-m3' } };
3
+ export function createPpioEmbeddingModule(config = {}) {
4
+ return embeddingModule(ppioEmbeddingPresets['baai/bge-m3'], { providerId: 'ppio', baseUrl: 'https://api.ppio.com', path: '/openai/v1/embeddings' }, config);
5
+ }
@@ -0,0 +1,21 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const siliconflowEmbeddingPresets: {
3
+ readonly 'Qwen/Qwen3-Embedding-8B': {
4
+ readonly modelId: "Qwen/Qwen3-Embedding-8B";
5
+ readonly dimensions: readonly [64, 128, 256, 512, 768, 1024, 1536, 2048, 2560, 4096];
6
+ };
7
+ readonly 'Qwen/Qwen3-Embedding-4B': {
8
+ readonly modelId: "Qwen/Qwen3-Embedding-4B";
9
+ readonly dimensions: readonly [64, 128, 256, 512, 768, 1024, 1536, 2048, 2560];
10
+ };
11
+ readonly 'Qwen/Qwen3-Embedding-0.6B': {
12
+ readonly modelId: "Qwen/Qwen3-Embedding-0.6B";
13
+ readonly dimensions: readonly [64, 128, 256, 512, 768, 1024];
14
+ };
15
+ readonly 'BAAI/bge-m3': {
16
+ readonly modelId: "BAAI/bge-m3";
17
+ };
18
+ };
19
+ export declare function createSiliconflowEmbeddingModule(config?: RetrievalModuleConfig & {
20
+ model?: keyof typeof siliconflowEmbeddingPresets;
21
+ }): import("./index.js").EmbeddingModule;
@@ -0,0 +1,10 @@
1
+ import { embeddingModule } from '../retrieval/module.js';
2
+ export const siliconflowEmbeddingPresets = {
3
+ 'Qwen/Qwen3-Embedding-8B': { modelId: 'Qwen/Qwen3-Embedding-8B', dimensions: [64, 128, 256, 512, 768, 1024, 1536, 2048, 2560, 4096] },
4
+ 'Qwen/Qwen3-Embedding-4B': { modelId: 'Qwen/Qwen3-Embedding-4B', dimensions: [64, 128, 256, 512, 768, 1024, 1536, 2048, 2560] },
5
+ 'Qwen/Qwen3-Embedding-0.6B': { modelId: 'Qwen/Qwen3-Embedding-0.6B', dimensions: [64, 128, 256, 512, 768, 1024] },
6
+ 'BAAI/bge-m3': { modelId: 'BAAI/bge-m3' },
7
+ };
8
+ export function createSiliconflowEmbeddingModule(config = {}) {
9
+ return embeddingModule(siliconflowEmbeddingPresets[config.model ?? 'Qwen/Qwen3-Embedding-8B'], { providerId: 'siliconflow', baseUrl: 'https://api.siliconflow.cn', path: '/v1/embeddings' }, config);
10
+ }
@@ -0,0 +1,10 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ /** Text-only entry: one text per call, so Ark never fuses independent documents. */
3
+ export declare const volcengineEmbeddingPresets: {
4
+ readonly 'doubao-embedding-vision-251215': {
5
+ readonly modelId: "doubao-embedding-vision-251215";
6
+ readonly maxBatchSize: 1;
7
+ readonly dimensions: readonly [1024, 2048];
8
+ };
9
+ };
10
+ export declare function createVolcengineEmbeddingModule(config?: RetrievalModuleConfig): import("./index.js").EmbeddingModule;
@@ -0,0 +1,6 @@
1
+ import { embeddingModule } from '../retrieval/module.js';
2
+ /** Text-only entry: one text per call, so Ark never fuses independent documents. */
3
+ export const volcengineEmbeddingPresets = { 'doubao-embedding-vision-251215': { modelId: 'doubao-embedding-vision-251215', maxBatchSize: 1, dimensions: [1024, 2048] } };
4
+ export function createVolcengineEmbeddingModule(config = {}) {
5
+ return embeddingModule(volcengineEmbeddingPresets['doubao-embedding-vision-251215'], { providerId: 'volcengine', baseUrl: 'https://ark.cn-beijing.volces.com', path: '/api/v3/embeddings/multimodal', envelope: 'ark-single' }, config);
6
+ }
@@ -0,0 +1,21 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const bailianRerankPresets: {
3
+ readonly 'qwen3.7-text-rerank': {
4
+ readonly modelId: "qwen3.7-text-rerank";
5
+ readonly maxDocuments: 500;
6
+ readonly instructionField: "instruct";
7
+ };
8
+ readonly 'qwen3-rerank': {
9
+ readonly modelId: "qwen3-rerank";
10
+ readonly maxDocuments: 500;
11
+ readonly instructionField: "instruct";
12
+ };
13
+ readonly 'gte-rerank-v2': {
14
+ readonly modelId: "gte-rerank-v2";
15
+ readonly maxDocuments: 500;
16
+ };
17
+ };
18
+ export declare function createBailianRerankModule(config: RetrievalModuleConfig & {
19
+ baseUrl: string;
20
+ model?: keyof typeof bailianRerankPresets;
21
+ }): import("./index.js").RerankModule;
@@ -0,0 +1,14 @@
1
+ import { rerankModule } from '../retrieval/module.js';
2
+ export const bailianRerankPresets = {
3
+ 'qwen3.7-text-rerank': { modelId: 'qwen3.7-text-rerank', maxDocuments: 500, instructionField: 'instruct' },
4
+ 'qwen3-rerank': { modelId: 'qwen3-rerank', maxDocuments: 500, instructionField: 'instruct' },
5
+ 'gte-rerank-v2': { modelId: 'gte-rerank-v2', maxDocuments: 500 },
6
+ };
7
+ export function createBailianRerankModule(config) {
8
+ const model = config.model ?? 'qwen3.7-text-rerank';
9
+ return rerankModule(bailianRerankPresets[model], {
10
+ providerId: 'bailian',
11
+ path: model === 'qwen3-rerank' ? '/compatible-api/v1/reranks' : '/api/v1/services/rerank/text-rerank/text-rerank',
12
+ envelope: model === 'qwen3-rerank' ? undefined : 'bailian',
13
+ }, config);
14
+ }
@@ -0,0 +1,9 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const bigmodelRerankPresets: {
3
+ readonly rerank: {
4
+ readonly modelId: "rerank";
5
+ readonly maxDocuments: 128;
6
+ readonly maxTextCharacters: 4096;
7
+ };
8
+ };
9
+ export declare function createBigmodelRerankModule(config?: RetrievalModuleConfig): import("./index.js").RerankModule;
@@ -0,0 +1,5 @@
1
+ import { rerankModule } from '../retrieval/module.js';
2
+ export const bigmodelRerankPresets = { rerank: { modelId: 'rerank', maxDocuments: 128, maxTextCharacters: 4096 } };
3
+ export function createBigmodelRerankModule(config = {}) {
4
+ return rerankModule(bigmodelRerankPresets.rerank, { providerId: 'bigmodel', baseUrl: 'https://open.bigmodel.cn', path: '/api/paas/v4/rerank' }, config);
5
+ }
@@ -0,0 +1 @@
1
+ export type { RerankInput, RerankOutput, RerankModule, RerankPreset, RetrievalUsage, RetrievalModuleConfig } from '../retrieval/types.js';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const ppioRerankPresets: {
3
+ readonly 'baai/bge-reranker-v2-m3': {
4
+ readonly modelId: "baai/bge-reranker-v2-m3";
5
+ };
6
+ };
7
+ export declare function createPpioRerankModule(config?: RetrievalModuleConfig): import("./index.js").RerankModule;
@@ -0,0 +1,5 @@
1
+ import { rerankModule } from '../retrieval/module.js';
2
+ export const ppioRerankPresets = { 'baai/bge-reranker-v2-m3': { modelId: 'baai/bge-reranker-v2-m3' } };
3
+ export function createPpioRerankModule(config = {}) {
4
+ return rerankModule(ppioRerankPresets['baai/bge-reranker-v2-m3'], { providerId: 'ppio', baseUrl: 'https://api.ppio.com', path: '/openai/v1/rerank' }, config);
5
+ }
@@ -0,0 +1,21 @@
1
+ import type { RetrievalModuleConfig } from '../retrieval/types.js';
2
+ export declare const siliconflowRerankPresets: {
3
+ readonly 'Qwen/Qwen3-Reranker-8B': {
4
+ readonly modelId: "Qwen/Qwen3-Reranker-8B";
5
+ readonly instructionField: "instruction";
6
+ };
7
+ readonly 'Qwen/Qwen3-Reranker-4B': {
8
+ readonly modelId: "Qwen/Qwen3-Reranker-4B";
9
+ readonly instructionField: "instruction";
10
+ };
11
+ readonly 'Qwen/Qwen3-Reranker-0.6B': {
12
+ readonly modelId: "Qwen/Qwen3-Reranker-0.6B";
13
+ readonly instructionField: "instruction";
14
+ };
15
+ readonly 'BAAI/bge-reranker-v2-m3': {
16
+ readonly modelId: "BAAI/bge-reranker-v2-m3";
17
+ };
18
+ };
19
+ export declare function createSiliconflowRerankModule(config?: RetrievalModuleConfig & {
20
+ model?: keyof typeof siliconflowRerankPresets;
21
+ }): import("./index.js").RerankModule;
@@ -0,0 +1,10 @@
1
+ import { rerankModule } from '../retrieval/module.js';
2
+ export const siliconflowRerankPresets = {
3
+ 'Qwen/Qwen3-Reranker-8B': { modelId: 'Qwen/Qwen3-Reranker-8B', instructionField: 'instruction' },
4
+ 'Qwen/Qwen3-Reranker-4B': { modelId: 'Qwen/Qwen3-Reranker-4B', instructionField: 'instruction' },
5
+ 'Qwen/Qwen3-Reranker-0.6B': { modelId: 'Qwen/Qwen3-Reranker-0.6B', instructionField: 'instruction' },
6
+ 'BAAI/bge-reranker-v2-m3': { modelId: 'BAAI/bge-reranker-v2-m3' },
7
+ };
8
+ export function createSiliconflowRerankModule(config = {}) {
9
+ return rerankModule(siliconflowRerankPresets[config.model ?? 'Qwen/Qwen3-Reranker-8B'], { providerId: 'siliconflow', baseUrl: 'https://api.siliconflow.cn', path: '/v1/rerank' }, config);
10
+ }
@@ -0,0 +1,3 @@
1
+ import type { CapabilityExecutionContext } from '../types.js';
2
+ export declare function apiRoot(value: string | undefined): string;
3
+ export declare function requestJson(context: CapabilityExecutionContext, providerId: string, credentialId: string, kind: 'embedding' | 'rerank', endpoint: string, body: Record<string, unknown>): Promise<Record<string, unknown>>;
@@ -0,0 +1,48 @@
1
+ import { fetchProvider } from '../../providers/provider-fetch.js';
2
+ import { AiRuntimeError } from '../../runtime/AiRuntimeError.js';
3
+ import { invalidInput, invalidResponse, record } from './validation.js';
4
+ export function apiRoot(value) {
5
+ if (typeof value !== 'string' || !value.trim())
6
+ invalidInput('A region/workspace API baseUrl is required');
7
+ let parsed;
8
+ try {
9
+ parsed = new URL(value);
10
+ }
11
+ catch {
12
+ return invalidInput('Invalid API baseUrl');
13
+ }
14
+ if (!['http:', 'https:'].includes(parsed.protocol) || parsed.username || parsed.password || parsed.search || parsed.hash || /[{}]/.test(value)) {
15
+ invalidInput('API baseUrl must be HTTP(S), without credentials, placeholders, query or fragment');
16
+ }
17
+ return value.trim().replace(/\/+$/, '');
18
+ }
19
+ export async function requestJson(context, providerId, credentialId, kind, endpoint, body) {
20
+ context.signal.throwIfAborted();
21
+ const key = await context.runtime.credentials.get(kind, credentialId);
22
+ if (!key?.trim())
23
+ throw new AiRuntimeError('api_key_missing', `${providerId} ${kind} API key is not configured`);
24
+ context.signal.throwIfAborted();
25
+ const response = await fetchProvider(`${providerId} ${kind}`, endpoint, {
26
+ method: 'POST',
27
+ headers: { Authorization: `Bearer ${key.trim()}`, 'Content-Type': 'application/json' },
28
+ body: JSON.stringify(body),
29
+ signal: context.signal,
30
+ }, { transport: context.runtime.transport, retryPreconnectOnce: false });
31
+ // Read even error responses to release the underlying response body. Never log body content.
32
+ const responseText = await response.text();
33
+ context.signal.throwIfAborted();
34
+ if (!response.ok)
35
+ throw new AiRuntimeError('provider_error', `${providerId} ${kind} failed with HTTP ${response.status}`);
36
+ let decoded;
37
+ try {
38
+ decoded = JSON.parse(responseText);
39
+ }
40
+ catch {
41
+ return invalidResponse('Provider returned invalid JSON');
42
+ }
43
+ const raw = record(decoded, 'response');
44
+ if (raw.error || (raw.code !== undefined && raw.code !== null && raw.code !== '' && raw.code !== 0)) {
45
+ throw new AiRuntimeError('provider_error', `${providerId} ${kind} returned a provider error`);
46
+ }
47
+ return raw;
48
+ }
@@ -0,0 +1,11 @@
1
+ import type { EmbeddingModule, EmbeddingPreset, RerankModule, RerankPreset, RetrievalModuleConfig } from './types.js';
2
+ interface ProviderContract {
3
+ providerId: string;
4
+ baseUrl?: string;
5
+ path: string;
6
+ envelope?: 'bailian' | 'ark-single';
7
+ floatEncoding?: boolean;
8
+ }
9
+ export declare function embeddingModule(preset: EmbeddingPreset, provider: ProviderContract, config?: RetrievalModuleConfig): EmbeddingModule;
10
+ export declare function rerankModule(preset: RerankPreset, provider: ProviderContract, config?: RetrievalModuleConfig): RerankModule;
11
+ export {};
@@ -0,0 +1,110 @@
1
+ import { apiRoot, requestJson } from './http.js';
2
+ import { inputRecord, invalidInput, invalidResponse, positiveInteger, record, responseIndex, text, texts, usage } from './validation.js';
3
+ function descriptor(kind, modelId, providerId, moduleId) {
4
+ return {
5
+ id: moduleId ?? `${providerId}.${kind}.${modelId}`,
6
+ kind,
7
+ source: { kind: 'builtin', namespace: '@henjicc/ai-sdk' },
8
+ version: '1', providerIds: [providerId], modelId,
9
+ contract: { input: [{ kind: 'text', required: true, multiple: true }], output: [{ kind: 'structured-data', required: true }] },
10
+ operations: [kind], executionModes: ['request-response'],
11
+ };
12
+ }
13
+ async function traced(context, providerId, modelId, kind, run) {
14
+ const fields = { requestId: context.requestId, providerId, modelId };
15
+ const span = context.runtime.tracer.startSpan(`${kind}.request`, fields);
16
+ context.runtime.logger.info(`${kind} request started`, { ...fields, event: `${kind}.request.start` });
17
+ try {
18
+ const output = await run();
19
+ context.signal.throwIfAborted();
20
+ context.runtime.logger.info(`${kind} request completed`, { ...fields, event: `${kind}.request.completed` });
21
+ span.end();
22
+ return output;
23
+ }
24
+ catch (error) {
25
+ // Error details may contain provider echoes of input or credentials; log only the stage.
26
+ context.runtime.logger.error(`${kind} request failed`, { ...fields, event: `${kind}.request.failed` });
27
+ span.end();
28
+ throw error;
29
+ }
30
+ }
31
+ export function embeddingModule(preset, provider, config = {}) {
32
+ if (!preset)
33
+ invalidInput('Unknown embedding model');
34
+ const endpoint = apiRoot(config.baseUrl ?? provider.baseUrl) + provider.path;
35
+ return {
36
+ descriptor: descriptor('embedding', preset.modelId, provider.providerId, config.moduleId),
37
+ execute: (input, context) => traced(context, provider.providerId, preset.modelId, 'embedding', async () => {
38
+ const rawInput = inputRecord(input, ['texts', 'dimensions']);
39
+ const source = texts(rawInput.texts, 'texts', preset.maxBatchSize, preset.maxTextCharacters);
40
+ const body = { model: preset.modelId, input: source };
41
+ if (provider.envelope === 'ark-single')
42
+ body.input = [{ type: 'text', text: source[0] }];
43
+ if (provider.floatEncoding !== false)
44
+ body.encoding_format = 'float';
45
+ if (rawInput.dimensions !== undefined) {
46
+ const dimensions = positiveInteger(rawInput.dimensions, 'dimensions');
47
+ if (!preset.dimensions?.includes(dimensions))
48
+ invalidInput('Unsupported embedding dimensions for this model');
49
+ body.dimensions = dimensions;
50
+ }
51
+ const raw = await requestJson(context, provider.providerId, config.credentialId ?? provider.providerId, 'embedding', endpoint, body);
52
+ const data = provider.envelope === 'ark-single' ? [{ ...record(raw.data, 'data'), index: 0 }] : raw.data;
53
+ if (!Array.isArray(data) || data.length !== source.length)
54
+ invalidResponse('Embedding result count must match the input count');
55
+ const seen = new Set();
56
+ let dimensionCount;
57
+ const embeddings = data.map(value => {
58
+ const item = record(value, 'embedding');
59
+ const index = responseIndex(item.index, source.length, seen);
60
+ if (!Array.isArray(item.embedding) || item.embedding.length === 0 || !item.embedding.every(n => typeof n === 'number' && Number.isFinite(n))) {
61
+ invalidResponse('Embedding must contain a non-empty finite numeric vector');
62
+ }
63
+ const vector = item.embedding;
64
+ dimensionCount ??= vector.length;
65
+ if (vector.length !== dimensionCount || (rawInput.dimensions !== undefined && vector.length !== rawInput.dimensions))
66
+ invalidResponse('Embedding vector dimensions do not match');
67
+ return { index, vector };
68
+ }).sort((a, b) => a.index - b.index);
69
+ return { embeddings, usage: usage(raw.usage) };
70
+ }),
71
+ };
72
+ }
73
+ export function rerankModule(preset, provider, config = {}) {
74
+ if (!preset)
75
+ invalidInput('Unknown rerank model');
76
+ const endpoint = apiRoot(config.baseUrl ?? provider.baseUrl) + provider.path;
77
+ return {
78
+ descriptor: descriptor('rerank', preset.modelId, provider.providerId, config.moduleId),
79
+ execute: (input, context) => traced(context, provider.providerId, preset.modelId, 'rerank', async () => {
80
+ const rawInput = inputRecord(input, ['query', 'documents', 'topN', 'instruction']);
81
+ const query = text(rawInput.query, 'query', preset.maxTextCharacters);
82
+ const documents = texts(rawInput.documents, 'documents', preset.maxDocuments, preset.maxTextCharacters);
83
+ const params = {};
84
+ if (rawInput.topN !== undefined)
85
+ params.top_n = Math.min(positiveInteger(rawInput.topN, 'topN'), documents.length);
86
+ if (rawInput.instruction !== undefined) {
87
+ if (!preset.instructionField)
88
+ invalidInput('Instructions are not supported by this rerank model');
89
+ params[preset.instructionField] = text(rawInput.instruction, 'instruction');
90
+ }
91
+ const body = provider.envelope === 'bailian'
92
+ ? { model: preset.modelId, input: { query, documents }, parameters: params }
93
+ : { model: preset.modelId, query, documents, ...params };
94
+ const raw = await requestJson(context, provider.providerId, config.credentialId ?? provider.providerId, 'rerank', endpoint, body);
95
+ const payload = provider.envelope === 'bailian' ? record(raw.output, 'output') : raw;
96
+ if (!Array.isArray(payload.results) || payload.results.length === 0 || payload.results.length > (params.top_n ?? documents.length))
97
+ invalidResponse('Invalid rerank result count');
98
+ const seen = new Set();
99
+ const results = payload.results.map(value => {
100
+ const item = record(value, 'rerank result');
101
+ const index = responseIndex(item.index, documents.length, seen);
102
+ if (typeof item.relevance_score !== 'number' || !Number.isFinite(item.relevance_score))
103
+ invalidResponse('Invalid rerank score');
104
+ return { index, score: item.relevance_score, document: documents[index] };
105
+ }).sort((a, b) => b.score - a.score);
106
+ const meta = raw.meta === undefined ? undefined : record(raw.meta, 'meta');
107
+ return { results, usage: usage(raw.usage ?? meta?.tokens) };
108
+ }),
109
+ };
110
+ }
@@ -0,0 +1,54 @@
1
+ import type { CapabilityModule } from '../types.js';
2
+ export interface RetrievalUsage {
3
+ inputTokens?: number;
4
+ outputTokens?: number;
5
+ totalTokens?: number;
6
+ }
7
+ export interface EmbeddingInput {
8
+ texts: readonly string[];
9
+ dimensions?: number;
10
+ }
11
+ export interface EmbeddingOutput {
12
+ /** Ordered by the original input index, independent of provider response order. */
13
+ embeddings: readonly {
14
+ index: number;
15
+ vector: readonly number[];
16
+ }[];
17
+ usage?: RetrievalUsage;
18
+ }
19
+ export interface RerankInput {
20
+ query: string;
21
+ documents: readonly string[];
22
+ topN?: number;
23
+ instruction?: string;
24
+ }
25
+ export interface RerankOutput {
26
+ /** Scores are comparable only within this request. */
27
+ results: readonly {
28
+ index: number;
29
+ score: number;
30
+ document: string;
31
+ }[];
32
+ usage?: RetrievalUsage;
33
+ }
34
+ export type EmbeddingModule = CapabilityModule<EmbeddingInput, EmbeddingOutput>;
35
+ export type RerankModule = CapabilityModule<RerankInput, RerankOutput>;
36
+ export interface RetrievalModuleConfig {
37
+ /** Exact API root for the selected region/workspace; never changed by the SDK. */
38
+ baseUrl?: string;
39
+ /** Separate credentials for accounts or regions, without changing provider identity. */
40
+ credentialId?: string;
41
+ moduleId?: string;
42
+ }
43
+ export interface EmbeddingPreset {
44
+ modelId: string;
45
+ dimensions?: readonly number[];
46
+ maxBatchSize?: number;
47
+ maxTextCharacters?: number;
48
+ }
49
+ export interface RerankPreset {
50
+ modelId: string;
51
+ maxDocuments?: number;
52
+ maxTextCharacters?: number;
53
+ instructionField?: 'instruction' | 'instruct';
54
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { RetrievalUsage } from './types.js';
2
+ export declare function invalidInput(message: string): never;
3
+ export declare function invalidResponse(message: string): never;
4
+ export declare function record(value: unknown, label: string): Record<string, unknown>;
5
+ export declare function inputRecord(value: unknown, keys: readonly string[]): Record<string, unknown>;
6
+ export declare function text(value: unknown, label: string, maxCharacters?: number): string;
7
+ export declare function texts(value: unknown, label: string, maximum?: number, maxCharacters?: number): string[];
8
+ export declare function positiveInteger(value: unknown, label: string): number;
9
+ export declare function responseIndex(value: unknown, count: number, seen: Set<number>): number;
10
+ export declare function usage(value: unknown): RetrievalUsage | undefined;
@@ -0,0 +1,65 @@
1
+ import { AiRuntimeError } from '../../runtime/AiRuntimeError.js';
2
+ export function invalidInput(message) {
3
+ throw new AiRuntimeError('invalid_parameter', message);
4
+ }
5
+ export function invalidResponse(message) {
6
+ throw new AiRuntimeError('invalid_response', message);
7
+ }
8
+ export function record(value, label) {
9
+ if (!value || typeof value !== 'object' || Array.isArray(value))
10
+ invalidResponse(`${label} must be an object`);
11
+ return value;
12
+ }
13
+ export function inputRecord(value, keys) {
14
+ if (!value || typeof value !== 'object' || Array.isArray(value))
15
+ invalidInput('Input must be an object');
16
+ const result = value;
17
+ for (const key of Object.keys(result))
18
+ if (!keys.includes(key))
19
+ invalidInput(`Unsupported input field: ${key}`);
20
+ return result;
21
+ }
22
+ export function text(value, label, maxCharacters) {
23
+ if (typeof value !== 'string' || !value.trim())
24
+ invalidInput(`${label} must be non-empty text`);
25
+ if (maxCharacters !== undefined && Array.from(value).length > maxCharacters)
26
+ invalidInput(`${label} exceeds ${maxCharacters} characters`);
27
+ return value;
28
+ }
29
+ export function texts(value, label, maximum, maxCharacters) {
30
+ if (!Array.isArray(value) || value.length === 0)
31
+ invalidInput(`${label} must be a non-empty array`);
32
+ if (maximum !== undefined && value.length > maximum)
33
+ invalidInput(`${label} exceeds ${maximum} items`);
34
+ return value.map((item, index) => text(item, `${label}[${index}]`, maxCharacters));
35
+ }
36
+ export function positiveInteger(value, label) {
37
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1)
38
+ invalidInput(`${label} must be a positive integer`);
39
+ return value;
40
+ }
41
+ export function responseIndex(value, count, seen) {
42
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0 || value >= count || seen.has(value)) {
43
+ invalidResponse('Result index is missing, duplicate or outside the input range');
44
+ }
45
+ seen.add(value);
46
+ return value;
47
+ }
48
+ export function usage(value) {
49
+ if (value === undefined || value === null)
50
+ return undefined;
51
+ const raw = record(value, 'usage');
52
+ const output = {};
53
+ for (const [target, source] of [
54
+ ['inputTokens', raw.prompt_tokens ?? raw.input_tokens],
55
+ ['outputTokens', raw.completion_tokens ?? raw.output_tokens],
56
+ ['totalTokens', raw.total_tokens],
57
+ ]) {
58
+ if (source === undefined || source === null)
59
+ continue;
60
+ if (typeof source !== 'number' || !Number.isSafeInteger(source) || source < 0)
61
+ invalidResponse(`Invalid usage.${target}`);
62
+ output[target] = source;
63
+ }
64
+ return Object.keys(output).length ? output : undefined;
65
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ResolvedRuntimeContext } from '../runtime/RuntimeContext.js';
2
2
  type ExtensibleString = string & Record<never, never>;
3
- export type CapabilityKind = 'media-generation' | 'chat' | 'speech-recognition' | 'translation' | ExtensibleString;
3
+ export type CapabilityKind = 'media-generation' | 'chat' | 'speech-recognition' | 'translation' | 'embedding' | 'rerank' | ExtensibleString;
4
4
  export type CapabilityContentKind = 'text' | 'structured-data' | 'image' | 'audio' | 'video' | 'pdf' | ExtensibleString;
5
5
  export interface CapabilityValueContract {
6
6
  kind: CapabilityContentKind;
@@ -0,0 +1,2 @@
1
+ export declare const apimartGptImage25Model: import("../../index.js").ModelRuntimeDefinition;
2
+ export default apimartGptImage25Model;
@@ -0,0 +1,51 @@
1
+ import { defineModel } from '../defineModel.js';
2
+ import { GPT25_BACKGROUNDS, GPT25_EXT_RATIOS, GPT25_QUALITIES, GPT25_RATIOS, GPT25_RESOLUTIONS, gpt25Choice, gpt25Count, gpt25Images, gpt25Options, gpt25Prompt, gpt25Ratio } from '../shared/gptImage25.js';
3
+ import { gpt25OutputEstimate } from '../shared/gptImage25Pricing.js';
4
+ export const apimartGptImage25Model = defineModel({
5
+ meta: {
6
+ id: 'apimart-gpt-image-2.5', canonicalModelId: 'gpt-image-2.5', seriesId: 'gpt-image', seriesRank: 2.5,
7
+ provider: 'apimart', type: 'image',
8
+ tags: ['text-to-image', 'image-to-image', 'supports-image-editing', 'supports-multi-image', 'multi-output', 'supports-4k', 'provider-apimart'],
9
+ polling: { interval: 3000, maxAttempts: 200 },
10
+ },
11
+ inputLimits: { images: { max: 16 }, videos: { max: 0 } },
12
+ params: [
13
+ { id: 'gpt25Channel', type: 'dropdown', order: 1, default: 'ext', options: gpt25Options(['ext', 'official']) },
14
+ { id: 'gpt25Variant', type: 'dropdown', order: 2, default: 'flare', options: gpt25Options(['flare', 'sunburst']) },
15
+ { id: 'gpt25AspectRatio', type: 'dropdown', order: 3, default: 'smart', options: gpt25Options(['smart', ...GPT25_RATIOS]) },
16
+ { id: 'gpt25Resolution', type: 'dropdown', order: 4, default: '1K', options: gpt25Options(GPT25_RESOLUTIONS) },
17
+ { id: 'gpt25Quality', type: 'dropdown', order: 5, default: 'medium', options: gpt25Options(GPT25_QUALITIES), visible: { condition: p => p.gpt25Channel === 'official' } },
18
+ { id: 'gpt25Count', type: 'number', order: 6, default: 1, min: 1, max: 4, step: 1 },
19
+ { id: 'gpt25Background', type: 'dropdown', order: 7, default: 'auto', options: gpt25Options(GPT25_BACKGROUNDS), visible: { condition: p => p.gpt25Channel === 'official' } },
20
+ ],
21
+ endpoints: '/v1/images/generations',
22
+ request: { builder: params => {
23
+ const channel = gpt25Choice(params.gpt25Channel, ['ext', 'official'], 'ext');
24
+ const variant = gpt25Choice(params.gpt25Variant, ['flare', 'sunburst'], 'flare');
25
+ const resolution = gpt25Choice(params.gpt25Resolution, GPT25_RESOLUTIONS, '1K');
26
+ const body = {
27
+ model: channel === 'ext' ? 'gpt-image-2.5-ext' : `gpt-image-2.5-${variant}`,
28
+ prompt: gpt25Prompt(params), n: gpt25Count(params.gpt25Count, 4),
29
+ size: gpt25Ratio(params, params.gpt25AspectRatio, channel === 'ext' ? GPT25_EXT_RATIOS : GPT25_RATIOS),
30
+ resolution: channel === 'ext' ? resolution : resolution.toLowerCase(),
31
+ };
32
+ if (channel === 'ext')
33
+ body.version = variant;
34
+ else {
35
+ body.quality = gpt25Choice(params.gpt25Quality, GPT25_QUALITIES, 'medium');
36
+ body.background = gpt25Choice(params.gpt25Background, GPT25_BACKGROUNDS, 'auto');
37
+ }
38
+ const images = gpt25Images(params);
39
+ if (images.length)
40
+ body.image_urls = images;
41
+ return body;
42
+ } },
43
+ pricing: {
44
+ currency: '$',
45
+ calculator: params => params.gpt25Channel === 'official'
46
+ ? gpt25OutputEstimate(params, 24, 'medium')
47
+ : gpt25Count(params.gpt25Count, 4) * ({ '1K': 0.0085, '2K': 0.014, '4K': 0.021 }[gpt25Choice(params.gpt25Resolution, GPT25_RESOLUTIONS, '1K')] ?? 0.0085),
48
+ description: 'Ext按张:1K $0.0085 / 2K $0.014 / 4K $0.021;官方渠道按token,估算仅含输出,输入另计,自动质量按max预估',
49
+ },
50
+ });
51
+ export default apimartGptImage25Model;
@@ -0,0 +1,2 @@
1
+ export declare const falGptImage25Model: import("../../index.js").ModelRuntimeDefinition;
2
+ export default falGptImage25Model;