@opencode/ai 2.1.4 → 2.2.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 (269) hide show
  1. package/README.md +283 -114
  2. package/dist/ai-client.d.ts +2 -2
  3. package/dist/ai-client.js +2 -1
  4. package/dist/cache-policy.d.ts +4 -0
  5. package/dist/cache-policy.js +20 -6
  6. package/dist/decision-client.d.ts +21 -0
  7. package/dist/decision-client.js +55 -0
  8. package/dist/decision.d.ts +472 -0
  9. package/dist/decision.js +158 -0
  10. package/dist/effect.d.ts +38 -0
  11. package/dist/effect.js +27 -0
  12. package/dist/effort-updates.d.ts +2 -2
  13. package/dist/experimental/cloudflare-run-extraction.d.ts +13 -0
  14. package/dist/experimental/cloudflare-run-extraction.js +83 -0
  15. package/dist/experimental/extraction.d.ts +183 -0
  16. package/dist/experimental/extraction.js +102 -0
  17. package/dist/experimental/realtime.d.ts +7 -2
  18. package/dist/experimental/realtime.js +5 -5
  19. package/dist/experimental.d.ts +2 -3
  20. package/dist/experimental.js +1 -2
  21. package/dist/image-client.d.ts +5 -14
  22. package/dist/image-client.js +0 -1
  23. package/dist/image.d.ts +6 -176
  24. package/dist/image.js +4 -11
  25. package/dist/index.d.ts +1426 -34
  26. package/dist/index.js +127 -24
  27. package/dist/llm.d.ts +16 -1
  28. package/dist/llm.js +34 -0
  29. package/dist/media-client.d.ts +2 -1
  30. package/dist/media-model.d.ts +3 -0
  31. package/dist/media-model.js +4 -1
  32. package/dist/media.d.ts +0 -7
  33. package/dist/media.js +0 -6
  34. package/dist/protocols/alibaba-chat.d.ts +20 -0
  35. package/dist/protocols/alibaba-images.d.ts +22 -0
  36. package/dist/protocols/alibaba-images.js +77 -0
  37. package/dist/protocols/alibaba-messages.d.ts +52 -17
  38. package/dist/protocols/alibaba-responses.d.ts +6 -3
  39. package/dist/protocols/anthropic-messages.d.ts +160 -54
  40. package/dist/protocols/anthropic-messages.js +44 -13
  41. package/dist/protocols/bedrock-converse.d.ts +110 -15
  42. package/dist/protocols/bedrock-converse.js +112 -15
  43. package/dist/protocols/bedrock-event-stream.js +1 -0
  44. package/dist/protocols/bfl-images.d.ts +9 -0
  45. package/dist/protocols/bfl-images.js +17 -15
  46. package/dist/protocols/cartesia-speech.d.ts +0 -18
  47. package/dist/protocols/cloudflare-run-decisions.d.ts +9 -0
  48. package/dist/protocols/cloudflare-run-decisions.js +36 -0
  49. package/dist/protocols/cloudflare-workers-ai-images.d.ts +23 -0
  50. package/dist/protocols/cloudflare-workers-ai-images.js +80 -0
  51. package/dist/protocols/deepgram-speech.d.ts +0 -18
  52. package/dist/protocols/elevenlabs-speech.d.ts +0 -18
  53. package/dist/protocols/fal-images.d.ts +10 -1
  54. package/dist/protocols/fal-images.js +16 -25
  55. package/dist/protocols/fal-video.js +1 -1
  56. package/dist/protocols/gemini.d.ts +3 -0
  57. package/dist/protocols/gemini.js +11 -6
  58. package/dist/protocols/google-images.d.ts +2 -2
  59. package/dist/protocols/google-images.js +8 -37
  60. package/dist/protocols/google-interactions.d.ts +4 -0
  61. package/dist/protocols/google-interactions.js +12 -5
  62. package/dist/protocols/google-speech.d.ts +0 -18
  63. package/dist/protocols/google-speech.js +0 -1
  64. package/dist/protocols/google-transcription.d.ts +0 -18
  65. package/dist/protocols/google-transcription.js +0 -1
  66. package/dist/protocols/google-video.d.ts +1 -1
  67. package/dist/protocols/google-video.js +2 -7
  68. package/dist/protocols/index.d.ts +3 -0
  69. package/dist/protocols/index.js +3 -0
  70. package/dist/protocols/meta-images.d.ts +7 -1
  71. package/dist/protocols/meta-images.js +10 -8
  72. package/dist/protocols/meta-messages.d.ts +52 -17
  73. package/dist/protocols/meta-messages.js +14 -1
  74. package/dist/protocols/meta-responses.d.ts +6 -0
  75. package/dist/protocols/meta-responses.js +29 -1
  76. package/dist/protocols/open-responses.d.ts +30 -0
  77. package/dist/protocols/open-responses.js +8 -18
  78. package/dist/protocols/openai-chat.d.ts +713 -1
  79. package/dist/protocols/openai-chat.js +35 -22
  80. package/dist/protocols/openai-compatible-chat.d.ts +22 -1
  81. package/dist/protocols/openai-compatible-responses.d.ts +8 -5
  82. package/dist/protocols/openai-decisions.d.ts +22 -0
  83. package/dist/protocols/openai-decisions.js +128 -0
  84. package/dist/protocols/openai-images.d.ts +21 -24
  85. package/dist/protocols/openai-images.js +100 -34
  86. package/dist/protocols/openai-responses.d.ts +82 -24
  87. package/dist/protocols/openai-responses.js +32 -2
  88. package/dist/protocols/openai-speech.d.ts +0 -18
  89. package/dist/protocols/openai-speech.js +15 -5
  90. package/dist/protocols/openai-transcription.d.ts +0 -18
  91. package/dist/protocols/openai-transcription.js +3 -4
  92. package/dist/protocols/replicate-images.js +1 -1
  93. package/dist/protocols/runway-video.d.ts +1 -1
  94. package/dist/protocols/runway-video.js +1 -1
  95. package/dist/protocols/shared.d.ts +9 -1
  96. package/dist/protocols/shared.js +13 -2
  97. package/dist/protocols/stability-images.d.ts +5 -0
  98. package/dist/protocols/stability-images.js +4 -9
  99. package/dist/protocols/system-one.d.ts +101 -0
  100. package/dist/protocols/system-one.js +230 -0
  101. package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
  102. package/dist/protocols/utils/bedrock-cache.js +7 -6
  103. package/dist/protocols/utils/cache.d.ts +14 -3
  104. package/dist/protocols/utils/cache.js +11 -4
  105. package/dist/protocols/utils/gemini-generate-content.d.ts +3 -3
  106. package/dist/protocols/utils/gemini-generate-content.js +10 -16
  107. package/dist/protocols/utils/gemini-json-schema.d.ts +5 -0
  108. package/dist/protocols/utils/gemini-json-schema.js +3 -3
  109. package/dist/protocols/utils/image-sizing.d.ts +31 -0
  110. package/dist/protocols/utils/image-sizing.js +73 -0
  111. package/dist/protocols/utils/media-input.d.ts +4 -5
  112. package/dist/protocols/utils/media-input.js +8 -5
  113. package/dist/protocols/utils/speech-stream.d.ts +0 -1
  114. package/dist/protocols/utils/speech-stream.js +0 -1
  115. package/dist/protocols/utils/tool-schema.js +15 -5
  116. package/dist/protocols/utils/tool-stream.d.ts +9 -0
  117. package/dist/protocols/venice-chat.d.ts +19 -0
  118. package/dist/protocols/venice-chat.js +1 -1
  119. package/dist/protocols/xai-images.d.ts +1 -2
  120. package/dist/protocols/xai-images.js +9 -2
  121. package/dist/protocols/xai-responses.d.ts +10 -0
  122. package/dist/protocols/xai-responses.js +28 -2
  123. package/dist/protocols/xai-video.d.ts +1 -1
  124. package/dist/protocols/xai-video.js +11 -8
  125. package/dist/protocols/zai-chat.d.ts +21 -0
  126. package/dist/protocols/zai-images.d.ts +3 -1
  127. package/dist/protocols/zai-images.js +12 -11
  128. package/dist/protocols/zai-messages.d.ts +52 -17
  129. package/dist/provider-error.js +19 -4
  130. package/dist/providers/alibaba/images.d.ts +2 -0
  131. package/dist/providers/alibaba/images.js +1 -0
  132. package/dist/providers/alibaba.d.ts +79 -18
  133. package/dist/providers/alibaba.js +16 -8
  134. package/dist/providers/amazon-bedrock-mantle.d.ts +197 -138
  135. package/dist/providers/amazon-bedrock.d.ts +34 -14
  136. package/dist/providers/amazon-bedrock.js +11 -11
  137. package/dist/providers/anthropic-compatible.d.ts +52 -17
  138. package/dist/providers/anthropic.d.ts +52 -17
  139. package/dist/providers/azure/images.d.ts +2 -0
  140. package/dist/providers/azure/images.js +1 -0
  141. package/dist/providers/azure.d.ts +50 -9
  142. package/dist/providers/azure.js +19 -1
  143. package/dist/providers/baseten/decisions.d.ts +2 -0
  144. package/dist/providers/baseten/decisions.js +1 -0
  145. package/dist/providers/baseten.d.ts +51 -1
  146. package/dist/providers/baseten.js +41 -8
  147. package/dist/providers/cerebras.d.ts +42 -0
  148. package/dist/providers/cloudflare-ai-gateway/decisions.d.ts +2 -0
  149. package/dist/providers/cloudflare-ai-gateway/decisions.js +1 -0
  150. package/dist/providers/cloudflare-ai-gateway.d.ts +177 -43
  151. package/dist/providers/cloudflare-ai-gateway.js +32 -4
  152. package/dist/providers/cloudflare-workers-ai/decisions.d.ts +2 -0
  153. package/dist/providers/cloudflare-workers-ai/decisions.js +1 -0
  154. package/dist/providers/cloudflare-workers-ai/images.d.ts +2 -0
  155. package/dist/providers/cloudflare-workers-ai/images.js +1 -0
  156. package/dist/providers/cloudflare-workers-ai.d.ts +55 -1
  157. package/dist/providers/cloudflare-workers-ai.js +45 -9
  158. package/dist/providers/cohere.d.ts +42 -0
  159. package/dist/providers/deepinfra.d.ts +42 -0
  160. package/dist/providers/deepseek.d.ts +42 -0
  161. package/dist/providers/digitalocean/decisions.d.ts +2 -0
  162. package/dist/providers/digitalocean/decisions.js +1 -0
  163. package/dist/providers/digitalocean/images.d.ts +2 -0
  164. package/dist/providers/digitalocean/images.js +1 -0
  165. package/dist/providers/digitalocean.d.ts +72 -1
  166. package/dist/providers/digitalocean.js +39 -8
  167. package/dist/providers/fireworks.d.ts +42 -0
  168. package/dist/providers/google/images.d.ts +2 -0
  169. package/dist/providers/google/images.js +1 -0
  170. package/dist/providers/google-vertex/images.d.ts +2 -0
  171. package/dist/providers/google-vertex/images.js +1 -0
  172. package/dist/providers/google-vertex-chat.d.ts +21 -0
  173. package/dist/providers/google-vertex-messages.d.ts +52 -17
  174. package/dist/providers/google-vertex-responses.d.ts +3 -0
  175. package/dist/providers/google-vertex.d.ts +3 -1
  176. package/dist/providers/google-vertex.js +30 -13
  177. package/dist/providers/google.d.ts +5 -4
  178. package/dist/providers/google.js +15 -8
  179. package/dist/providers/groq.d.ts +42 -4
  180. package/dist/providers/groq.js +0 -6
  181. package/dist/providers/meta.d.ts +197 -138
  182. package/dist/providers/minimax.d.ts +76 -17
  183. package/dist/providers/moonshot.d.ts +76 -17
  184. package/dist/providers/openai/images.d.ts +2 -0
  185. package/dist/providers/openai/images.js +1 -0
  186. package/dist/providers/openai-compatible/images.d.ts +2 -0
  187. package/dist/providers/openai-compatible/images.js +1 -0
  188. package/dist/providers/openai-compatible-responses.d.ts +3 -0
  189. package/dist/providers/openai-compatible.d.ts +24 -1
  190. package/dist/providers/openai-compatible.js +21 -9
  191. package/dist/providers/openai-options.d.ts +3 -1
  192. package/dist/providers/openai.d.ts +46 -9
  193. package/dist/providers/openai.js +20 -4
  194. package/dist/providers/opencode/decisions.d.ts +2 -0
  195. package/dist/providers/opencode/decisions.js +1 -0
  196. package/dist/providers/opencode.d.ts +9 -10
  197. package/dist/providers/opencode.js +10 -8
  198. package/dist/providers/openrouter/decisions.d.ts +2 -0
  199. package/dist/providers/openrouter/decisions.js +1 -0
  200. package/dist/providers/openrouter/images.d.ts +2 -0
  201. package/dist/providers/openrouter/images.js +1 -0
  202. package/dist/providers/openrouter.d.ts +92 -11
  203. package/dist/providers/openrouter.js +38 -16
  204. package/dist/providers/togetherai.d.ts +42 -0
  205. package/dist/providers/typesafe-ai/decisions.d.ts +2 -0
  206. package/dist/providers/typesafe-ai/decisions.js +1 -0
  207. package/dist/providers/typesafe-ai.d.ts +9 -10
  208. package/dist/providers/typesafe-ai.js +10 -8
  209. package/dist/providers/venice.d.ts +19 -0
  210. package/dist/providers/vercel-ai-gateway/decisions.d.ts +2 -0
  211. package/dist/providers/vercel-ai-gateway/decisions.js +1 -0
  212. package/dist/providers/vercel-ai-gateway/images.d.ts +2 -0
  213. package/dist/providers/vercel-ai-gateway/images.js +1 -0
  214. package/dist/providers/vercel-ai-gateway.d.ts +10 -16
  215. package/dist/providers/vercel-ai-gateway.js +31 -85
  216. package/dist/providers/xai/images.d.ts +2 -0
  217. package/dist/providers/xai/images.js +1 -0
  218. package/dist/providers/xai.d.ts +28 -5
  219. package/dist/providers/xai.js +15 -8
  220. package/dist/providers/zai/images.d.ts +2 -0
  221. package/dist/providers/zai/images.js +1 -0
  222. package/dist/providers/zai-coding-plan.d.ts +76 -17
  223. package/dist/providers/zai.d.ts +26 -4
  224. package/dist/providers/zai.js +15 -8
  225. package/dist/route/client.d.ts +2 -2
  226. package/dist/route/client.js +26 -4
  227. package/dist/route/decision.d.ts +58 -0
  228. package/dist/route/decision.js +75 -0
  229. package/dist/route/executor.d.ts +1 -1
  230. package/dist/route/framing.d.ts +2 -0
  231. package/dist/route/index.d.ts +3 -0
  232. package/dist/route/index.js +3 -0
  233. package/dist/route/media-protocol.d.ts +1 -0
  234. package/dist/route/media-protocol.js +12 -8
  235. package/dist/route/media.d.ts +5 -1
  236. package/dist/route/media.js +6 -2
  237. package/dist/route/transport/http.js +1 -0
  238. package/dist/route/transport/index.d.ts +1 -0
  239. package/dist/schema/events.d.ts +148 -6
  240. package/dist/schema/events.js +20 -0
  241. package/dist/schema/messages.d.ts +6 -2
  242. package/dist/schema/messages.js +3 -0
  243. package/dist/schema/options.d.ts +5 -3
  244. package/dist/schema/options.js +8 -3
  245. package/dist/speech-client.d.ts +5 -14
  246. package/dist/speech-client.js +0 -1
  247. package/dist/speech.d.ts +0 -135
  248. package/dist/speech.js +2 -4
  249. package/dist/testing.d.ts +25 -24
  250. package/dist/testing.js +3 -21
  251. package/dist/transcription-client.d.ts +5 -14
  252. package/dist/transcription.d.ts +0 -135
  253. package/dist/transcription.js +1 -1
  254. package/dist/utils/media-type.js +22 -1
  255. package/dist/video-client.d.ts +5 -14
  256. package/dist/video-client.js +0 -1
  257. package/dist/video.d.ts +1 -136
  258. package/dist/video.js +3 -5
  259. package/package.json +513 -11
  260. package/dist/experimental/evaluation-client.d.ts +0 -21
  261. package/dist/experimental/evaluation-client.js +0 -64
  262. package/dist/experimental/evaluation.d.ts +0 -242
  263. package/dist/experimental/evaluation.js +0 -108
  264. package/dist/experimental/system-one.d.ts +0 -16
  265. package/dist/experimental/system-one.js +0 -135
  266. package/dist/promise.d.ts +0 -1021
  267. package/dist/promise.js +0 -101
  268. package/dist/provider.d.ts +0 -23
  269. package/dist/provider.js +0 -2
@@ -4,12 +4,13 @@ import { AlibabaMessages } from "../protocols/alibaba-messages.js";
4
4
  import { AlibabaResponses } from "../protocols/alibaba-responses.js";
5
5
  import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";
6
6
  import { Route, type RouteDefaultsInput } from "../route/client.js";
7
- import { ToolDefinition, type ModelID } from "../schema/index.js";
7
+ import { ToolDefinition, type ModelID, type ProviderOptions } from "../schema/index.js";
8
8
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
9
9
  export type Region = "ap-southeast-1" | "cn-beijing" | "cn-hongkong" | "us-east-1" | "eu-central-1" | "ap-northeast-1" | (string & {});
10
10
  export type ChatOptionsInput = AlibabaChat.OptionsInput;
11
11
  export type MessagesOptionsInput = AlibabaMessages.OptionsInput;
12
12
  export type ResponsesOptionsInput = AlibabaResponses.OptionsInput;
13
+ export type { AlibabaImageOptions } from "../protocols/alibaba-images.js";
13
14
  type Location = AtLeastOne<{
14
15
  readonly region: Region;
15
16
  /** Overrides the selected API's complete base URL, including its version prefix. */
@@ -32,6 +33,11 @@ export declare const routes: (Route<{
32
33
  readonly image_url: {
33
34
  readonly url: string;
34
35
  };
36
+ } | {
37
+ readonly type: "video_url";
38
+ readonly video_url: {
39
+ readonly url: string;
40
+ };
35
41
  } | {
36
42
  readonly type: "file";
37
43
  readonly file: {
@@ -53,6 +59,11 @@ export declare const routes: (Route<{
53
59
  readonly image_url: {
54
60
  readonly url: string;
55
61
  };
62
+ } | {
63
+ readonly type: "video_url";
64
+ readonly video_url: {
65
+ readonly url: string;
66
+ };
56
67
  } | {
57
68
  readonly type: "file";
58
69
  readonly file: {
@@ -134,7 +145,17 @@ export declare const routes: (Route<{
134
145
  } | undefined;
135
146
  readonly store?: boolean | undefined;
136
147
  readonly prompt_cache_key?: string | undefined;
148
+ readonly prompt_cache_retention?: string | undefined;
149
+ readonly prompt_cache_options?: {
150
+ readonly ttl?: string | undefined;
151
+ } | undefined;
137
152
  readonly reasoning_effort?: import("../schema/options.js").ReasoningEffort | undefined;
153
+ readonly verbosity?: import("../schema/options.js").OpenString<"high" | "low" | "medium"> | undefined;
154
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
155
+ readonly metadata?: {
156
+ readonly [x: string]: string;
157
+ } | undefined;
158
+ readonly safety_identifier?: string | undefined;
138
159
  readonly tool_stream?: boolean | undefined;
139
160
  readonly max_completion_tokens?: number | undefined;
140
161
  readonly max_tokens?: number | undefined;
@@ -184,7 +205,7 @@ export declare const routes: (Route<{
184
205
  readonly text: string;
185
206
  readonly cache_control?: {
186
207
  readonly type: "ephemeral";
187
- readonly ttl?: "1h" | "5m" | undefined;
208
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
188
209
  } | undefined;
189
210
  }[] | undefined;
190
211
  readonly messages: readonly ({
@@ -194,7 +215,7 @@ export declare const routes: (Route<{
194
215
  readonly text: string;
195
216
  readonly cache_control?: {
196
217
  readonly type: "ephemeral";
197
- readonly ttl?: "1h" | "5m" | undefined;
218
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
198
219
  } | undefined;
199
220
  } | {
200
221
  readonly type: "image";
@@ -211,11 +232,28 @@ export declare const routes: (Route<{
211
232
  };
212
233
  readonly cache_control?: {
213
234
  readonly type: "ephemeral";
214
- readonly ttl?: "1h" | "5m" | undefined;
235
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
215
236
  } | undefined;
216
237
  readonly transformations?: {
217
238
  readonly oversized_image?: "downsize" | "error" | undefined;
218
239
  } | undefined;
240
+ } | {
241
+ readonly type: "video";
242
+ readonly source: {
243
+ readonly type: "base64";
244
+ readonly media_type: string;
245
+ readonly data: string;
246
+ } | {
247
+ readonly type: "url";
248
+ readonly url: string;
249
+ } | {
250
+ readonly type: "file";
251
+ readonly file_id: string;
252
+ };
253
+ readonly cache_control?: {
254
+ readonly type: "ephemeral";
255
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
256
+ } | undefined;
219
257
  } | {
220
258
  readonly type: "document";
221
259
  readonly source: {
@@ -235,7 +273,7 @@ export declare const routes: (Route<{
235
273
  };
236
274
  readonly cache_control?: {
237
275
  readonly type: "ephemeral";
238
- readonly ttl?: "1h" | "5m" | undefined;
276
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
239
277
  } | undefined;
240
278
  readonly title?: string | undefined;
241
279
  readonly context?: string | undefined;
@@ -250,7 +288,7 @@ export declare const routes: (Route<{
250
288
  readonly text: string;
251
289
  readonly cache_control?: {
252
290
  readonly type: "ephemeral";
253
- readonly ttl?: "1h" | "5m" | undefined;
291
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
254
292
  } | undefined;
255
293
  } | {
256
294
  readonly type: "image";
@@ -267,11 +305,28 @@ export declare const routes: (Route<{
267
305
  };
268
306
  readonly cache_control?: {
269
307
  readonly type: "ephemeral";
270
- readonly ttl?: "1h" | "5m" | undefined;
308
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
271
309
  } | undefined;
272
310
  readonly transformations?: {
273
311
  readonly oversized_image?: "downsize" | "error" | undefined;
274
312
  } | undefined;
313
+ } | {
314
+ readonly type: "video";
315
+ readonly source: {
316
+ readonly type: "base64";
317
+ readonly media_type: string;
318
+ readonly data: string;
319
+ } | {
320
+ readonly type: "url";
321
+ readonly url: string;
322
+ } | {
323
+ readonly type: "file";
324
+ readonly file_id: string;
325
+ };
326
+ readonly cache_control?: {
327
+ readonly type: "ephemeral";
328
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
329
+ } | undefined;
275
330
  } | {
276
331
  readonly type: "document";
277
332
  readonly source: {
@@ -291,7 +346,7 @@ export declare const routes: (Route<{
291
346
  };
292
347
  readonly cache_control?: {
293
348
  readonly type: "ephemeral";
294
- readonly ttl?: "1h" | "5m" | undefined;
349
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
295
350
  } | undefined;
296
351
  readonly title?: string | undefined;
297
352
  readonly context?: string | undefined;
@@ -302,7 +357,7 @@ export declare const routes: (Route<{
302
357
  readonly is_error?: boolean | undefined;
303
358
  readonly cache_control?: {
304
359
  readonly type: "ephemeral";
305
- readonly ttl?: "1h" | "5m" | undefined;
360
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
306
361
  } | undefined;
307
362
  })[];
308
363
  } | {
@@ -315,7 +370,7 @@ export declare const routes: (Route<{
315
370
  readonly text: string;
316
371
  readonly cache_control?: {
317
372
  readonly type: "ephemeral";
318
- readonly ttl?: "1h" | "5m" | undefined;
373
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
319
374
  } | undefined;
320
375
  } | {
321
376
  readonly type: "thinking";
@@ -323,14 +378,14 @@ export declare const routes: (Route<{
323
378
  readonly signature: string;
324
379
  readonly cache_control?: {
325
380
  readonly type: "ephemeral";
326
- readonly ttl?: "1h" | "5m" | undefined;
381
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
327
382
  } | undefined;
328
383
  } | {
329
384
  readonly type: "redacted_thinking";
330
385
  readonly data: string;
331
386
  readonly cache_control?: {
332
387
  readonly type: "ephemeral";
333
- readonly ttl?: "1h" | "5m" | undefined;
388
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
334
389
  } | undefined;
335
390
  } | {
336
391
  readonly type: "tool_use";
@@ -339,7 +394,7 @@ export declare const routes: (Route<{
339
394
  readonly input: unknown;
340
395
  readonly cache_control?: {
341
396
  readonly type: "ephemeral";
342
- readonly ttl?: "1h" | "5m" | undefined;
397
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
343
398
  } | undefined;
344
399
  } | {
345
400
  readonly type: "server_tool_use";
@@ -348,7 +403,7 @@ export declare const routes: (Route<{
348
403
  readonly input: unknown;
349
404
  readonly cache_control?: {
350
405
  readonly type: "ephemeral";
351
- readonly ttl?: "1h" | "5m" | undefined;
406
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
352
407
  } | undefined;
353
408
  } | {
354
409
  readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
@@ -356,7 +411,7 @@ export declare const routes: (Route<{
356
411
  readonly content: unknown;
357
412
  readonly cache_control?: {
358
413
  readonly type: "ephemeral";
359
- readonly ttl?: "1h" | "5m" | undefined;
414
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
360
415
  } | undefined;
361
416
  })[];
362
417
  } | {
@@ -366,7 +421,7 @@ export declare const routes: (Route<{
366
421
  readonly text: string;
367
422
  readonly cache_control?: {
368
423
  readonly type: "ephemeral";
369
- readonly ttl?: "1h" | "5m" | undefined;
424
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
370
425
  } | undefined;
371
426
  }[];
372
427
  readonly output_config?: {
@@ -381,7 +436,7 @@ export declare const routes: (Route<{
381
436
  };
382
437
  readonly cache_control?: {
383
438
  readonly type: "ephemeral";
384
- readonly ttl?: "1h" | "5m" | undefined;
439
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
385
440
  } | undefined;
386
441
  }[] | undefined;
387
442
  readonly tool_choice?: {
@@ -409,7 +464,7 @@ export declare const routes: (Route<{
409
464
  } | undefined;
410
465
  readonly cache_control?: {
411
466
  readonly type: "ephemeral";
412
- readonly ttl?: "1h" | "5m" | undefined;
467
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
413
468
  } | undefined;
414
469
  readonly container?: string | {
415
470
  readonly id?: string | null | undefined;
@@ -422,6 +477,7 @@ export declare const routes: (Route<{
422
477
  readonly user_id?: string | null | undefined;
423
478
  } | undefined;
424
479
  readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
480
+ readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
425
481
  readonly thinking?: {
426
482
  readonly type: string;
427
483
  readonly budget_tokens?: number | undefined;
@@ -479,6 +535,9 @@ export declare const routes: (Route<{
479
535
  readonly content: readonly ({
480
536
  readonly type: "input_text";
481
537
  readonly text: string;
538
+ } | {
539
+ readonly type: "input_video";
540
+ readonly video_url: string;
482
541
  } | {
483
542
  readonly type: "input_image";
484
543
  readonly image_url: string;
@@ -667,6 +726,7 @@ export declare const configure: (input: Config) => {
667
726
  readonly previousResponseId?: string | undefined;
668
727
  readonly conversation?: string | undefined;
669
728
  }, import("../route/client.js").CompactionOperations | undefined>;
729
+ image: (id: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
670
730
  configure: typeof configure;
671
731
  };
672
732
  export declare const provider: {
@@ -676,6 +736,7 @@ export declare const provider: {
676
736
  export declare const model: ProviderPackage.Definition<Settings, ChatOptionsInput>["model"];
677
737
  export declare const messagesModel: ProviderPackage.Definition<Settings<MessagesOptionsInput>, MessagesOptionsInput>["model"];
678
738
  export declare const responsesModel: ProviderPackage.Definition<Settings<ResponsesOptionsInput>, ResponsesOptionsInput>["model"];
739
+ export declare const imageModel: (id: string, settings: Settings) => import("../image.js").ImageModel<import("./alibaba.js").AlibabaImageOptions>;
679
740
  export declare const webSearch: () => ToolDefinition;
680
741
  export declare const webExtractor: () => ToolDefinition;
681
742
  export declare const codeInterpreter: () => ToolDefinition;
@@ -1,12 +1,14 @@
1
1
  import { Struct } from "effect";
2
2
  import { AlibabaChat } from "../protocols/alibaba-chat.js";
3
+ import { AlibabaImages } from "../protocols/alibaba-images.js";
3
4
  import { AlibabaMessages } from "../protocols/alibaba-messages.js";
4
5
  import { AlibabaResponses } from "../protocols/alibaba-responses.js";
5
6
  import { AuthOptions } from "../route/auth-options.js";
6
7
  import { Route } from "../route/client.js";
7
8
  import { Endpoint } from "../route/endpoint.js";
8
9
  import { Framing } from "../route/framing.js";
9
- import { ProviderConfigurationError, ProviderID, ToolDefinition } from "../schema/index.js";
10
+ import { MediaRoute } from "../route/media.js";
11
+ import { ProviderConfigurationError, ProviderID, ToolDefinition, } from "../schema/index.js";
10
12
  export const id = ProviderID.make("alibaba");
11
13
  const hosts = new Map([
12
14
  ["ap-southeast-1", "dashscope-intl.aliyuncs.com"],
@@ -66,19 +68,25 @@ export const configure = (input) => {
66
68
  })
67
69
  .model({ id, compatibility: { requireSignature: false } });
68
70
  const responses = (id) => responsesRoute.with(common).model({ id });
69
- return { id, model: chat, chat, messages, responses, configure };
71
+ const media = MediaRoute.deployment({ ...input, baseURL: baseURL ?? `https://${host}/api/v1` }, opts.auth);
72
+ const image = (id, providerOptions) => AlibabaImages.model({ ...media, id, providerOptions });
73
+ return { id, model: chat, chat, messages, responses, image, configure };
70
74
  };
71
75
  export const provider = { id, configure };
72
- export const model = (id, input) => fromSettings(input).chat(id);
73
- export const messagesModel = (id, input) => fromSettings(input).messages(id);
74
- export const responsesModel = (id, input) => fromSettings(input).responses(id);
75
- function fromSettings(input) {
76
+ export const model = (id, input) => configure(config(input)).chat(id);
77
+ export const messagesModel = (id, input) => configure(config(input)).messages(id);
78
+ export const responsesModel = (id, input) => configure(config(input)).responses(id);
79
+ export const imageModel = (id, settings) => {
80
+ const input = config(settings);
81
+ return configure(input).image(id, input.providerOptions);
82
+ };
83
+ function config(input) {
76
84
  const { body, ...rest } = input;
77
- return configure({
85
+ return {
78
86
  ...rest,
79
87
  http: body === undefined ? undefined : { body },
80
88
  providerOptions: Struct.omit(rest, ["apiKey", "baseURL", "headers", "region", "workspaceID"]),
81
- });
89
+ };
82
90
  }
83
91
  export const webSearch = () => hostedTool("web_search", "Search the web with Alibaba's hosted search tool.");
84
92
  export const webExtractor = () => hostedTool("web_extractor", "Extract web page content with Alibaba's hosted tool.");