@opencode/ai 2.2.0 → 2.2.1

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 (184) hide show
  1. package/README.md +66 -62
  2. package/dist/effect.d.ts +1 -1
  3. package/dist/effect.js +1 -1
  4. package/dist/image-client.d.ts +45 -0
  5. package/dist/index.d.ts +38 -20
  6. package/dist/index.js +14 -2
  7. package/dist/media-client.d.ts +1 -0
  8. package/dist/media-client.js +1 -0
  9. package/dist/protocols/alibaba-chat.d.ts +39 -4
  10. package/dist/protocols/alibaba-responses.d.ts +20 -3
  11. package/dist/protocols/google-images.js +3 -1
  12. package/dist/protocols/meta-responses.d.ts +40 -6
  13. package/dist/protocols/meta-responses.js +1 -1
  14. package/dist/protocols/minimax-images.d.ts +25 -0
  15. package/dist/protocols/minimax-images.js +150 -0
  16. package/dist/protocols/open-responses.d.ts +182 -27
  17. package/dist/protocols/open-responses.js +108 -36
  18. package/dist/protocols/openai-chat.d.ts +438 -46
  19. package/dist/protocols/openai-chat.js +121 -39
  20. package/dist/protocols/openai-compatible-chat.d.ts +35 -4
  21. package/dist/protocols/openai-compatible-responses.d.ts +20 -3
  22. package/dist/protocols/openai-freeform.d.ts +47 -0
  23. package/dist/protocols/openai-freeform.js +54 -0
  24. package/dist/protocols/openai-images.d.ts +16 -1
  25. package/dist/protocols/openai-images.js +49 -17
  26. package/dist/protocols/openai-responses.d.ts +120 -18
  27. package/dist/protocols/openai-responses.js +17 -8
  28. package/dist/protocols/venice-chat.d.ts +39 -4
  29. package/dist/protocols/venice-chat.js +1 -1
  30. package/dist/protocols/xai-images.d.ts +6 -0
  31. package/dist/protocols/xai-images.js +4 -5
  32. package/dist/protocols/xai-responses.d.ts +20 -3
  33. package/dist/protocols/xai-responses.js +2 -1
  34. package/dist/protocols/zai-chat.d.ts +39 -4
  35. package/dist/provider-error.js +5 -4
  36. package/dist/provider-package.d.ts +2 -0
  37. package/dist/providers/alibaba.d.ts +58 -10
  38. package/dist/providers/amazon-bedrock-mantle.d.ts +66 -11
  39. package/dist/providers/amazon-bedrock-mantle.js +1 -1
  40. package/dist/providers/amazon-bedrock.d.ts +1 -1
  41. package/dist/providers/amazon-bedrock.js +1 -1
  42. package/dist/providers/anthropic-compatible.d.ts +1 -1
  43. package/dist/providers/anthropic.d.ts +1 -1
  44. package/dist/providers/anthropic.js +1 -1
  45. package/dist/providers/azure.d.ts +79 -15
  46. package/dist/providers/baseten.d.ts +74 -12
  47. package/dist/providers/baseten.js +1 -1
  48. package/dist/providers/cerebras.d.ts +73 -11
  49. package/dist/providers/cerebras.js +1 -1
  50. package/dist/providers/cloudflare-ai-gateway.d.ts +113 -17
  51. package/dist/providers/cloudflare-workers-ai.d.ts +73 -11
  52. package/dist/providers/cohere/chat.d.ts +1 -1
  53. package/dist/providers/cohere/chat.js +1 -1
  54. package/dist/providers/cohere.d.ts +73 -11
  55. package/dist/providers/cohere.js +1 -1
  56. package/dist/providers/deepinfra.d.ts +73 -11
  57. package/dist/providers/deepinfra.js +1 -1
  58. package/dist/providers/deepseek.d.ts +73 -11
  59. package/dist/providers/deepseek.js +1 -1
  60. package/dist/providers/digitalocean/responses.d.ts +4 -0
  61. package/dist/providers/digitalocean/responses.js +1 -0
  62. package/dist/providers/digitalocean.d.ts +320 -21
  63. package/dist/providers/digitalocean.js +18 -7
  64. package/dist/providers/fireworks.d.ts +73 -11
  65. package/dist/providers/fireworks.js +1 -1
  66. package/dist/providers/google/interactions.d.ts +1 -1
  67. package/dist/providers/google/interactions.js +1 -1
  68. package/dist/providers/google-vertex-chat.d.ts +36 -5
  69. package/dist/providers/google-vertex-chat.js +1 -1
  70. package/dist/providers/google-vertex-interactions.d.ts +1 -1
  71. package/dist/providers/google-vertex-interactions.js +1 -1
  72. package/dist/providers/google-vertex-messages.d.ts +1 -1
  73. package/dist/providers/google-vertex-messages.js +1 -1
  74. package/dist/providers/google-vertex-mistral.d.ts +1 -1
  75. package/dist/providers/google-vertex-mistral.js +1 -1
  76. package/dist/providers/google-vertex-responses.d.ts +21 -4
  77. package/dist/providers/google-vertex-responses.js +1 -1
  78. package/dist/providers/google-vertex.d.ts +2 -2
  79. package/dist/providers/google-vertex.js +1 -1
  80. package/dist/providers/google.d.ts +2 -2
  81. package/dist/providers/google.js +1 -1
  82. package/dist/providers/groq.d.ts +77 -11
  83. package/dist/providers/groq.js +1 -1
  84. package/dist/providers/index.d.ts +0 -4
  85. package/dist/providers/index.js +0 -4
  86. package/dist/providers/meta/images.d.ts +2 -0
  87. package/dist/providers/meta/images.js +1 -0
  88. package/dist/providers/meta.d.ts +61 -12
  89. package/dist/providers/meta.js +2 -1
  90. package/dist/providers/minimax/chat.d.ts +1 -1
  91. package/dist/providers/minimax/chat.js +1 -1
  92. package/dist/providers/minimax/images.d.ts +3 -0
  93. package/dist/providers/minimax/images.js +1 -0
  94. package/dist/providers/minimax/responses.d.ts +1 -1
  95. package/dist/providers/minimax/responses.js +1 -1
  96. package/dist/providers/minimax.d.ts +63 -9
  97. package/dist/providers/minimax.js +22 -9
  98. package/dist/providers/mistral.d.ts +3 -3
  99. package/dist/providers/mistral.js +1 -1
  100. package/dist/providers/moonshot/messages.d.ts +1 -1
  101. package/dist/providers/moonshot/messages.js +1 -1
  102. package/dist/providers/moonshot/responses.d.ts +1 -1
  103. package/dist/providers/moonshot/responses.js +1 -1
  104. package/dist/providers/moonshot.d.ts +56 -8
  105. package/dist/providers/moonshot.js +1 -1
  106. package/dist/providers/openai-compatible-responses.d.ts +21 -4
  107. package/dist/providers/openai-compatible.d.ts +38 -7
  108. package/dist/providers/openai-compatible.js +9 -2
  109. package/dist/providers/openai.d.ts +59 -11
  110. package/dist/providers/openai.js +4 -2
  111. package/dist/providers/opencode.d.ts +3 -3
  112. package/dist/providers/opencode.js +1 -1
  113. package/dist/providers/openrouter/responses.d.ts +4 -0
  114. package/dist/providers/openrouter/responses.js +1 -0
  115. package/dist/providers/openrouter.d.ts +356 -26
  116. package/dist/providers/openrouter.js +42 -13
  117. package/dist/providers/togetherai.d.ts +73 -11
  118. package/dist/providers/togetherai.js +1 -1
  119. package/dist/providers/typesafe-ai.d.ts +3 -3
  120. package/dist/providers/typesafe-ai.js +1 -1
  121. package/dist/providers/venice/responses.d.ts +4 -0
  122. package/dist/providers/venice/responses.js +1 -0
  123. package/dist/providers/venice.d.ts +242 -9
  124. package/dist/providers/venice.js +33 -17
  125. package/dist/providers/vercel-ai-gateway.d.ts +8 -8
  126. package/dist/providers/vercel-ai-gateway.js +12 -2
  127. package/dist/providers/xai.d.ts +39 -8
  128. package/dist/providers/xai.js +1 -1
  129. package/dist/providers/zai-coding-plan/messages.d.ts +1 -1
  130. package/dist/providers/zai-coding-plan/messages.js +1 -1
  131. package/dist/providers/zai-coding-plan/responses.d.ts +1 -1
  132. package/dist/providers/zai-coding-plan/responses.js +1 -1
  133. package/dist/providers/zai-coding-plan.d.ts +56 -8
  134. package/dist/providers/zai-coding-plan.js +1 -1
  135. package/dist/providers/zai.d.ts +37 -6
  136. package/dist/providers/zai.js +1 -1
  137. package/dist/route/auth.d.ts +1 -1
  138. package/dist/route/media-protocol.d.ts +2 -4
  139. package/dist/route/media.d.ts +1 -1
  140. package/dist/route/media.js +2 -4
  141. package/dist/schema/messages.d.ts +35 -1
  142. package/dist/schema/messages.js +20 -0
  143. package/dist/speech-client.d.ts +48 -0
  144. package/dist/testing/decision.d.ts +16 -0
  145. package/dist/testing/decision.js +20 -0
  146. package/dist/testing/image.d.ts +14 -0
  147. package/dist/testing/image.js +12 -0
  148. package/dist/testing/media.d.ts +18 -0
  149. package/dist/testing/media.js +36 -0
  150. package/dist/testing/script.d.ts +28 -0
  151. package/dist/testing/script.js +60 -0
  152. package/dist/testing/speech.d.ts +14 -0
  153. package/dist/testing/speech.js +12 -0
  154. package/dist/testing/transcription.d.ts +14 -0
  155. package/dist/testing/transcription.js +12 -0
  156. package/dist/testing/video.d.ts +14 -0
  157. package/dist/testing/video.js +12 -0
  158. package/dist/testing.d.ts +10 -21
  159. package/dist/testing.js +11 -54
  160. package/dist/tool.d.ts +12 -1
  161. package/dist/tool.js +10 -2
  162. package/dist/transcription-client.d.ts +64 -0
  163. package/dist/video-client.d.ts +41 -0
  164. package/package.json +22 -38
  165. package/dist/protocols/bfl-images.d.ts +0 -47
  166. package/dist/protocols/bfl-images.js +0 -155
  167. package/dist/protocols/fal-images.d.ts +0 -34
  168. package/dist/protocols/fal-images.js +0 -95
  169. package/dist/protocols/fal-video.d.ts +0 -29
  170. package/dist/protocols/fal-video.js +0 -73
  171. package/dist/protocols/replicate-images.d.ts +0 -28
  172. package/dist/protocols/replicate-images.js +0 -127
  173. package/dist/protocols/stability-images.d.ts +0 -44
  174. package/dist/protocols/stability-images.js +0 -131
  175. package/dist/protocols/utils/fal-queue.d.ts +0 -26
  176. package/dist/protocols/utils/fal-queue.js +0 -67
  177. package/dist/providers/black-forest-labs.d.ts +0 -21
  178. package/dist/providers/black-forest-labs.js +0 -23
  179. package/dist/providers/fal.d.ts +0 -24
  180. package/dist/providers/fal.js +0 -26
  181. package/dist/providers/replicate.d.ts +0 -21
  182. package/dist/providers/replicate.js +0 -17
  183. package/dist/providers/stability.d.ts +0 -23
  184. package/dist/providers/stability.js +0 -18
@@ -5,6 +5,7 @@ import { type ProviderAuthOption } from "../route/auth-options.js";
5
5
  import { type ModelID, type OpenString, type ProviderOptions } from "../schema/index.js";
6
6
  import type { ProviderPackage } from "../provider-package.js";
7
7
  import { OpenAIChat } from "../protocols/openai-chat.js";
8
+ import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
8
9
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
9
10
  export interface OpenRouterProviderRouting {
10
11
  readonly [key: string]: unknown;
@@ -79,11 +80,11 @@ export interface OpenRouterDecisionOptions {
79
80
  readonly trace?: Readonly<Record<string, unknown>>;
80
81
  readonly user?: string;
81
82
  }
82
- export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
83
+ export type Config = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
83
84
  readonly baseURL?: string;
84
- readonly providerOptions?: OpenRouterProviderOptionsInput;
85
+ readonly providerOptions?: OpenRouterProviderOptionsInput | OpenResponsesProviderOptionsInput;
85
86
  };
86
- export type Settings = ProviderPackage.Settings & OpenRouterProviderOptionsInput & {
87
+ export type Settings<Options = OpenRouterProviderOptionsInput> = ProviderPackage.Settings & Options & {
87
88
  readonly apiKey?: string;
88
89
  readonly baseURL?: string;
89
90
  };
@@ -151,7 +152,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
151
152
  readonly ttl: Schema.optional<Schema.String>;
152
153
  }>>;
153
154
  }>>]>>;
154
- readonly tool_calls: Schema.optional<Schema.$Array<Schema.Struct<{
155
+ readonly tool_calls: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
155
156
  readonly id: Schema.String;
156
157
  readonly type: Schema.tag<"function">;
157
158
  readonly function: Schema.Struct<{
@@ -163,7 +164,14 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
163
164
  readonly thought_signature: Schema.String;
164
165
  }>;
165
166
  }>>;
166
- }>>>;
167
+ }>, Schema.Struct<{
168
+ readonly id: Schema.String;
169
+ readonly type: Schema.tag<"custom">;
170
+ readonly custom: Schema.Struct<{
171
+ readonly name: Schema.String;
172
+ readonly input: Schema.String;
173
+ }>;
174
+ }>]>>>;
167
175
  readonly reasoning_content: Schema.optional<Schema.String>;
168
176
  readonly reasoning: Schema.optional<Schema.String>;
169
177
  readonly reasoning_text: Schema.optional<Schema.String>;
@@ -180,7 +188,7 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
180
188
  }>>;
181
189
  }>>]>;
182
190
  }>]>>;
183
- readonly tools: Schema.optional<Schema.$Array<Schema.Struct<{
191
+ readonly tools: Schema.optional<Schema.$Array<Schema.Union<readonly [Schema.Struct<{
184
192
  readonly type: Schema.tag<"function">;
185
193
  readonly function: Schema.Struct<{
186
194
  readonly name: Schema.String;
@@ -192,12 +200,36 @@ declare const OpenRouterBody: Schema.StructWithRest<Schema.Struct<{
192
200
  readonly type: Schema.Literal<"ephemeral">;
193
201
  readonly ttl: Schema.optional<Schema.String>;
194
202
  }>>;
195
- }>>>;
203
+ }>, Schema.Struct<{
204
+ readonly type: Schema.tag<"custom">;
205
+ readonly custom: Schema.Struct<{
206
+ readonly name: Schema.String;
207
+ readonly description: Schema.String;
208
+ readonly format: Schema.Union<readonly [Schema.Struct<{
209
+ readonly type: Schema.tag<"text">;
210
+ }>, Schema.Struct<{
211
+ readonly type: Schema.tag<"grammar">;
212
+ readonly grammar: Schema.Struct<{
213
+ readonly syntax: Schema.Literals<readonly ["lark", "regex"]>;
214
+ readonly definition: Schema.String;
215
+ }>;
216
+ }>]>;
217
+ }>;
218
+ readonly cache_control: Schema.optional<Schema.Struct<{
219
+ readonly type: Schema.Literal<"ephemeral">;
220
+ readonly ttl: Schema.optional<Schema.String>;
221
+ }>>;
222
+ }>]>>>;
196
223
  readonly tool_choice: Schema.optional<Schema.Union<readonly [Schema.Literals<readonly ["auto", "none", "required"]>, Schema.Struct<{
197
224
  readonly type: Schema.tag<"function">;
198
225
  readonly function: Schema.Struct<{
199
226
  readonly name: Schema.String;
200
227
  }>;
228
+ }>, Schema.Struct<{
229
+ readonly type: Schema.tag<"custom">;
230
+ readonly custom: Schema.Struct<{
231
+ readonly name: Schema.String;
232
+ }>;
201
233
  }>]>>;
202
234
  readonly stream: Schema.Literal<true>;
203
235
  readonly stream_options: Schema.optional<Schema.Struct<{
@@ -310,7 +342,14 @@ export declare const protocol: Protocol<{
310
342
  readonly ttl?: string | undefined;
311
343
  } | undefined;
312
344
  }[] | null;
313
- readonly tool_calls?: readonly {
345
+ readonly tool_calls?: readonly ({
346
+ readonly id: string;
347
+ readonly type: "custom";
348
+ readonly custom: {
349
+ readonly name: string;
350
+ readonly input: string;
351
+ };
352
+ } | {
314
353
  readonly id: string;
315
354
  readonly type: "function";
316
355
  readonly function: {
@@ -322,13 +361,13 @@ export declare const protocol: Protocol<{
322
361
  readonly thought_signature: string;
323
362
  };
324
363
  } | undefined;
325
- }[] | undefined;
364
+ })[] | undefined;
326
365
  readonly reasoning_content?: string | undefined;
327
366
  readonly reasoning?: string | undefined;
328
367
  readonly reasoning_text?: string | undefined;
329
368
  readonly reasoning_details?: unknown;
330
369
  })[];
331
- tools?: readonly {
370
+ tools?: readonly ({
332
371
  readonly type: "function";
333
372
  readonly function: {
334
373
  readonly name: string;
@@ -342,12 +381,36 @@ export declare const protocol: Protocol<{
342
381
  readonly type: "ephemeral";
343
382
  readonly ttl?: string | undefined;
344
383
  } | undefined;
345
- }[] | undefined;
384
+ } | {
385
+ readonly type: "custom";
386
+ readonly custom: {
387
+ readonly name: string;
388
+ readonly description: string;
389
+ readonly format: {
390
+ readonly type: "text";
391
+ } | {
392
+ readonly type: "grammar";
393
+ readonly grammar: {
394
+ readonly syntax: "lark" | "regex";
395
+ readonly definition: string;
396
+ };
397
+ };
398
+ };
399
+ readonly cache_control?: {
400
+ readonly type: "ephemeral";
401
+ readonly ttl?: string | undefined;
402
+ } | undefined;
403
+ })[] | undefined;
346
404
  tool_choice?: "auto" | "none" | "required" | {
347
405
  readonly type: "function";
348
406
  readonly function: {
349
407
  readonly name: string;
350
408
  };
409
+ } | {
410
+ readonly type: "custom";
411
+ readonly custom: {
412
+ readonly name: string;
413
+ };
351
414
  } | undefined;
352
415
  stream: true;
353
416
  stream_options?: {
@@ -413,6 +476,10 @@ export declare const protocol: Protocol<{
413
476
  readonly name?: string | null | undefined;
414
477
  readonly arguments?: string | null | undefined;
415
478
  } | null | undefined;
479
+ readonly custom?: {
480
+ readonly name?: string | null | undefined;
481
+ readonly input?: string | null | undefined;
482
+ } | null | undefined;
416
483
  readonly extra_content?: unknown;
417
484
  }[] | null | undefined;
418
485
  } | null | undefined;
@@ -543,7 +610,14 @@ export declare const route: Route<{
543
610
  readonly ttl?: string | undefined;
544
611
  } | undefined;
545
612
  }[] | null;
546
- readonly tool_calls?: readonly {
613
+ readonly tool_calls?: readonly ({
614
+ readonly id: string;
615
+ readonly type: "custom";
616
+ readonly custom: {
617
+ readonly name: string;
618
+ readonly input: string;
619
+ };
620
+ } | {
547
621
  readonly id: string;
548
622
  readonly type: "function";
549
623
  readonly function: {
@@ -555,13 +629,13 @@ export declare const route: Route<{
555
629
  readonly thought_signature: string;
556
630
  };
557
631
  } | undefined;
558
- }[] | undefined;
632
+ })[] | undefined;
559
633
  readonly reasoning_content?: string | undefined;
560
634
  readonly reasoning?: string | undefined;
561
635
  readonly reasoning_text?: string | undefined;
562
636
  readonly reasoning_details?: unknown;
563
637
  })[];
564
- tools?: readonly {
638
+ tools?: readonly ({
565
639
  readonly type: "function";
566
640
  readonly function: {
567
641
  readonly name: string;
@@ -575,12 +649,36 @@ export declare const route: Route<{
575
649
  readonly type: "ephemeral";
576
650
  readonly ttl?: string | undefined;
577
651
  } | undefined;
578
- }[] | undefined;
652
+ } | {
653
+ readonly type: "custom";
654
+ readonly custom: {
655
+ readonly name: string;
656
+ readonly description: string;
657
+ readonly format: {
658
+ readonly type: "text";
659
+ } | {
660
+ readonly type: "grammar";
661
+ readonly grammar: {
662
+ readonly syntax: "lark" | "regex";
663
+ readonly definition: string;
664
+ };
665
+ };
666
+ };
667
+ readonly cache_control?: {
668
+ readonly type: "ephemeral";
669
+ readonly ttl?: string | undefined;
670
+ } | undefined;
671
+ })[] | undefined;
579
672
  tool_choice?: "auto" | "none" | "required" | {
580
673
  readonly type: "function";
581
674
  readonly function: {
582
675
  readonly name: string;
583
676
  };
677
+ } | {
678
+ readonly type: "custom";
679
+ readonly custom: {
680
+ readonly name: string;
681
+ };
584
682
  } | undefined;
585
683
  stream: true;
586
684
  stream_options?: {
@@ -628,7 +726,204 @@ export declare const route: Route<{
628
726
  user?: string | undefined;
629
727
  reasoning?: Record<string, unknown> | undefined;
630
728
  }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
631
- export declare const routes: Route<{
729
+ export declare const routes: (Route<{
730
+ readonly model: string;
731
+ readonly input: readonly ({
732
+ readonly type: "configuration_update";
733
+ readonly reasoning: {
734
+ readonly effort: import("../schema/options.js").ReasoningEffort;
735
+ };
736
+ } | {
737
+ readonly type: "message";
738
+ readonly role: "system";
739
+ readonly content: string;
740
+ } | {
741
+ readonly type: "message";
742
+ readonly role: "developer";
743
+ readonly content: string;
744
+ } | {
745
+ readonly type: "custom_tool_call_output" | "function_call_output";
746
+ readonly call_id: string;
747
+ readonly output: string | readonly ({
748
+ readonly type: "input_text";
749
+ readonly text: string;
750
+ } | {
751
+ readonly type: "input_video";
752
+ readonly video_url: string;
753
+ } | {
754
+ readonly type: "input_image";
755
+ readonly image_url: string;
756
+ readonly detail?: string | undefined;
757
+ } | {
758
+ readonly type: "input_file";
759
+ readonly filename: string;
760
+ readonly detail?: string | undefined;
761
+ readonly file_data?: string | undefined;
762
+ readonly file_url?: string | undefined;
763
+ })[];
764
+ } | {
765
+ readonly type: "reasoning";
766
+ readonly id?: string | undefined;
767
+ readonly summary: readonly {
768
+ readonly type: "summary_text";
769
+ readonly text: string;
770
+ }[];
771
+ readonly encrypted_content?: string | null | undefined;
772
+ } | {
773
+ readonly type: "compaction";
774
+ readonly id?: string | null | undefined;
775
+ readonly encrypted_content: string;
776
+ } | {
777
+ readonly type: "message";
778
+ readonly role: "user";
779
+ readonly content: readonly ({
780
+ readonly type: "input_text";
781
+ readonly text: string;
782
+ } | {
783
+ readonly type: "input_video";
784
+ readonly video_url: string;
785
+ } | {
786
+ readonly type: "input_image";
787
+ readonly image_url: string;
788
+ readonly detail?: string | undefined;
789
+ } | {
790
+ readonly type: "input_file";
791
+ readonly filename: string;
792
+ readonly detail?: string | undefined;
793
+ readonly file_data?: string | undefined;
794
+ readonly file_url?: string | undefined;
795
+ })[];
796
+ readonly id?: string | undefined;
797
+ readonly status?: string | undefined;
798
+ } | {
799
+ readonly type: "message";
800
+ readonly id?: string | undefined;
801
+ readonly role: "assistant";
802
+ readonly content: readonly {
803
+ readonly type: "output_text";
804
+ readonly text: string;
805
+ }[];
806
+ readonly phase?: "commentary" | "final_answer" | null | undefined;
807
+ readonly status?: string | undefined;
808
+ } | {
809
+ readonly type: "function_call";
810
+ readonly id?: string | undefined;
811
+ readonly call_id: string;
812
+ readonly name: string;
813
+ readonly namespace?: string | undefined;
814
+ readonly arguments: string;
815
+ } | {
816
+ readonly type: "custom_tool_call";
817
+ readonly id?: string | undefined;
818
+ readonly call_id: string;
819
+ readonly name: string;
820
+ readonly input: string;
821
+ } | {
822
+ readonly [x: string]: unknown;
823
+ readonly type: "web_search_call";
824
+ readonly id: string;
825
+ readonly status?: string | undefined;
826
+ readonly action?: {
827
+ readonly [x: string]: unknown;
828
+ } | null | undefined;
829
+ } | {
830
+ readonly [x: string]: unknown;
831
+ readonly type: "file_search_call";
832
+ readonly id: string;
833
+ readonly status?: string | undefined;
834
+ readonly queries?: readonly string[] | undefined;
835
+ readonly results?: readonly {
836
+ readonly [x: string]: unknown;
837
+ }[] | null | undefined;
838
+ } | {
839
+ readonly [x: string]: unknown;
840
+ readonly type: "code_interpreter_call";
841
+ readonly id: string;
842
+ readonly status?: string | undefined;
843
+ readonly code?: string | null | undefined;
844
+ readonly container_id?: string | null | undefined;
845
+ readonly outputs?: readonly {
846
+ readonly [x: string]: unknown;
847
+ }[] | null | undefined;
848
+ } | {
849
+ readonly [x: string]: unknown;
850
+ readonly type: "mcp_call";
851
+ readonly id: string;
852
+ readonly status?: string | undefined;
853
+ readonly server_label?: string | undefined;
854
+ readonly name?: string | undefined;
855
+ readonly arguments?: string | undefined;
856
+ readonly output?: string | null | undefined;
857
+ readonly error?: unknown;
858
+ } | {
859
+ readonly [x: string]: unknown;
860
+ readonly type: string;
861
+ readonly id: string;
862
+ })[];
863
+ readonly instructions?: string | undefined;
864
+ readonly tools?: readonly ({
865
+ readonly type: "custom";
866
+ readonly name: string;
867
+ readonly description: string;
868
+ readonly format: {
869
+ readonly type: "text";
870
+ } | {
871
+ readonly type: "grammar";
872
+ readonly syntax: "lark" | "regex";
873
+ readonly definition: string;
874
+ };
875
+ } | {
876
+ readonly type: "function";
877
+ readonly name: string;
878
+ readonly description: string;
879
+ readonly parameters: {
880
+ readonly [x: string]: unknown;
881
+ };
882
+ readonly strict?: boolean | undefined;
883
+ } | {
884
+ readonly [x: string]: unknown;
885
+ readonly type: string;
886
+ })[] | undefined;
887
+ readonly tool_choice?: "auto" | "none" | "required" | {
888
+ readonly type: "custom" | "function";
889
+ readonly name: string;
890
+ } | {
891
+ readonly type: "allowed_tools";
892
+ readonly mode: "auto" | "none" | "required";
893
+ readonly tools: readonly {
894
+ readonly type: "custom" | "function";
895
+ readonly name: string;
896
+ }[];
897
+ } | undefined;
898
+ readonly store?: boolean | undefined;
899
+ readonly metadata?: {
900
+ readonly [x: string]: string;
901
+ } | undefined;
902
+ readonly safety_identifier?: string | undefined;
903
+ readonly stream_options?: {
904
+ readonly include_obfuscation?: boolean | undefined;
905
+ } | undefined;
906
+ readonly top_logprobs?: number | undefined;
907
+ readonly truncation?: "auto" | "disabled" | undefined;
908
+ readonly service_tier?: OpenString<"auto" | "default" | "flex" | "priority"> | undefined;
909
+ readonly prompt_cache_key?: string | undefined;
910
+ readonly include?: readonly OpenString<"code_interpreter_call.outputs" | "computer_call_output.output.image_url" | "file_search_call.results" | "message.input_image.image_url" | "message.output_text.logprobs" | "reasoning.encrypted_content" | "web_search_call.action.sources" | "web_search_call.results">[] | undefined;
911
+ readonly reasoning?: {
912
+ readonly effort?: import("../schema/options.js").ReasoningEffort | undefined;
913
+ readonly summary?: "auto" | "concise" | "detailed" | undefined;
914
+ } | undefined;
915
+ readonly text?: {
916
+ readonly verbosity?: OpenString<"high" | "low" | "medium"> | undefined;
917
+ } | undefined;
918
+ readonly max_output_tokens?: number | undefined;
919
+ readonly max_tool_calls?: number | undefined;
920
+ readonly parallel_tool_calls?: boolean | undefined;
921
+ readonly temperature?: number | undefined;
922
+ readonly top_p?: number | undefined;
923
+ readonly presence_penalty?: number | undefined;
924
+ readonly frequency_penalty?: number | undefined;
925
+ readonly stream: true;
926
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<{
632
927
  model: string;
633
928
  messages: readonly ({
634
929
  readonly role: "system";
@@ -704,7 +999,14 @@ export declare const routes: Route<{
704
999
  readonly ttl?: string | undefined;
705
1000
  } | undefined;
706
1001
  }[] | null;
707
- readonly tool_calls?: readonly {
1002
+ readonly tool_calls?: readonly ({
1003
+ readonly id: string;
1004
+ readonly type: "custom";
1005
+ readonly custom: {
1006
+ readonly name: string;
1007
+ readonly input: string;
1008
+ };
1009
+ } | {
708
1010
  readonly id: string;
709
1011
  readonly type: "function";
710
1012
  readonly function: {
@@ -716,13 +1018,13 @@ export declare const routes: Route<{
716
1018
  readonly thought_signature: string;
717
1019
  };
718
1020
  } | undefined;
719
- }[] | undefined;
1021
+ })[] | undefined;
720
1022
  readonly reasoning_content?: string | undefined;
721
1023
  readonly reasoning?: string | undefined;
722
1024
  readonly reasoning_text?: string | undefined;
723
1025
  readonly reasoning_details?: unknown;
724
1026
  })[];
725
- tools?: readonly {
1027
+ tools?: readonly ({
726
1028
  readonly type: "function";
727
1029
  readonly function: {
728
1030
  readonly name: string;
@@ -736,12 +1038,36 @@ export declare const routes: Route<{
736
1038
  readonly type: "ephemeral";
737
1039
  readonly ttl?: string | undefined;
738
1040
  } | undefined;
739
- }[] | undefined;
1041
+ } | {
1042
+ readonly type: "custom";
1043
+ readonly custom: {
1044
+ readonly name: string;
1045
+ readonly description: string;
1046
+ readonly format: {
1047
+ readonly type: "text";
1048
+ } | {
1049
+ readonly type: "grammar";
1050
+ readonly grammar: {
1051
+ readonly syntax: "lark" | "regex";
1052
+ readonly definition: string;
1053
+ };
1054
+ };
1055
+ };
1056
+ readonly cache_control?: {
1057
+ readonly type: "ephemeral";
1058
+ readonly ttl?: string | undefined;
1059
+ } | undefined;
1060
+ })[] | undefined;
740
1061
  tool_choice?: "auto" | "none" | "required" | {
741
1062
  readonly type: "function";
742
1063
  readonly function: {
743
1064
  readonly name: string;
744
1065
  };
1066
+ } | {
1067
+ readonly type: "custom";
1068
+ readonly custom: {
1069
+ readonly name: string;
1070
+ };
745
1071
  } | undefined;
746
1072
  stream: true;
747
1073
  stream_options?: {
@@ -788,10 +1114,11 @@ export declare const routes: Route<{
788
1114
  } | undefined;
789
1115
  user?: string | undefined;
790
1116
  reasoning?: Record<string, unknown> | undefined;
791
- }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
792
- export declare const configure: (input?: LanguageModelOptions) => {
1117
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>)[];
1118
+ export declare const configure: (input?: Config) => {
793
1119
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
794
1120
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
1121
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
795
1122
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
796
1123
  decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
797
1124
  configure: typeof configure;
@@ -799,13 +1126,16 @@ export declare const configure: (input?: LanguageModelOptions) => {
799
1126
  export declare const provider: {
800
1127
  id: string & import("effect/Brand").Brand<"AI.ProviderID">;
801
1128
  model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<OpenRouterOptions, import("../route/client.js").CompactionOperations | undefined>;
1129
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
802
1130
  image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
803
1131
  decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
804
1132
  configure: typeof configure;
805
1133
  };
806
1134
  export declare const decision: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
807
1135
  export declare const image: (modelID: string | ModelID, providerOptions?: ProviderOptions) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
808
- export declare const model: ProviderPackage.Definition<Settings, OpenRouterProviderOptionsInput>["model"];
809
- export declare const imageModel: (modelID: string, settings: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
810
- export declare const decisionModel: (modelID: string, settings: Settings) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
811
- export {};
1136
+ export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
1137
+ export declare const model: ProviderPackage.Model<Settings, OpenRouterProviderOptionsInput>;
1138
+ export declare const responsesModel: ProviderPackage.Model<Settings<OpenResponsesProviderOptionsInput>, OpenResponsesProviderOptionsInput>;
1139
+ export declare const imageModel: (modelID: string, settings?: Settings) => import("../image.js").ImageModel<import("../protocols/openai-images.js").OpenAIImageOptions>;
1140
+ export declare const decisionModel: (modelID: string, settings?: Settings) => import("../decision.js").DecisionModel<OpenRouterDecisionOptions>;
1141
+ export * as OpenRouter from "./openrouter.js";
@@ -8,6 +8,7 @@ import { SystemOne } from "../protocols/system-one.js";
8
8
  import { OpenAIImages } from "../protocols/openai-images.js";
9
9
  import { MediaRoute } from "../route/media.js";
10
10
  import { OpenAIChat } from "../protocols/openai-chat.js";
11
+ import { OpenResponses } from "../protocols/open-responses.js";
11
12
  import { cacheControl } from "../protocols/utils/cache.js";
12
13
  import { isRecord, JsonObject, lenient, ProviderShared } from "../protocols/shared.js";
13
14
  export const id = ProviderID.make("openrouter");
@@ -82,6 +83,19 @@ const bodyOptions = (body, input, maxTokens) => {
82
83
  ...(known.reasoning !== undefined ? { reasoning: fitReasoning(known.reasoning, maxTokens) } : {}),
83
84
  };
84
85
  };
86
+ const IMAGE_RESOLUTIONS = new Set(["512", "768", "1K", "1.5K", "2K", "4K"]);
87
+ // A pixel `size` renders at the upstream's own tier (Gemini 2K comes back as 4K) and FLUX 3 rejects it, so sizing goes
88
+ // out as an aspect ratio and a resolution tier. Values OpenRouter doesn't list are left out.
89
+ const imageSizing = (request) => {
90
+ const resolution = request.resolution
91
+ ?.toUpperCase()
92
+ .replace(/^0\.5K$/, "512")
93
+ .replace(/^0\.75K$/, "768");
94
+ return {
95
+ aspect_ratio: request.aspect,
96
+ resolution: resolution !== undefined && IMAGE_RESOLUTIONS.has(resolution) ? resolution : undefined,
97
+ };
98
+ };
85
99
  export const route = Route.make({
86
100
  id: ADAPTER,
87
101
  provider: id,
@@ -90,18 +104,22 @@ export const route = Route.make({
90
104
  endpoint: Endpoint.path("/chat/completions", { baseURL }),
91
105
  framing: OpenAIChat.framing,
92
106
  });
93
- export const routes = [route];
94
- const configuredRoute = (input) => {
95
- const { apiKey: _, auth: _auth, baseURL: endpoint, ...rest } = input;
96
- return route.with({
97
- ...rest,
98
- endpoint: { baseURL: endpoint ?? baseURL },
99
- auth: AuthOptions.bearer(input, "OPENROUTER_API_KEY"),
100
- });
101
- };
107
+ const responsesRoute = Route.make({
108
+ id: "openrouter-responses",
109
+ provider: id,
110
+ providerMetadataKey: "openrouter",
111
+ protocol: OpenResponses.protocol,
112
+ endpoint: Endpoint.path("/responses", { baseURL }),
113
+ transport: OpenResponses.httpTransport,
114
+ defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
115
+ });
116
+ export const routes = [route, responsesRoute];
102
117
  export const configure = (input = {}) => {
103
- const route = configuredRoute(input);
118
+ const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
104
119
  const auth = AuthOptions.bearer(input, "OPENROUTER_API_KEY");
120
+ const options = { ...defaults, endpoint: { baseURL: endpoint ?? baseURL }, auth };
121
+ const chatRoute = route.with(options);
122
+ const configuredResponses = responsesRoute.with(options);
105
123
  const decisionRoute = SystemOne.route.with({
106
124
  provider: id,
107
125
  providerMetadataKey: "openrouter",
@@ -111,7 +129,14 @@ export const configure = (input = {}) => {
111
129
  http: input.http,
112
130
  });
113
131
  const media = MediaRoute.deployment({ ...input, baseURL: input.baseURL ?? baseURL }, auth);
114
- const image = (modelID, providerOptions) => OpenAIImages.model({ ...media, id: modelID, provider: id, providerOptions });
132
+ const image = (modelID, providerOptions) => OpenAIImages.model({
133
+ ...media,
134
+ id: modelID,
135
+ provider: id,
136
+ providerOptions,
137
+ sizing: imageSizing,
138
+ imageInput: "references",
139
+ });
115
140
  const decision = (modelID, providerOptions) => decisionRoute.model({
116
141
  id: modelID,
117
142
  compatibility: { mediaInput: "state" },
@@ -119,7 +144,8 @@ export const configure = (input = {}) => {
119
144
  });
120
145
  return {
121
146
  id,
122
- model: (modelID) => route.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } }),
147
+ model: (modelID) => chatRoute.model({ id: modelID, compatibility: { supportsPromptCacheKey: true } }),
148
+ responses: (modelID) => configuredResponses.model({ id: modelID }),
123
149
  image,
124
150
  decision,
125
151
  configure,
@@ -128,7 +154,9 @@ export const configure = (input = {}) => {
128
154
  export const provider = configure();
129
155
  export const decision = provider.decision;
130
156
  export const image = provider.image;
157
+ export const responses = provider.responses;
131
158
  export const model = (modelID, settings) => configure(config(settings)).model(modelID);
159
+ export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
132
160
  export const imageModel = (modelID, settings) => {
133
161
  const input = config(settings);
134
162
  return configure(input).image(modelID, input.providerOptions);
@@ -137,7 +165,7 @@ export const decisionModel = (modelID, settings) => {
137
165
  const input = config(settings);
138
166
  return configure(input).decision(modelID, input.providerOptions);
139
167
  };
140
- function config({ apiKey, baseURL, body, headers, ...providerOptions }) {
168
+ function config({ apiKey, baseURL, body, headers, ...providerOptions } = {}) {
141
169
  return {
142
170
  apiKey,
143
171
  baseURL,
@@ -146,3 +174,4 @@ function config({ apiKey, baseURL, body, headers, ...providerOptions }) {
146
174
  providerOptions,
147
175
  };
148
176
  }
177
+ export * as OpenRouter from "./openrouter.js";