@opencode/ai 2.2.4 → 2.2.6

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 (264) hide show
  1. package/README.md +133 -69
  2. package/dist/cache-policy.d.ts +1 -1
  3. package/dist/cache-policy.js +16 -4
  4. package/dist/decision-client.d.ts +3 -3
  5. package/dist/decision.d.ts +20 -125
  6. package/dist/decision.js +25 -15
  7. package/dist/effect.d.ts +4 -15
  8. package/dist/effect.js +2 -6
  9. package/dist/effort-updates.d.ts +3 -3
  10. package/dist/effort-updates.js +2 -2
  11. package/dist/experimental/cloudflare-run-extraction.d.ts +7 -3
  12. package/dist/experimental/cloudflare-run-extraction.js +4 -1
  13. package/dist/experimental/extraction.d.ts +10 -40
  14. package/dist/experimental/extraction.js +14 -13
  15. package/dist/experimental.d.ts +8 -8
  16. package/dist/experimental.js +4 -4
  17. package/dist/generation.d.ts +0 -2
  18. package/dist/generation.js +2 -2
  19. package/dist/image-client.d.ts +13 -7
  20. package/dist/image-client.js +1 -1
  21. package/dist/image.d.ts +357 -464
  22. package/dist/image.js +17 -15
  23. package/dist/index.d.ts +28 -465
  24. package/dist/index.js +18 -17
  25. package/dist/llm.d.ts +65 -266
  26. package/dist/llm.js +101 -92
  27. package/dist/loop.d.ts +38 -0
  28. package/dist/loop.js +136 -0
  29. package/dist/media-model.d.ts +1 -1
  30. package/dist/media-model.js +8 -6
  31. package/dist/media.d.ts +9 -0
  32. package/dist/media.js +37 -2
  33. package/dist/protocols/alibaba-chat.d.ts +5 -1
  34. package/dist/protocols/alibaba-chat.js +3 -3
  35. package/dist/protocols/alibaba-images.d.ts +2 -2
  36. package/dist/protocols/alibaba-messages.js +3 -3
  37. package/dist/protocols/alibaba-responses.js +8 -20
  38. package/dist/protocols/anthropic-messages.d.ts +1 -1
  39. package/dist/protocols/anthropic-messages.js +57 -185
  40. package/dist/protocols/assemblyai-transcription.d.ts +2 -2
  41. package/dist/protocols/bedrock-converse.js +11 -22
  42. package/dist/protocols/cartesia-speech.d.ts +2 -2
  43. package/dist/protocols/cloudflare-workers-ai-images.d.ts +2 -2
  44. package/dist/protocols/cohere-chat.js +9 -12
  45. package/dist/protocols/deepgram-speech.d.ts +2 -2
  46. package/dist/protocols/deepgram-transcription.d.ts +2 -2
  47. package/dist/protocols/elevenlabs-speech.d.ts +2 -2
  48. package/dist/protocols/elevenlabs-transcription.d.ts +2 -2
  49. package/dist/protocols/gemini.d.ts +3 -0
  50. package/dist/protocols/gemini.js +56 -89
  51. package/dist/protocols/google-images.d.ts +2 -2
  52. package/dist/protocols/google-interactions.d.ts +3 -4
  53. package/dist/protocols/google-interactions.js +54 -32
  54. package/dist/protocols/google-speech.d.ts +2 -2
  55. package/dist/protocols/google-transcription.d.ts +2 -2
  56. package/dist/protocols/google-video.d.ts +2 -2
  57. package/dist/protocols/meta-images.d.ts +2 -2
  58. package/dist/protocols/meta-responses.js +26 -23
  59. package/dist/protocols/minimax-images.d.ts +2 -2
  60. package/dist/protocols/mistral-chat.js +14 -20
  61. package/dist/protocols/open-responses-channel.js +6 -19
  62. package/dist/protocols/open-responses-continuation.d.ts +1 -5
  63. package/dist/protocols/open-responses-continuation.js +1 -3
  64. package/dist/protocols/open-responses.d.ts +1 -21
  65. package/dist/protocols/open-responses.js +10 -15
  66. package/dist/protocols/openai-chat.d.ts +3 -23
  67. package/dist/protocols/openai-chat.js +26 -47
  68. package/dist/protocols/openai-compatible-chat.d.ts +1 -1
  69. package/dist/protocols/openai-compatible-responses.d.ts +2 -2
  70. package/dist/protocols/openai-compatible-responses.js +1 -1
  71. package/dist/protocols/openai-decisions.js +1 -1
  72. package/dist/protocols/openai-images.d.ts +2 -2
  73. package/dist/protocols/openai-responses.js +10 -29
  74. package/dist/protocols/openai-speech.d.ts +2 -2
  75. package/dist/protocols/openai-transcription.d.ts +2 -2
  76. package/dist/protocols/runway-video.d.ts +2 -2
  77. package/dist/protocols/shared.d.ts +1 -4
  78. package/dist/protocols/shared.js +13 -11
  79. package/dist/protocols/system-one.d.ts +4 -4
  80. package/dist/protocols/utils/bedrock-cache.js +2 -5
  81. package/dist/protocols/utils/bedrock-media.d.ts +0 -3
  82. package/dist/protocols/utils/cache.d.ts +3 -0
  83. package/dist/protocols/utils/cache.js +15 -2
  84. package/dist/protocols/utils/image-sizing.d.ts +1 -1
  85. package/dist/protocols/utils/responses-checkpoint.js +1 -1
  86. package/dist/protocols/utils/responses-compaction.d.ts +1 -1
  87. package/dist/protocols/utils/responses-compaction.js +6 -5
  88. package/dist/protocols/utils/responses-hosted-tools.d.ts +97 -1
  89. package/dist/protocols/utils/responses-hosted-tools.js +31 -0
  90. package/dist/protocols/utils/tool-stream.d.ts +5 -271
  91. package/dist/protocols/utils/tool-stream.js +3 -13
  92. package/dist/protocols/venice-chat.d.ts +3 -1
  93. package/dist/protocols/venice-chat.js +4 -4
  94. package/dist/protocols/xai-images.d.ts +2 -2
  95. package/dist/protocols/xai-responses.js +5 -25
  96. package/dist/protocols/xai-video.d.ts +2 -2
  97. package/dist/protocols/zai-chat.d.ts +5 -1
  98. package/dist/protocols/zai-chat.js +1 -1
  99. package/dist/protocols/zai-images.d.ts +2 -2
  100. package/dist/protocols/zai-messages.js +3 -3
  101. package/dist/provider-error.d.ts +0 -1
  102. package/dist/provider-error.js +9 -80
  103. package/dist/providers/alibaba.d.ts +67 -4
  104. package/dist/providers/alibaba.js +6 -1
  105. package/dist/providers/amazon-bedrock-mantle.d.ts +6 -3
  106. package/dist/providers/amazon-bedrock-mantle.js +6 -3
  107. package/dist/providers/amazon-bedrock.d.ts +6 -7
  108. package/dist/providers/amazon-bedrock.js +1 -1
  109. package/dist/providers/anthropic-compatible.d.ts +7 -8
  110. package/dist/providers/anthropic-compatible.js +2 -5
  111. package/dist/providers/anthropic.d.ts +8 -9
  112. package/dist/providers/anthropic.js +2 -7
  113. package/dist/providers/assemblyai.d.ts +2 -2
  114. package/dist/providers/assemblyai.js +2 -7
  115. package/dist/providers/azure/messages.d.ts +2 -0
  116. package/dist/providers/azure/messages.js +1 -0
  117. package/dist/providers/azure.d.ts +322 -7
  118. package/dist/providers/azure.js +25 -9
  119. package/dist/providers/baseten.d.ts +5 -5
  120. package/dist/providers/baseten.js +7 -21
  121. package/dist/providers/cartesia.d.ts +1 -1
  122. package/dist/providers/cerebras.d.ts +5 -5
  123. package/dist/providers/cerebras.js +4 -15
  124. package/dist/providers/cloudflare-ai-gateway.d.ts +21 -13
  125. package/dist/providers/cloudflare-ai-gateway.js +28 -40
  126. package/dist/providers/cloudflare-shared.d.ts +9 -0
  127. package/dist/providers/cloudflare-shared.js +25 -0
  128. package/dist/providers/cloudflare-workers-ai.d.ts +4 -4
  129. package/dist/providers/cloudflare-workers-ai.js +4 -20
  130. package/dist/providers/cohere/chat.js +2 -7
  131. package/dist/providers/cohere.d.ts +6 -5
  132. package/dist/providers/cohere.js +7 -13
  133. package/dist/providers/deepgram.d.ts +2 -2
  134. package/dist/providers/deepgram.js +2 -7
  135. package/dist/providers/deepinfra.d.ts +5 -5
  136. package/dist/providers/deepinfra.js +5 -13
  137. package/dist/providers/deepseek.d.ts +5 -5
  138. package/dist/providers/deepseek.js +3 -14
  139. package/dist/providers/digitalocean.d.ts +8 -5
  140. package/dist/providers/digitalocean.js +13 -14
  141. package/dist/providers/elevenlabs.d.ts +2 -2
  142. package/dist/providers/elevenlabs.js +2 -7
  143. package/dist/providers/fireworks.d.ts +5 -5
  144. package/dist/providers/fireworks.js +4 -15
  145. package/dist/providers/google/interactions.d.ts +1 -1
  146. package/dist/providers/google/interactions.js +2 -7
  147. package/dist/providers/google-vertex-chat.d.ts +3 -3
  148. package/dist/providers/google-vertex-chat.js +3 -29
  149. package/dist/providers/google-vertex-interactions.d.ts +3 -3
  150. package/dist/providers/google-vertex-messages.d.ts +3 -3
  151. package/dist/providers/google-vertex-messages.js +3 -29
  152. package/dist/providers/google-vertex-mistral.d.ts +3 -3
  153. package/dist/providers/google-vertex-mistral.js +3 -29
  154. package/dist/providers/google-vertex-responses.d.ts +3 -3
  155. package/dist/providers/google-vertex-responses.js +4 -30
  156. package/dist/providers/google-vertex-shared.d.ts +31 -0
  157. package/dist/providers/google-vertex-shared.js +25 -0
  158. package/dist/providers/google-vertex.d.ts +3 -3
  159. package/dist/providers/google.d.ts +15 -13
  160. package/dist/providers/google.js +9 -19
  161. package/dist/providers/groq.d.ts +5 -5
  162. package/dist/providers/groq.js +4 -15
  163. package/dist/providers/meta.d.ts +5 -5
  164. package/dist/providers/meta.js +10 -24
  165. package/dist/providers/minimax/chat.js +2 -7
  166. package/dist/providers/minimax/responses.js +2 -7
  167. package/dist/providers/minimax.d.ts +5 -5
  168. package/dist/providers/minimax.js +11 -23
  169. package/dist/providers/mistral.d.ts +10 -11
  170. package/dist/providers/mistral.js +3 -14
  171. package/dist/providers/moonshot/messages.js +2 -7
  172. package/dist/providers/moonshot/responses.js +2 -7
  173. package/dist/providers/moonshot.d.ts +5 -5
  174. package/dist/providers/moonshot.js +4 -16
  175. package/dist/providers/openai-compatible-responses.d.ts +6 -7
  176. package/dist/providers/openai-compatible-responses.js +2 -8
  177. package/dist/providers/openai-compatible.d.ts +6 -7
  178. package/dist/providers/openai-compatible.js +4 -10
  179. package/dist/providers/openai.d.ts +4 -4
  180. package/dist/providers/openai.js +3 -3
  181. package/dist/providers/opencode.d.ts +4 -4
  182. package/dist/providers/opencode.js +6 -2
  183. package/dist/providers/openrouter.d.ts +8 -5
  184. package/dist/providers/openrouter.js +16 -24
  185. package/dist/providers/runway.d.ts +1 -1
  186. package/dist/providers/settings.d.ts +40 -0
  187. package/dist/providers/settings.js +19 -0
  188. package/dist/providers/togetherai.d.ts +5 -5
  189. package/dist/providers/togetherai.js +5 -15
  190. package/dist/providers/typesafe-ai.d.ts +4 -4
  191. package/dist/providers/typesafe-ai.js +6 -2
  192. package/dist/providers/venice.d.ts +4 -4
  193. package/dist/providers/venice.js +6 -2
  194. package/dist/providers/vercel-ai-gateway.d.ts +5 -5
  195. package/dist/providers/vercel-ai-gateway.js +15 -28
  196. package/dist/providers/xai.d.ts +4 -4
  197. package/dist/providers/xai.js +4 -12
  198. package/dist/providers/zai-coding-plan/messages.js +2 -7
  199. package/dist/providers/zai-coding-plan/responses.js +2 -7
  200. package/dist/providers/zai-coding-plan.d.ts +5 -5
  201. package/dist/providers/zai-coding-plan.js +8 -15
  202. package/dist/providers/zai.d.ts +5 -5
  203. package/dist/providers/zai.js +10 -22
  204. package/dist/public.d.ts +12 -0
  205. package/dist/public.js +5 -0
  206. package/dist/route/auth-options.d.ts +9 -5
  207. package/dist/route/auth-options.js +10 -7
  208. package/dist/route/client.d.ts +50 -37
  209. package/dist/route/client.js +42 -53
  210. package/dist/route/decision.d.ts +8 -8
  211. package/dist/route/decision.js +3 -3
  212. package/dist/route/executor.d.ts +5 -0
  213. package/dist/route/executor.js +10 -0
  214. package/dist/route/index.d.ts +5 -7
  215. package/dist/route/index.js +1 -1
  216. package/dist/route/media.d.ts +7 -11
  217. package/dist/route/media.js +22 -26
  218. package/dist/route/transport/http.js +6 -5
  219. package/dist/route/transport/websocket.js +7 -1
  220. package/dist/schema/errors.d.ts +16 -17
  221. package/dist/schema/errors.js +63 -12
  222. package/dist/schema/events.d.ts +2563 -2954
  223. package/dist/schema/events.js +54 -109
  224. package/dist/schema/messages.d.ts +194 -137
  225. package/dist/schema/messages.js +66 -83
  226. package/dist/schema/options.d.ts +112 -65
  227. package/dist/schema/options.js +52 -101
  228. package/dist/speech-client.d.ts +7 -7
  229. package/dist/speech.d.ts +306 -316
  230. package/dist/speech.js +16 -14
  231. package/dist/testing.d.ts +31 -175
  232. package/dist/testing.js +60 -5
  233. package/dist/tool-history.d.ts +1 -1
  234. package/dist/tool-history.js +3 -10
  235. package/dist/tool-runtime.d.ts +9 -2
  236. package/dist/tool-runtime.js +17 -31
  237. package/dist/tool.d.ts +39 -43
  238. package/dist/tool.js +16 -26
  239. package/dist/transcription-client.d.ts +7 -7
  240. package/dist/transcription.d.ts +314 -265
  241. package/dist/transcription.js +16 -14
  242. package/dist/utils/provider-codes.d.ts +3 -0
  243. package/dist/utils/provider-codes.js +41 -0
  244. package/dist/video-client.d.ts +7 -7
  245. package/dist/video-client.js +1 -1
  246. package/dist/video.d.ts +269 -287
  247. package/dist/video.js +16 -14
  248. package/package.json +9 -9
  249. package/dist/experimental/testing.d.ts +0 -3
  250. package/dist/experimental/testing.js +0 -3
  251. package/dist/testing/decision.d.ts +0 -16
  252. package/dist/testing/decision.js +0 -20
  253. package/dist/testing/image.d.ts +0 -14
  254. package/dist/testing/image.js +0 -12
  255. package/dist/testing/media.d.ts +0 -18
  256. package/dist/testing/media.js +0 -36
  257. package/dist/testing/script.d.ts +0 -28
  258. package/dist/testing/script.js +0 -60
  259. package/dist/testing/speech.d.ts +0 -14
  260. package/dist/testing/speech.js +0 -12
  261. package/dist/testing/transcription.d.ts +0 -14
  262. package/dist/testing/transcription.js +0 -12
  263. package/dist/testing/video.d.ts +0 -14
  264. package/dist/testing/video.js +0 -12
@@ -1,25 +1,27 @@
1
1
  import { type AtLeastOne, type ProviderAuthOption } from "../route/auth-options.js";
2
- import type { Route, RouteDefaultsInput, CompactionOperations } from "../route/client.js";
2
+ import type { Route, CompactionOperations } from "../route/client.js";
3
3
  import type { ProviderPackage } from "../provider-package.js";
4
- import { type ModelID, type ProviderOptions } from "../schema/index.js";
4
+ import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
5
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
5
6
  import { type OpenAIProviderOptionsInput } from "./openai-options.js";
6
7
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
8
  type AzureURL = AtLeastOne<{
8
9
  readonly resourceName: string;
9
10
  readonly baseURL: string;
10
11
  }>;
11
- export type Config = AzureURL & RouteDefaultsInput & ProviderAuthOption<"optional"> & {
12
+ export type Config = AzureURL & RequestOptions & ProviderAuthOption<"optional"> & {
12
13
  readonly apiVersion?: string;
13
14
  readonly queryParams?: Record<string, string>;
14
15
  readonly useDeploymentBasedUrls?: boolean;
15
- readonly providerOptions?: OpenAIProviderOptionsInput;
16
+ readonly providerOptions?: OpenAIProviderOptionsInput | AnthropicMessages.ProviderOptionsInput;
16
17
  };
17
- export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & AzureURL & {
18
- readonly apiKey?: string;
18
+ export type Settings<Options = OpenAIProviderOptionsInput> = ProviderPackage.Settings & Options & AzureURL & {
19
+ readonly apiKey?: string | false;
19
20
  readonly apiVersion?: string;
20
21
  readonly queryParams?: Readonly<Record<string, string>>;
21
22
  readonly useDeploymentBasedUrls?: boolean;
22
23
  };
24
+ export type MessagesSettings = Settings<AnthropicMessages.ProviderOptionsInput>;
23
25
  declare const responsesRoute: Route<{
24
26
  readonly model: string;
25
27
  readonly input: readonly ({
@@ -253,6 +255,313 @@ declare const responsesRoute: Route<{
253
255
  endpoint: import("../route/client.js").CompactOperation;
254
256
  }>;
255
257
  export declare const routes: (Route<{
258
+ readonly context_management?: {
259
+ readonly edits: readonly {
260
+ readonly type: "compact_20260112";
261
+ readonly trigger?: {
262
+ readonly type: "input_tokens";
263
+ readonly value: number;
264
+ } | undefined;
265
+ readonly pause_after_compaction?: boolean | undefined;
266
+ readonly instructions?: string | undefined;
267
+ }[];
268
+ } | undefined;
269
+ readonly model: string;
270
+ readonly system?: readonly {
271
+ readonly type: "text";
272
+ readonly text: string;
273
+ readonly cache_control?: {
274
+ readonly type: "ephemeral";
275
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
276
+ } | undefined;
277
+ }[] | undefined;
278
+ readonly messages: readonly ({
279
+ readonly role: "user";
280
+ readonly content: readonly ({
281
+ readonly type: "text";
282
+ readonly text: string;
283
+ readonly cache_control?: {
284
+ readonly type: "ephemeral";
285
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
286
+ } | undefined;
287
+ } | {
288
+ readonly type: "image";
289
+ readonly source: {
290
+ readonly type: "base64";
291
+ readonly media_type: string;
292
+ readonly data: string;
293
+ } | {
294
+ readonly type: "url";
295
+ readonly url: string;
296
+ } | {
297
+ readonly type: "file";
298
+ readonly file_id: string;
299
+ };
300
+ readonly cache_control?: {
301
+ readonly type: "ephemeral";
302
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
303
+ } | undefined;
304
+ readonly transformations?: {
305
+ readonly oversized_image?: "downsize" | "error" | undefined;
306
+ } | undefined;
307
+ } | {
308
+ readonly type: "video";
309
+ readonly source: {
310
+ readonly type: "base64";
311
+ readonly media_type: string;
312
+ readonly data: string;
313
+ } | {
314
+ readonly type: "url";
315
+ readonly url: string;
316
+ } | {
317
+ readonly type: "file";
318
+ readonly file_id: string;
319
+ };
320
+ readonly cache_control?: {
321
+ readonly type: "ephemeral";
322
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
323
+ } | undefined;
324
+ } | {
325
+ readonly type: "document";
326
+ readonly source: {
327
+ readonly type: "base64";
328
+ readonly media_type: "application/pdf";
329
+ readonly data: string;
330
+ } | {
331
+ readonly type: "text";
332
+ readonly media_type: "text/plain";
333
+ readonly data: string;
334
+ } | {
335
+ readonly type: "url";
336
+ readonly url: string;
337
+ } | {
338
+ readonly type: "file";
339
+ readonly file_id: string;
340
+ };
341
+ readonly cache_control?: {
342
+ readonly type: "ephemeral";
343
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
344
+ } | undefined;
345
+ readonly title?: string | undefined;
346
+ readonly context?: string | undefined;
347
+ readonly citations?: {
348
+ readonly enabled: boolean;
349
+ } | undefined;
350
+ } | {
351
+ readonly type: "tool_result";
352
+ readonly tool_use_id: string;
353
+ readonly content: string | readonly ({
354
+ readonly type: "text";
355
+ readonly text: string;
356
+ readonly cache_control?: {
357
+ readonly type: "ephemeral";
358
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
359
+ } | undefined;
360
+ } | {
361
+ readonly type: "image";
362
+ readonly source: {
363
+ readonly type: "base64";
364
+ readonly media_type: string;
365
+ readonly data: string;
366
+ } | {
367
+ readonly type: "url";
368
+ readonly url: string;
369
+ } | {
370
+ readonly type: "file";
371
+ readonly file_id: string;
372
+ };
373
+ readonly cache_control?: {
374
+ readonly type: "ephemeral";
375
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
376
+ } | undefined;
377
+ readonly transformations?: {
378
+ readonly oversized_image?: "downsize" | "error" | undefined;
379
+ } | undefined;
380
+ } | {
381
+ readonly type: "video";
382
+ readonly source: {
383
+ readonly type: "base64";
384
+ readonly media_type: string;
385
+ readonly data: string;
386
+ } | {
387
+ readonly type: "url";
388
+ readonly url: string;
389
+ } | {
390
+ readonly type: "file";
391
+ readonly file_id: string;
392
+ };
393
+ readonly cache_control?: {
394
+ readonly type: "ephemeral";
395
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
396
+ } | undefined;
397
+ } | {
398
+ readonly type: "document";
399
+ readonly source: {
400
+ readonly type: "base64";
401
+ readonly media_type: "application/pdf";
402
+ readonly data: string;
403
+ } | {
404
+ readonly type: "text";
405
+ readonly media_type: "text/plain";
406
+ readonly data: string;
407
+ } | {
408
+ readonly type: "url";
409
+ readonly url: string;
410
+ } | {
411
+ readonly type: "file";
412
+ readonly file_id: string;
413
+ };
414
+ readonly cache_control?: {
415
+ readonly type: "ephemeral";
416
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
417
+ } | undefined;
418
+ readonly title?: string | undefined;
419
+ readonly context?: string | undefined;
420
+ readonly citations?: {
421
+ readonly enabled: boolean;
422
+ } | undefined;
423
+ })[];
424
+ readonly is_error?: boolean | undefined;
425
+ readonly cache_control?: {
426
+ readonly type: "ephemeral";
427
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
428
+ } | undefined;
429
+ })[];
430
+ } | {
431
+ readonly role: "assistant";
432
+ readonly content: readonly ({
433
+ readonly type: "compaction";
434
+ readonly content: string | null;
435
+ } | {
436
+ readonly type: "text";
437
+ readonly text: string;
438
+ readonly cache_control?: {
439
+ readonly type: "ephemeral";
440
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
441
+ } | undefined;
442
+ } | {
443
+ readonly type: "thinking";
444
+ readonly thinking: string;
445
+ readonly signature: string;
446
+ readonly cache_control?: {
447
+ readonly type: "ephemeral";
448
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
449
+ } | undefined;
450
+ } | {
451
+ readonly type: "redacted_thinking";
452
+ readonly data: string;
453
+ readonly cache_control?: {
454
+ readonly type: "ephemeral";
455
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
456
+ } | undefined;
457
+ } | {
458
+ readonly type: "tool_use";
459
+ readonly id: string;
460
+ readonly name: string;
461
+ readonly input: unknown;
462
+ readonly cache_control?: {
463
+ readonly type: "ephemeral";
464
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
465
+ } | undefined;
466
+ } | {
467
+ readonly type: "server_tool_use";
468
+ readonly id: string;
469
+ readonly name: string;
470
+ readonly input: unknown;
471
+ readonly cache_control?: {
472
+ readonly type: "ephemeral";
473
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
474
+ } | undefined;
475
+ } | {
476
+ readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
477
+ readonly tool_use_id: string;
478
+ readonly content: unknown;
479
+ readonly cache_control?: {
480
+ readonly type: "ephemeral";
481
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
482
+ } | undefined;
483
+ })[];
484
+ } | {
485
+ readonly role: "system";
486
+ readonly content: readonly {
487
+ readonly type: "text";
488
+ readonly text: string;
489
+ readonly cache_control?: {
490
+ readonly type: "ephemeral";
491
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
492
+ } | undefined;
493
+ }[];
494
+ readonly output_config?: {
495
+ readonly effort: string;
496
+ } | undefined;
497
+ })[];
498
+ readonly tools?: readonly {
499
+ readonly name: string;
500
+ readonly description: string;
501
+ readonly input_schema: {
502
+ readonly [x: string]: unknown;
503
+ };
504
+ readonly cache_control?: {
505
+ readonly type: "ephemeral";
506
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
507
+ } | undefined;
508
+ }[] | undefined;
509
+ readonly tool_choice?: {
510
+ readonly type: "any" | "auto" | "none";
511
+ readonly disable_parallel_tool_use?: boolean | undefined;
512
+ } | {
513
+ readonly type: "tool";
514
+ readonly name: string;
515
+ readonly disable_parallel_tool_use?: boolean | undefined;
516
+ } | undefined;
517
+ readonly stream: true;
518
+ readonly max_tokens: number;
519
+ readonly temperature?: number | undefined;
520
+ readonly top_p?: number | undefined;
521
+ readonly top_k?: number | undefined;
522
+ readonly stop_sequences?: readonly string[] | undefined;
523
+ readonly thinking?: {
524
+ readonly type: "between_tools" | "disabled";
525
+ } | {
526
+ readonly display?: import("../schema/options.js").OpenString<"omitted" | "summarized"> | undefined;
527
+ readonly block_binding?: {
528
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"drop_block" | "error"> | undefined;
529
+ } | undefined;
530
+ readonly type: "enabled";
531
+ readonly budget_tokens: number;
532
+ } | {
533
+ readonly display?: import("../schema/options.js").OpenString<"omitted" | "summarized"> | undefined;
534
+ readonly block_binding?: {
535
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"drop_block" | "error"> | undefined;
536
+ } | undefined;
537
+ readonly type: "adaptive";
538
+ } | undefined;
539
+ readonly output_config?: {
540
+ readonly effort?: string | undefined;
541
+ readonly format?: {
542
+ readonly type: "json_schema";
543
+ readonly schema: {
544
+ readonly [x: string]: unknown;
545
+ };
546
+ } | null | undefined;
547
+ } | undefined;
548
+ readonly cache_control?: {
549
+ readonly type: "ephemeral";
550
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
551
+ } | undefined;
552
+ readonly container?: string | {
553
+ readonly id?: string | null | undefined;
554
+ readonly skills?: readonly {
555
+ readonly [x: string]: unknown;
556
+ }[] | null | undefined;
557
+ } | null | undefined;
558
+ readonly inference_geo?: string | null | undefined;
559
+ readonly metadata?: {
560
+ readonly user_id?: string | null | undefined;
561
+ } | undefined;
562
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
563
+ readonly speed?: import("../schema/options.js").OpenString<"fast" | "standard"> | undefined;
564
+ }, import("../route/transport/http.js").HttpPrepared<string>, CompactionOperations | undefined> | Route<{
256
565
  readonly model: string;
257
566
  readonly messages: readonly ({
258
567
  readonly role: "system";
@@ -666,6 +975,7 @@ export declare const configure: (input: Config) => {
666
975
  endpoint: import("../route/client.js").CompactOperation;
667
976
  }>;
668
977
  chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, CompactionOperations | undefined>;
978
+ messages: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.OptionsInput, CompactionOperations | undefined>;
669
979
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
670
980
  configure: typeof configure;
671
981
  };
@@ -675,8 +985,13 @@ export declare const provider: {
675
985
  };
676
986
  export declare const responsesModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput, typeof responsesRoute.compact>;
677
987
  export declare const chatModel: ProviderPackage.Model<Settings, OpenAIProviderOptionsInput>;
988
+ export declare const messagesModel: ProviderPackage.Model<MessagesSettings, AnthropicMessages.ProviderOptionsInput>;
678
989
  export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
679
- export declare const model: ProviderPackage.Model<Settings, import("./openai-options.js").OpenAIOptionsInput, {
990
+ export declare const model: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, {
991
+ endpoint: import("../route/client.js").CompactOperation;
992
+ }>;
993
+ export declare const responses: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, {
680
994
  endpoint: import("../route/client.js").CompactOperation;
681
995
  }>;
996
+ export declare const chat: ProviderPackage.Model<Settings<import("./openai-options.js").OpenAIOptionsInput>, import("./openai-options.js").OpenAIOptionsInput, CompactionOperations | undefined>;
682
997
  export {};
@@ -1,8 +1,9 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import {} from "../route/auth-options.js";
2
+ import { AuthOptions } from "../route/auth-options.js";
3
3
  import { Endpoint } from "../route/endpoint.js";
4
4
  import { MediaRoute } from "../route/media.js";
5
- import { HttpOptions, ProviderConfigurationError, ProviderID, mergeHttpOptions, } from "../schema/index.js";
5
+ import { ProviderConfigurationError, ProviderID, } from "../schema/index.js";
6
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
6
7
  import { OpenAIImages } from "../protocols/openai-images.js";
7
8
  import * as OpenAIChat from "../protocols/openai-chat.js";
8
9
  import * as OpenAIResponses from "../protocols/openai-responses.js";
@@ -39,7 +40,10 @@ const chatRoute = OpenAIChat.route.with({
39
40
  provider: id,
40
41
  auth: routeAuth,
41
42
  });
42
- export const routes = [responsesRoute, chatRoute];
43
+ // Claude on Foundry serves Anthropic Messages under the resource's `services.ai.azure.com` host and accepts the
44
+ // resource key as `x-api-key`; it rejects `api-key`.
45
+ const messagesRoute = AnthropicMessages.route.with({ id: "azure-anthropic-messages", provider: id });
46
+ export const routes = [responsesRoute, chatRoute, messagesRoute];
43
47
  const defaults = (input) => {
44
48
  const { apiKey: _, apiVersion: _apiVersion, resourceName: _resourceName, useDeploymentBasedUrls: _useDeploymentBasedUrls, baseURL: _baseURL, queryParams: _queryParams, ...rest } = input;
45
49
  if ("auth" in rest) {
@@ -48,12 +52,10 @@ const defaults = (input) => {
48
52
  }
49
53
  return rest;
50
54
  };
51
- const auth = (input) => {
55
+ const auth = (input, header = "api-key") => {
52
56
  if ("auth" in input && input.auth)
53
57
  return input.auth;
54
- return Auth.remove("authorization").andThen(Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey")
55
- .orElse(Auth.config("AZURE_OPENAI_API_KEY"))
56
- .pipe(Auth.header("api-key")));
58
+ return Auth.remove("authorization").andThen(AuthOptions.apiKey(input, "AZURE_OPENAI_API_KEY", Auth.header(header)));
57
59
  };
58
60
  const configuredRoute = (route, input, modelID) => route.with({
59
61
  auth: auth(input),
@@ -76,7 +78,17 @@ export const configure = (input) => {
76
78
  .model({ id: modelID });
77
79
  const chat = (modelID) => configuredRoute(chatRoute, input, modelID)
78
80
  .with(withOpenAIOptions(modelID, modelDefaults))
79
- .model({ id: modelID, compatibility: { supportsPromptCacheKey: true } });
81
+ .model({ id: modelID, capabilities: { promptCacheKey: true } });
82
+ const messages = (modelID) => messagesRoute
83
+ .with({
84
+ ...modelDefaults,
85
+ auth: auth(input, "x-api-key"),
86
+ endpoint: {
87
+ baseURL: Endpoint.trimBaseUrl(input.baseURL ?? `https://${input.resourceName.trim()}.services.ai.azure.com/anthropic/v1`),
88
+ query: input.queryParams,
89
+ },
90
+ })
91
+ .model({ id: modelID });
80
92
  const image = (modelID, providerOptions) => {
81
93
  const target = endpoint(input, modelID);
82
94
  const media = MediaRoute.deployment({ ...input, baseURL: target.baseURL }, auth(input));
@@ -85,7 +97,7 @@ export const configure = (input) => {
85
97
  id: modelID,
86
98
  provider: id,
87
99
  providerOptions,
88
- http: mergeHttpOptions(media.http, target.query === undefined ? undefined : new HttpOptions({ query: target.query })),
100
+ http: { ...media.http, query: { ...media.http?.query, ...target.query } },
89
101
  });
90
102
  };
91
103
  return {
@@ -93,6 +105,7 @@ export const configure = (input) => {
93
105
  model: responses,
94
106
  responses,
95
107
  chat,
108
+ messages,
96
109
  image,
97
110
  configure,
98
111
  };
@@ -119,8 +132,11 @@ const config = ({ apiKey, apiVersion, baseURL, body, headers, queryParams, resou
119
132
  };
120
133
  export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
121
134
  export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
135
+ export const messagesModel = (modelID, settings) => configure(config(settings)).messages(modelID);
122
136
  export const imageModel = (modelID, settings) => {
123
137
  const input = config(settings);
124
138
  return configure(input).image(modelID, input.providerOptions);
125
139
  };
126
140
  export const model = responsesModel;
141
+ export const responses = responsesModel;
142
+ export const chat = chatModel;
@@ -1,10 +1,10 @@
1
1
  import type { ProviderPackage } from "../provider-package.js";
2
- import { type ProviderAuthOption } from "../route/auth-options.js";
3
- import { Route, type RouteDefaultsInput } from "../route/client.js";
4
- import { type ModelID, type ProviderOptions } from "../schema/index.js";
2
+ import type { ProviderAuthOption } from "../route/auth-options.js";
3
+ import { Route } from "../route/client.js";
4
+ import { type ModelID, type ProviderOptions, type RequestOptions } from "../schema/index.js";
5
5
  import type { OpenAIProviderOptionsInput } from "./openai-options.js";
6
6
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
7
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
@@ -13,7 +13,7 @@ export interface BasetenDecisionOptions {
13
13
  readonly max_len?: number;
14
14
  }
15
15
  export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
16
- readonly apiKey?: string;
16
+ readonly apiKey?: string | false;
17
17
  readonly baseURL?: string;
18
18
  };
19
19
  export declare const route: Route<{
@@ -1,11 +1,11 @@
1
1
  import { Effect } from "effect";
2
2
  import { OpenAIChat } from "../protocols/openai-chat.js";
3
3
  import { SystemOne } from "../protocols/system-one.js";
4
- import { AuthOptions } from "../route/auth-options.js";
5
4
  import { Route } from "../route/client.js";
6
5
  import { DecisionRoute } from "../route/decision.js";
7
6
  import { Endpoint } from "../route/endpoint.js";
8
7
  import { ProviderID } from "../schema/index.js";
8
+ import { bearerRouteDefaults, toConfig } from "./settings.js";
9
9
  export const id = ProviderID.make("baseten");
10
10
  const baseURL = "https://inference.baseten.co/v1";
11
11
  export const route = Route.make({
@@ -27,20 +27,15 @@ const decisionProtocol = DecisionRoute.protocol({
27
27
  },
28
28
  });
29
29
  export const configure = (input = {}) => {
30
- const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
31
- const auth = AuthOptions.bearer(input, "BASETEN_API_KEY");
32
- const configured = route.with({
33
- ...defaults,
34
- endpoint: { baseURL: endpoint ?? baseURL },
35
- auth,
36
- });
30
+ const options = bearerRouteDefaults(input, "BASETEN_API_KEY", baseURL);
31
+ const configured = route.with(options);
37
32
  const decisionRoute = DecisionRoute.make({
38
33
  id: decisionProtocol.id,
39
34
  provider: id,
40
35
  providerMetadataKey: "baseten",
41
36
  protocol: decisionProtocol,
42
- endpoint: Endpoint.path("/systemone", { baseURL: endpoint ?? baseURL }),
43
- auth,
37
+ endpoint: Endpoint.path("/systemone", { baseURL: options.endpoint.baseURL }),
38
+ auth: options.auth,
44
39
  headers: input.headers,
45
40
  http: input.http,
46
41
  });
@@ -54,18 +49,9 @@ export const configure = (input = {}) => {
54
49
  };
55
50
  export const provider = configure();
56
51
  export const decision = provider.decision;
57
- export const model = (modelID, settings) => configure(config(settings)).model(modelID);
52
+ export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);
58
53
  export const decisionModel = (modelID, settings) => {
59
- const input = config(settings);
54
+ const input = toConfig(settings);
60
55
  return configure(input).decision(modelID, input.providerOptions);
61
56
  };
62
- function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
63
- return {
64
- apiKey,
65
- baseURL,
66
- headers,
67
- http: body === undefined ? undefined : { body },
68
- providerOptions,
69
- };
70
- }
71
57
  export * as Baseten from "./baseten.js";
@@ -5,7 +5,7 @@ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
5
  export type Config = ProviderAuthOption<"optional"> & {
6
6
  readonly baseURL?: string;
7
7
  readonly headers?: Record<string, string>;
8
- readonly http?: HttpOptions.Input;
8
+ readonly http?: HttpOptions;
9
9
  };
10
10
  export declare const configure: (input?: Config) => {
11
11
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1,15 +1,15 @@
1
1
  import type { ProviderPackage } from "../provider-package.js";
2
- import { type ProviderAuthOption } from "../route/auth-options.js";
3
- import { Route, type RouteDefaultsInput } from "../route/client.js";
4
- import { type ModelID } from "../schema/index.js";
2
+ import type { ProviderAuthOption } from "../route/auth-options.js";
3
+ import { Route } from "../route/client.js";
4
+ import { type ModelID, type RequestOptions } from "../schema/index.js";
5
5
  import type { OpenAIProviderOptionsInput } from "./openai-options.js";
6
6
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
- export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
7
+ export type Config = Omit<RequestOptions, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
8
  readonly baseURL?: string;
9
9
  readonly providerOptions?: OpenAIProviderOptionsInput;
10
10
  };
11
11
  export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
12
- readonly apiKey?: string;
12
+ readonly apiKey?: string | false;
13
13
  readonly baseURL?: string;
14
14
  };
15
15
  export declare const route: Route<{
@@ -1,8 +1,8 @@
1
1
  import { OpenAIChat } from "../protocols/openai-chat.js";
2
- import { AuthOptions } from "../route/auth-options.js";
3
2
  import { Route } from "../route/client.js";
4
3
  import { Endpoint } from "../route/endpoint.js";
5
4
  import { ProviderID } from "../schema/index.js";
5
+ import { bearerRouteDefaults, toConfig } from "./settings.js";
6
6
  export const id = ProviderID.make("cerebras");
7
7
  const baseURL = "https://api.cerebras.ai/v1";
8
8
  export const route = Route.make({
@@ -15,12 +15,7 @@ export const route = Route.make({
15
15
  });
16
16
  export const routes = [route];
17
17
  export const configure = (input = {}) => {
18
- const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
19
- const configured = route.with({
20
- ...defaults,
21
- endpoint: { baseURL: endpoint ?? baseURL },
22
- auth: AuthOptions.bearer(input, "CEREBRAS_API_KEY"),
23
- });
18
+ const configured = route.with(bearerRouteDefaults(input, "CEREBRAS_API_KEY", baseURL));
24
19
  return {
25
20
  id,
26
21
  model: (modelID) => configured.model({
@@ -28,17 +23,11 @@ export const configure = (input = {}) => {
28
23
  compatibility: {
29
24
  maxTokensField: "max_tokens",
30
25
  reasoningField: "reasoning",
31
- supportsPromptCacheKey: true,
32
26
  },
27
+ capabilities: { promptCacheKey: true },
33
28
  }),
34
29
  configure,
35
30
  };
36
31
  };
37
32
  export const provider = configure();
38
- export const model = (modelID, { apiKey, baseURL, body, headers, ...providerOptions } = {}) => configure({
39
- apiKey,
40
- baseURL,
41
- headers,
42
- http: body === undefined ? undefined : { body },
43
- providerOptions,
44
- }).model(modelID);
33
+ export const model = (modelID, settings) => configure(toConfig(settings)).model(modelID);