@opencode/ai 2.0.16 → 2.0.18

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 (185) hide show
  1. package/README.md +187 -129
  2. package/dist/ai-client.d.ts +8 -0
  3. package/dist/ai-client.js +12 -0
  4. package/dist/experimental/evaluation-client.d.ts +3 -3
  5. package/dist/experimental/evaluation-client.js +1 -1
  6. package/dist/experimental/evaluation.js +1 -1
  7. package/dist/generation.d.ts +6 -10
  8. package/dist/generation.js +17 -20
  9. package/dist/image-client.d.ts +59 -24
  10. package/dist/image-client.js +16 -40
  11. package/dist/image.d.ts +15 -27
  12. package/dist/image.js +4 -15
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +1 -0
  15. package/dist/llm.d.ts +7 -5
  16. package/dist/llm.js +10 -4
  17. package/dist/media-client.d.ts +30 -0
  18. package/dist/media-client.js +51 -0
  19. package/dist/media-model.d.ts +9 -10
  20. package/dist/media-model.js +10 -12
  21. package/dist/media.js +2 -2
  22. package/dist/promise.d.ts +68 -30
  23. package/dist/promise.js +52 -31
  24. package/dist/protocols/alibaba-chat.js +4 -1
  25. package/dist/protocols/alibaba-messages.d.ts +1 -1
  26. package/dist/protocols/alibaba-messages.js +6 -4
  27. package/dist/protocols/anthropic-messages.d.ts +34 -34
  28. package/dist/protocols/anthropic-messages.js +14 -8
  29. package/dist/protocols/assemblyai-transcription.d.ts +2 -1
  30. package/dist/protocols/assemblyai-transcription.js +14 -16
  31. package/dist/protocols/bedrock-converse.d.ts +7 -0
  32. package/dist/protocols/bedrock-converse.js +37 -11
  33. package/dist/protocols/bfl-images.d.ts +7 -1
  34. package/dist/protocols/bfl-images.js +36 -36
  35. package/dist/protocols/cartesia-speech.d.ts +18 -2
  36. package/dist/protocols/cartesia-speech.js +10 -16
  37. package/dist/protocols/deepgram-speech.d.ts +19 -3
  38. package/dist/protocols/deepgram-speech.js +11 -12
  39. package/dist/protocols/deepgram-transcription.d.ts +2 -1
  40. package/dist/protocols/deepgram-transcription.js +9 -13
  41. package/dist/protocols/elevenlabs-speech.d.ts +19 -3
  42. package/dist/protocols/elevenlabs-speech.js +9 -13
  43. package/dist/protocols/fal-images.d.ts +2 -1
  44. package/dist/protocols/fal-images.js +30 -40
  45. package/dist/protocols/fal-video.d.ts +2 -2
  46. package/dist/protocols/fal-video.js +9 -24
  47. package/dist/protocols/gemini.d.ts +13 -13
  48. package/dist/protocols/gemini.js +16 -7
  49. package/dist/protocols/google-images.d.ts +3 -3
  50. package/dist/protocols/google-images.js +11 -21
  51. package/dist/protocols/google-speech.d.ts +16 -0
  52. package/dist/protocols/google-speech.js +20 -16
  53. package/dist/protocols/google-transcription.d.ts +2 -1
  54. package/dist/protocols/google-transcription.js +8 -20
  55. package/dist/protocols/google-video.d.ts +2 -2
  56. package/dist/protocols/google-video.js +14 -30
  57. package/dist/protocols/meta-images.d.ts +3 -4
  58. package/dist/protocols/meta-images.js +12 -21
  59. package/dist/protocols/meta-messages.d.ts +5 -5
  60. package/dist/protocols/meta-responses.js +6 -4
  61. package/dist/protocols/open-responses.d.ts +4 -3
  62. package/dist/protocols/open-responses.js +4 -8
  63. package/dist/protocols/openai-chat.js +3 -4
  64. package/dist/protocols/openai-images.d.ts +7 -5
  65. package/dist/protocols/openai-images.js +65 -66
  66. package/dist/protocols/openai-responses.d.ts +10 -10
  67. package/dist/protocols/openai-responses.js +31 -30
  68. package/dist/protocols/openai-speech.d.ts +21 -1
  69. package/dist/protocols/openai-speech.js +11 -12
  70. package/dist/protocols/openai-transcription.d.ts +4 -0
  71. package/dist/protocols/openai-transcription.js +44 -32
  72. package/dist/protocols/replicate-images.js +11 -17
  73. package/dist/protocols/runway-video.d.ts +3 -3
  74. package/dist/protocols/runway-video.js +11 -17
  75. package/dist/protocols/shared.d.ts +11 -17
  76. package/dist/protocols/shared.js +11 -40
  77. package/dist/protocols/stability-images.d.ts +2 -1
  78. package/dist/protocols/stability-images.js +24 -36
  79. package/dist/protocols/utils/fal-queue.d.ts +1 -3
  80. package/dist/protocols/utils/fal-queue.js +4 -6
  81. package/dist/protocols/utils/media-input.d.ts +15 -1
  82. package/dist/protocols/utils/media-input.js +22 -0
  83. package/dist/protocols/utils/responses-checkpoint.js +3 -7
  84. package/dist/protocols/utils/responses-compaction.d.ts +3 -1
  85. package/dist/protocols/utils/responses-compaction.js +16 -3
  86. package/dist/protocols/utils/speech-stream.d.ts +3 -3
  87. package/dist/protocols/utils/speech-stream.js +1 -4
  88. package/dist/protocols/utils/tool-schema.d.ts +2 -2
  89. package/dist/protocols/utils/tool-schema.js +29 -9
  90. package/dist/protocols/xai-images.d.ts +4 -4
  91. package/dist/protocols/xai-images.js +14 -29
  92. package/dist/protocols/xai-responses.js +1 -1
  93. package/dist/protocols/xai-video.js +12 -18
  94. package/dist/protocols/zai-images.d.ts +2 -2
  95. package/dist/protocols/zai-images.js +11 -14
  96. package/dist/protocols/zai-messages.d.ts +1 -1
  97. package/dist/provider-error.js +7 -1
  98. package/dist/providers/alibaba.d.ts +1 -1
  99. package/dist/providers/amazon-bedrock.d.ts +2 -0
  100. package/dist/providers/amazon-bedrock.js +1 -0
  101. package/dist/providers/anthropic-compatible.d.ts +5 -5
  102. package/dist/providers/anthropic.d.ts +5 -5
  103. package/dist/providers/assemblyai.d.ts +1 -1
  104. package/dist/providers/assemblyai.js +5 -10
  105. package/dist/providers/azure.d.ts +4 -4
  106. package/dist/providers/azure.js +2 -2
  107. package/dist/providers/black-forest-labs.d.ts +1 -1
  108. package/dist/providers/black-forest-labs.js +5 -10
  109. package/dist/providers/cartesia.d.ts +1 -1
  110. package/dist/providers/cartesia.js +5 -10
  111. package/dist/providers/cloudflare-ai-gateway.d.ts +14 -14
  112. package/dist/providers/deepgram.d.ts +1 -1
  113. package/dist/providers/deepgram.js +6 -12
  114. package/dist/providers/elevenlabs.d.ts +1 -1
  115. package/dist/providers/elevenlabs.js +5 -10
  116. package/dist/providers/fal.d.ts +1 -1
  117. package/dist/providers/fal.js +5 -12
  118. package/dist/providers/google-vertex-messages.d.ts +5 -5
  119. package/dist/providers/google-vertex.d.ts +3 -3
  120. package/dist/providers/google.d.ts +3 -3
  121. package/dist/providers/google.js +7 -12
  122. package/dist/providers/meta.d.ts +8 -8
  123. package/dist/providers/meta.js +4 -8
  124. package/dist/providers/minimax.d.ts +5 -5
  125. package/dist/providers/moonshot.d.ts +5 -5
  126. package/dist/providers/openai-options.d.ts +3 -9
  127. package/dist/providers/openai-options.js +4 -7
  128. package/dist/providers/openai.d.ts +9 -10
  129. package/dist/providers/openai.js +11 -12
  130. package/dist/providers/opencode-zen.js +1 -1
  131. package/dist/providers/openrouter.d.ts +6 -7
  132. package/dist/providers/openrouter.js +10 -5
  133. package/dist/providers/replicate.d.ts +1 -1
  134. package/dist/providers/replicate.js +5 -10
  135. package/dist/providers/runway.d.ts +1 -1
  136. package/dist/providers/runway.js +5 -10
  137. package/dist/providers/stability.d.ts +1 -1
  138. package/dist/providers/stability.js +6 -11
  139. package/dist/providers/typesafe-ai.js +1 -1
  140. package/dist/providers/vercel-ai-gateway.js +1 -1
  141. package/dist/providers/xai.js +5 -10
  142. package/dist/providers/zai-coding-plan.d.ts +1 -1
  143. package/dist/providers/zai.js +4 -8
  144. package/dist/route/auth.d.ts +1 -1
  145. package/dist/route/auth.js +14 -13
  146. package/dist/route/client.d.ts +9 -7
  147. package/dist/route/client.js +6 -8
  148. package/dist/route/endpoint.d.ts +1 -0
  149. package/dist/route/endpoint.js +2 -2
  150. package/dist/route/executor-service.d.ts +4 -2
  151. package/dist/route/executor-service.js +2 -1
  152. package/dist/route/executor.d.ts +3 -1
  153. package/dist/route/executor.js +7 -0
  154. package/dist/route/framing.d.ts +10 -1
  155. package/dist/route/framing.js +45 -5
  156. package/dist/route/index.d.ts +1 -1
  157. package/dist/route/media-protocol.d.ts +49 -35
  158. package/dist/route/media-protocol.js +77 -65
  159. package/dist/route/media.d.ts +10 -16
  160. package/dist/route/media.js +46 -62
  161. package/dist/route/protocol.d.ts +3 -1
  162. package/dist/schema/options.d.ts +6 -3
  163. package/dist/schema/options.js +7 -3
  164. package/dist/speech-client.d.ts +62 -17
  165. package/dist/speech-client.js +17 -21
  166. package/dist/speech.d.ts +178 -21
  167. package/dist/speech.js +13 -8
  168. package/dist/testing.d.ts +2 -2
  169. package/dist/transcription-client.d.ts +78 -24
  170. package/dist/transcription-client.js +9 -40
  171. package/dist/transcription.d.ts +15 -27
  172. package/dist/transcription.js +4 -10
  173. package/dist/utils/json.d.ts +4 -0
  174. package/dist/utils/json.js +4 -0
  175. package/dist/utils/media-type.d.ts +2 -1
  176. package/dist/utils/media-type.js +3 -1
  177. package/dist/video-client.d.ts +55 -24
  178. package/dist/video-client.js +16 -36
  179. package/dist/video.d.ts +18 -26
  180. package/dist/video.js +15 -16
  181. package/package.json +3 -3
  182. package/dist/protocols/utils/meta-image.d.ts +0 -2
  183. package/dist/protocols/utils/meta-image.js +0 -13
  184. package/dist/protocols/utils/openai-image.d.ts +0 -5
  185. package/dist/protocols/utils/openai-image.js +0 -18
@@ -1,8 +1,8 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { HttpOptions, ProviderID } from "../schema/index.js";
3
- import { DEFAULT_BASE_URL, ElevenLabsSpeech } from "../protocols/elevenlabs-speech.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { ElevenLabsSpeech } from "../protocols/elevenlabs-speech.js";
4
5
  export const id = ProviderID.make("elevenlabs");
5
- const baseURL = DEFAULT_BASE_URL;
6
6
  const auth = (options) => {
7
7
  if ("auth" in options && options.auth)
8
8
  return options.auth;
@@ -11,13 +11,8 @@ const auth = (options) => {
11
11
  .pipe(Auth.header("xi-api-key"));
12
12
  };
13
13
  export const configure = (input = {}) => {
14
- const speech = (modelID) => ElevenLabsSpeech.model({
15
- id: modelID,
16
- auth: auth(input),
17
- baseURL: input.baseURL ?? baseURL,
18
- headers: input.headers,
19
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
20
- });
14
+ const media = MediaRoute.deployment(input, auth(input));
15
+ const speech = (modelID) => ElevenLabsSpeech.model({ ...media, id: modelID });
21
16
  return {
22
17
  id,
23
18
  speech,
@@ -1,5 +1,5 @@
1
1
  import type { ProviderAuthOption } from "../route/auth-options.js";
2
- import { HttpOptions, type ModelID } from "../schema/index.js";
2
+ import { type HttpOptions, type ModelID } from "../schema/index.js";
3
3
  export type { FalImageOptions } from "../protocols/fal-images.js";
4
4
  export type { FalVideoOptions } from "../protocols/fal-video.js";
5
5
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1,10 +1,9 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { HttpOptions, ProviderID } from "../schema/index.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
3
4
  import { FalImages } from "../protocols/fal-images.js";
4
5
  import { FalVideo } from "../protocols/fal-video.js";
5
- import { FalQueue } from "../protocols/utils/fal-queue.js";
6
6
  export const id = ProviderID.make("fal");
7
- const baseURL = FalQueue.DEFAULT_BASE_URL;
8
7
  // fal authenticates with `Authorization: Key <FAL_KEY>` rather than a bearer token.
9
8
  const auth = (options) => {
10
9
  if ("auth" in options && options.auth)
@@ -14,17 +13,11 @@ const auth = (options) => {
14
13
  .pipe(Auth.scheme("Key"));
15
14
  };
16
15
  export const configure = (input = {}) => {
17
- const media = (modelID) => ({
18
- id: modelID,
19
- auth: auth(input),
20
- baseURL: input.baseURL ?? baseURL,
21
- headers: input.headers,
22
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
23
- });
16
+ const media = MediaRoute.deployment(input, auth(input));
24
17
  return {
25
18
  id,
26
- image: (modelID) => FalImages.model(media(modelID)),
27
- video: (modelID) => FalVideo.model(media(modelID)),
19
+ image: (modelID) => FalImages.model({ ...media, id: modelID }),
20
+ video: (modelID) => FalVideo.model({ ...media, id: modelID }),
28
21
  configure,
29
22
  };
30
23
  };
@@ -236,20 +236,20 @@ export declare const routes: Route<{
236
236
  thinking?: {
237
237
  readonly type: "enabled";
238
238
  readonly budget_tokens: number;
239
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
239
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
240
240
  readonly block_binding?: {
241
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
241
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
242
242
  } | undefined;
243
243
  } | {
244
244
  readonly type: "adaptive";
245
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
245
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
246
246
  readonly block_binding?: {
247
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
247
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
248
248
  } | undefined;
249
249
  } | {
250
250
  readonly type: "disabled";
251
251
  } | undefined;
252
- service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
252
+ service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
253
253
  container?: string | {
254
254
  readonly id?: string | null | undefined;
255
255
  readonly skills?: readonly {
@@ -83,8 +83,8 @@ export declare const routes: Route<{
83
83
  } | undefined;
84
84
  readonly cachedContent?: string | undefined;
85
85
  readonly safetySettings?: readonly {
86
- readonly category: (string & {}) | "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY";
87
- readonly threshold: (string & {}) | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF";
86
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">;
87
+ readonly threshold: import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">;
88
88
  }[] | undefined;
89
89
  readonly labels?: {
90
90
  readonly [x: string]: string;
@@ -105,7 +105,7 @@ export declare const routes: Route<{
105
105
  readonly thinkingConfig?: {
106
106
  readonly thinkingBudget?: number | undefined;
107
107
  readonly includeThoughts?: boolean | undefined;
108
- readonly thinkingLevel?: (string & {}) | "minimal" | "low" | "medium" | "high" | undefined;
108
+ readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
109
109
  } | undefined;
110
110
  readonly maxOutputTokens?: number | undefined;
111
111
  } | undefined;
@@ -68,8 +68,8 @@ export declare const routes: import("../route/client.js").Route<{
68
68
  } | undefined;
69
69
  readonly cachedContent?: string | undefined;
70
70
  readonly safetySettings?: readonly {
71
- readonly category: (string & {}) | "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY";
72
- readonly threshold: (string & {}) | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF";
71
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">;
72
+ readonly threshold: import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">;
73
73
  }[] | undefined;
74
74
  readonly labels?: {
75
75
  readonly [x: string]: string;
@@ -90,7 +90,7 @@ export declare const routes: import("../route/client.js").Route<{
90
90
  readonly thinkingConfig?: {
91
91
  readonly thinkingBudget?: number | undefined;
92
92
  readonly includeThoughts?: boolean | undefined;
93
- readonly thinkingLevel?: (string & {}) | "minimal" | "low" | "medium" | "high" | undefined;
93
+ readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
94
94
  } | undefined;
95
95
  readonly maxOutputTokens?: number | undefined;
96
96
  } | undefined;
@@ -1,5 +1,6 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { HttpOptions, ProviderID, mergeHttpOptions } from "../schema/index.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
3
4
  import { Gemini } from "../protocols/gemini.js";
4
5
  import { GoogleImages } from "../protocols/google-images.js";
5
6
  import { GoogleSpeech } from "../protocols/google-speech.js";
@@ -20,20 +21,14 @@ const configuredRoute = (input) => {
20
21
  };
21
22
  export const configure = (input = {}) => {
22
23
  const route = configuredRoute(input);
23
- const media = (modelID) => ({
24
- id: modelID,
25
- auth: auth(input),
26
- baseURL: input.baseURL,
27
- headers: input.headers,
28
- http: mergeHttpOptions(input.http === undefined ? undefined : HttpOptions.make(input.http)),
29
- });
24
+ const media = MediaRoute.deployment(input, auth(input));
30
25
  return {
31
26
  id,
32
27
  model: (modelID) => route.model({ id: modelID }),
33
- image: (modelID) => GoogleImages.model(media(modelID)),
34
- video: (modelID) => GoogleVideo.model(media(modelID)),
35
- speech: (modelID) => GoogleSpeech.model(media(modelID)),
36
- transcription: (modelID) => GoogleTranscription.model(media(modelID)),
28
+ image: (modelID) => GoogleImages.model({ ...media, id: modelID }),
29
+ video: (modelID) => GoogleVideo.model({ ...media, id: modelID }),
30
+ speech: (modelID) => GoogleSpeech.model({ ...media, id: modelID }),
31
+ transcription: (modelID) => GoogleTranscription.model({ ...media, id: modelID }),
37
32
  configure,
38
33
  };
39
34
  };
@@ -3,7 +3,7 @@ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
3
3
  import { MetaImages } from "../protocols/meta-images.js";
4
4
  import { type ProviderAuthOption } from "../route/auth-options.js";
5
5
  import { Route, type RouteDefaultsInput } from "../route/client.js";
6
- import { ToolDefinition, type ModelID } from "../schema/index.js";
6
+ import { ToolDefinition, type ModelID, type OpenString } from "../schema/index.js";
7
7
  import type { OpenResponsesProviderOptionsInput } from "./open-responses-options.js";
8
8
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
9
9
  export type ProviderOptionsInput = OpenResponsesProviderOptionsInput & Pick<AnthropicMessages.OptionsInput, "thinking" | "effort">;
@@ -23,8 +23,8 @@ export interface WebSearchOptions {
23
23
  export declare const webSearch: (options?: WebSearchOptions) => ToolDefinition;
24
24
  export interface ImageGenerationOptions {
25
25
  readonly size?: string;
26
- readonly outputFormat?: "webp" | "png" | "jpeg" | (string & {});
27
- readonly reasoningStrength?: "low" | "high" | (string & {});
26
+ readonly outputFormat?: OpenString<"webp" | "png" | "jpeg">;
27
+ readonly reasoningStrength?: OpenString<"low" | "high">;
28
28
  readonly enableImageSearch?: boolean;
29
29
  readonly enableWebSearch?: boolean;
30
30
  readonly enableShell?: boolean;
@@ -560,20 +560,20 @@ export declare const routes: (Route<{
560
560
  readonly thinking?: {
561
561
  readonly type: "enabled";
562
562
  readonly budget_tokens: number;
563
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
563
+ readonly display?: OpenString<"summarized" | "omitted"> | undefined;
564
564
  readonly block_binding?: {
565
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
565
+ readonly prefix_mismatch_behavior?: OpenString<"error" | "drop_block"> | undefined;
566
566
  } | undefined;
567
567
  } | {
568
568
  readonly type: "adaptive";
569
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
569
+ readonly display?: OpenString<"summarized" | "omitted"> | undefined;
570
570
  readonly block_binding?: {
571
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
571
+ readonly prefix_mismatch_behavior?: OpenString<"error" | "drop_block"> | undefined;
572
572
  } | undefined;
573
573
  } | {
574
574
  readonly type: "disabled";
575
575
  } | undefined;
576
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
576
+ readonly service_tier?: OpenString<"auto" | "standard_only"> | undefined;
577
577
  readonly container?: string | {
578
578
  readonly id?: string | null | undefined;
579
579
  readonly skills?: readonly {
@@ -6,7 +6,8 @@ import { MetaImages } from "../protocols/meta-images.js";
6
6
  import { AuthOptions } from "../route/auth-options.js";
7
7
  import { Route } from "../route/client.js";
8
8
  import { Endpoint } from "../route/endpoint.js";
9
- import { HttpOptions, ProviderID, ToolDefinition } from "../schema/index.js";
9
+ import { MediaRoute } from "../route/media.js";
10
+ import { ProviderID, ToolDefinition } from "../schema/index.js";
10
11
  export const id = ProviderID.make("meta");
11
12
  const baseURL = "https://api.meta.ai/v1";
12
13
  export const webSearch = (options = {}) => ToolDefinition.make({
@@ -84,13 +85,8 @@ export const configure = (input = {}) => {
84
85
  id: modelID,
85
86
  compatibility: { requireSignature: false },
86
87
  });
87
- const image = (modelID) => MetaImages.model({
88
- id: modelID,
89
- baseURL: endpoint ?? baseURL,
90
- auth: options.auth,
91
- headers: input.headers,
92
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
93
- });
88
+ const media = MediaRoute.deployment(input, options.auth);
89
+ const image = (modelID) => MetaImages.model({ ...media, id: modelID });
94
90
  return { id, model: responses, responses, chat, messages, image, configure };
95
91
  };
96
92
  export const provider = configure();
@@ -249,20 +249,20 @@ export declare const routes: (Route<{
249
249
  readonly thinking?: {
250
250
  readonly type: "enabled";
251
251
  readonly budget_tokens: number;
252
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
252
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
253
253
  readonly block_binding?: {
254
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
254
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
255
255
  } | undefined;
256
256
  } | {
257
257
  readonly type: "adaptive";
258
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
258
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
259
259
  readonly block_binding?: {
260
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
260
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
261
261
  } | undefined;
262
262
  } | {
263
263
  readonly type: "disabled";
264
264
  } | undefined;
265
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
265
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
266
266
  readonly container?: string | {
267
267
  readonly id?: string | null | undefined;
268
268
  readonly skills?: readonly {
@@ -247,20 +247,20 @@ export declare const routes: (Route<{
247
247
  readonly thinking?: {
248
248
  readonly type: "enabled";
249
249
  readonly budget_tokens: number;
250
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
250
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
251
251
  readonly block_binding?: {
252
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
252
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
253
253
  } | undefined;
254
254
  } | {
255
255
  readonly type: "adaptive";
256
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
256
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
257
257
  readonly block_binding?: {
258
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
258
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
259
259
  } | undefined;
260
260
  } | {
261
261
  readonly type: "disabled";
262
262
  } | undefined;
263
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
263
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
264
264
  readonly container?: string | {
265
265
  readonly id?: string | null | undefined;
266
266
  readonly skills?: readonly {
@@ -10,17 +10,11 @@ export type OpenAIOptionsInput = Omit<Options, "serviceTier"> & {
10
10
  readonly [key: string]: unknown;
11
11
  };
12
12
  export type OpenAIProviderOptionsInput = OpenAIOptionsInput;
13
- export declare const gpt5DefaultOptions: (modelID: string, options?: {
14
- readonly textVerbosity?: boolean;
15
- }) => ProviderOptions | undefined;
16
- export declare const openAIDefaultOptions: (modelID: string, options?: {
17
- readonly textVerbosity?: boolean;
18
- }) => ProviderOptions | undefined;
13
+ export declare const gpt5DefaultOptions: (modelID: string) => ProviderOptions | undefined;
14
+ export declare const openAIDefaultOptions: (modelID: string) => ProviderOptions | undefined;
19
15
  export declare const withOpenAIOptions: <Options extends {
20
16
  readonly providerOptions?: OpenAIProviderOptionsInput;
21
- }>(modelID: string, options: Options, defaults?: {
22
- readonly textVerbosity?: boolean;
23
- }) => Omit<Options, "providerOptions"> & {
17
+ }>(modelID: string, options: Options) => Omit<Options, "providerOptions"> & {
24
18
  readonly providerOptions?: ProviderOptions;
25
19
  };
26
20
  export * as OpenAIProviderOptions from "./openai-options.js";
@@ -13,7 +13,7 @@ const openAIProviderOptions = (options) => {
13
13
  return undefined;
14
14
  return result;
15
15
  };
16
- export const gpt5DefaultOptions = (modelID, options = {}) => {
16
+ export const gpt5DefaultOptions = (modelID) => {
17
17
  const id = modelID.toLowerCase();
18
18
  if (!id.includes("gpt-5") || id.includes("gpt-5-chat") || id.includes("gpt-5-pro"))
19
19
  return undefined;
@@ -26,16 +26,13 @@ export const gpt5DefaultOptions = (modelID, options = {}) => {
26
26
  // this, callers using the default model facade get reasoning summaries
27
27
  // they cannot replay statelessly.
28
28
  include: ["reasoning.encrypted_content"],
29
- textVerbosity: options.textVerbosity === true && id.includes("gpt-5.") && !id.includes("codex") && !id.includes("-chat")
30
- ? "low"
31
- : undefined,
32
29
  });
33
30
  };
34
- export const openAIDefaultOptions = (modelID, options = {}) => mergeProviderOptions(openAIProviderOptions({ store: false }), gpt5DefaultOptions(modelID, options));
35
- export const withOpenAIOptions = (modelID, options, defaults = {}) => {
31
+ export const openAIDefaultOptions = (modelID) => mergeProviderOptions(openAIProviderOptions({ store: false }), gpt5DefaultOptions(modelID));
32
+ export const withOpenAIOptions = (modelID, options) => {
36
33
  return {
37
34
  ...options,
38
- providerOptions: mergeProviderOptions(openAIDefaultOptions(modelID, defaults), options.providerOptions),
35
+ providerOptions: mergeProviderOptions(openAIDefaultOptions(modelID), options.providerOptions),
39
36
  };
40
37
  };
41
38
  export * as OpenAIProviderOptions from "./openai-options.js";
@@ -1,10 +1,9 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
2
  import type { Route, RouteDefaultsInput, CompactionOperations } from "../route/client.js";
3
3
  import type { ProviderPackage } from "../provider-package.js";
4
- import { ToolDefinition, type ModelID } from "../schema/index.js";
4
+ import { ToolDefinition, type ModelID, type OpenString } from "../schema/index.js";
5
5
  import * as OpenAIResponses from "../protocols/openai-responses.js";
6
6
  import { type OpenAIProviderOptionsInput } from "./openai-options.js";
7
- import { type OpenAIImageString } from "../protocols/openai-images.js";
8
7
  export type { OpenAIOptionsInput, OpenAIResponseIncludable } from "./openai-options.js";
9
8
  export type { OpenAIImageOptions } from "../protocols/openai-images.js";
10
9
  export type { OpenAISpeechOptions } from "../protocols/openai-speech.js";
@@ -265,8 +264,8 @@ export declare const routes: (Route<{
265
264
  readonly type: "image_generation_call";
266
265
  readonly status?: string | undefined;
267
266
  readonly result?: string | null | undefined;
268
- readonly revised_prompt?: string | null | undefined;
269
267
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
268
+ readonly revised_prompt?: string | null | undefined;
270
269
  })[];
271
270
  readonly model: string;
272
271
  readonly stream: true;
@@ -291,9 +290,9 @@ export declare const routes: (Route<{
291
290
  readonly size?: string | undefined;
292
291
  readonly action?: "generate" | "auto" | "edit" | undefined;
293
292
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
294
- readonly partial_images?: number | undefined;
295
293
  readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
296
294
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
295
+ readonly partial_images?: number | undefined;
297
296
  readonly output_compression?: number | undefined;
298
297
  readonly input_fidelity?: "low" | "high" | undefined;
299
298
  } | {
@@ -357,14 +356,14 @@ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
357
356
  readonly providerOptions?: OpenAIProviderOptionsInput;
358
357
  };
359
358
  export interface ImageGenerationOptions {
360
- readonly action?: OpenAIImageString<"auto" | "generate" | "edit">;
361
- readonly background?: OpenAIImageString<"auto" | "opaque" | "transparent">;
362
- readonly inputFidelity?: OpenAIImageString<"low" | "high">;
359
+ readonly action?: OpenString<"auto" | "generate" | "edit">;
360
+ readonly background?: OpenString<"auto" | "opaque" | "transparent">;
361
+ readonly inputFidelity?: OpenString<"low" | "high">;
363
362
  readonly outputCompression?: number;
364
- readonly outputFormat?: OpenAIImageString<"png" | "jpeg" | "webp">;
363
+ readonly outputFormat?: OpenString<"png" | "jpeg" | "webp">;
365
364
  readonly partialImages?: number;
366
- readonly quality?: OpenAIImageString<"auto" | "low" | "medium" | "high" | "standard" | "hd">;
367
- readonly size?: OpenAIImageString<"auto" | "256x256" | "512x512" | "1024x1024" | "1536x1024" | "1024x1536" | "1792x1024" | "1024x1792">;
365
+ readonly quality?: OpenString<"auto" | "low" | "medium" | "high" | "standard" | "hd">;
366
+ readonly size?: OpenString<"auto" | "256x256" | "512x512" | "1024x1024" | "1536x1024" | "1024x1536" | "1792x1024" | "1024x1792">;
368
367
  }
369
368
  export declare const imageGeneration: (options?: ImageGenerationOptions) => ToolDefinition;
370
369
  export type Settings = ProviderPackage.Settings & OpenAIProviderOptionsInput & {
@@ -1,5 +1,6 @@
1
1
  import { AuthOptions } from "../route/auth-options.js";
2
- import { HttpOptions, ProviderID, ToolDefinition, mergeHttpOptions } from "../schema/index.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { HttpOptions, ProviderID, ToolDefinition, mergeHttpOptions, } from "../schema/index.js";
3
4
  import * as OpenAIChat from "../protocols/openai-chat.js";
4
5
  import * as OpenAIResponses from "../protocols/openai-responses.js";
5
6
  import { withOpenAIOptions } from "./openai-options.js";
@@ -40,22 +41,20 @@ export const configure = (input = {}) => {
40
41
  const chatRoute = configuredRoute(OpenAIChat.route, input);
41
42
  const modelDefaults = defaults(input);
42
43
  const responses = (id) => responsesRoute
43
- .with(withOpenAIOptions(id, modelDefaults, { textVerbosity: true }))
44
+ .with(withOpenAIOptions(id, modelDefaults))
44
45
  .model({ id });
45
46
  const chat = (id) => chatRoute.with(withOpenAIOptions(id, modelDefaults)).model({
46
47
  id,
47
48
  compatibility: { supportsPromptCacheKey: true },
48
49
  });
49
- const media = (modelID) => ({
50
- id: modelID,
51
- auth: auth(input),
52
- baseURL: input.baseURL,
53
- headers: input.headers,
54
- http: mergeHttpOptions(input.http === undefined ? undefined : HttpOptions.make(input.http), input.queryParams === undefined ? undefined : new HttpOptions({ query: input.queryParams })),
55
- });
56
- const image = (modelID) => OpenAIImages.model(media(modelID));
57
- const speech = (modelID) => OpenAISpeech.model(media(modelID));
58
- const transcription = (modelID) => OpenAITranscription.model(media(modelID));
50
+ const deployment = MediaRoute.deployment(input, auth(input));
51
+ const media = {
52
+ ...deployment,
53
+ http: mergeHttpOptions(deployment.http, input.queryParams === undefined ? undefined : new HttpOptions({ query: input.queryParams })),
54
+ };
55
+ const image = (modelID) => OpenAIImages.model({ ...media, id: modelID });
56
+ const speech = (modelID) => OpenAISpeech.model({ ...media, id: modelID });
57
+ const transcription = (modelID) => OpenAITranscription.model({ ...media, id: modelID });
59
58
  return {
60
59
  id,
61
60
  model: responses,
@@ -11,7 +11,7 @@ export const configure = (input = {}) => {
11
11
  auth: AuthOptions.bearer(input, "OPENCODE_API_KEY"),
12
12
  baseURL: input.baseURL ?? baseURL,
13
13
  headers: input.headers,
14
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
14
+ http: HttpOptions.make(input.http),
15
15
  });
16
16
  return { id, experimental: { evaluation }, configure };
17
17
  };
@@ -2,21 +2,20 @@ import { Schema } from "effect";
2
2
  import { Route, type RouteDefaultsInput } from "../route/client.js";
3
3
  import { Protocol } from "../route/protocol.js";
4
4
  import { type ProviderAuthOption } from "../route/auth-options.js";
5
- import { type ModelID } from "../schema/index.js";
5
+ import { type ModelID, type OpenString } from "../schema/index.js";
6
6
  import type { ProviderPackage } from "../provider-package.js";
7
7
  import { OpenAIChat } from "../protocols/openai-chat.js";
8
8
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
9
- type OpenRouterString<Known extends string> = Known | (string & {});
10
9
  export interface OpenRouterProviderRouting {
11
10
  readonly [key: string]: unknown;
12
11
  readonly order?: ReadonlyArray<string>;
13
12
  readonly allow_fallbacks?: boolean;
14
13
  readonly require_parameters?: boolean;
15
- readonly data_collection?: OpenRouterString<"allow" | "deny">;
14
+ readonly data_collection?: OpenString<"allow" | "deny">;
16
15
  readonly only?: ReadonlyArray<string>;
17
16
  readonly ignore?: ReadonlyArray<string>;
18
17
  readonly quantizations?: ReadonlyArray<string>;
19
- readonly sort?: OpenRouterString<"price" | "throughput" | "latency">;
18
+ readonly sort?: OpenString<"price" | "throughput" | "latency">;
20
19
  readonly max_price?: Readonly<{
21
20
  prompt?: number | string;
22
21
  completion?: number | string;
@@ -30,7 +29,7 @@ export type OpenRouterPlugin = Readonly<{
30
29
  id: "web";
31
30
  max_results?: number;
32
31
  search_prompt?: string;
33
- engine?: OpenRouterString<"native" | "exa">;
32
+ engine?: OpenString<"native" | "exa">;
34
33
  }> | Readonly<{
35
34
  id: "file-parser";
36
35
  max_files?: number;
@@ -59,7 +58,7 @@ export interface OpenRouterOptions {
59
58
  readonly reasoning?: Readonly<{
60
59
  enabled?: boolean;
61
60
  exclude?: boolean;
62
- effort?: OpenRouterString<"none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
61
+ effort?: OpenString<"none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max">;
63
62
  max_tokens?: number;
64
63
  }>;
65
64
  readonly usage?: boolean | Readonly<{
@@ -69,7 +68,7 @@ export interface OpenRouterOptions {
69
68
  readonly web_search_options?: Readonly<{
70
69
  max_results?: number;
71
70
  search_prompt?: string;
72
- engine?: OpenRouterString<"native" | "exa">;
71
+ engine?: OpenString<"native" | "exa">;
73
72
  }>;
74
73
  }
75
74
  export type OpenRouterProviderOptionsInput = OpenRouterOptions;
@@ -7,7 +7,7 @@ import { HttpOptions, ProviderID } from "../schema/index.js";
7
7
  import { SystemOne } from "../experimental/system-one.js";
8
8
  import { OpenAIChat } from "../protocols/openai-chat.js";
9
9
  import { newBreakpoints, ttlBucket } from "../protocols/utils/cache.js";
10
- import { isRecord } from "../protocols/shared.js";
10
+ import { isRecord, ProviderShared } from "../protocols/shared.js";
11
11
  export const id = ProviderID.make("openrouter");
12
12
  const baseURL = "https://openrouter.ai/api/v1";
13
13
  const ADAPTER = "openrouter";
@@ -41,7 +41,7 @@ export const protocol = Protocol.make({
41
41
  return {
42
42
  ...body,
43
43
  messages,
44
- ...bodyOptions(request.providerOptions),
44
+ ...bodyOptions(request.providerOptions, request.generation?.maxTokens),
45
45
  };
46
46
  })),
47
47
  },
@@ -59,7 +59,12 @@ const cacheControl = () => {
59
59
  };
60
60
  };
61
61
  };
62
- const bodyOptions = (input) => {
62
+ // OpenRouter forwards `reasoning.max_tokens` as the upstream thinking budget. Upstreams such as Anthropic and Alibaba
63
+ // reject one that is not below the output limit; 1,024 is Anthropic's minimum budget.
64
+ const fitReasoning = (reasoning, maxTokens) => typeof reasoning.max_tokens === "number"
65
+ ? { ...reasoning, max_tokens: ProviderShared.fitThinkingBudget(reasoning.max_tokens, maxTokens, 1_024) }
66
+ : reasoning;
67
+ const bodyOptions = (input, maxTokens) => {
63
68
  const openrouter = isRecord(input) ? input : {};
64
69
  const { usage, models, provider, plugins, web_search_options, debug, user, reasoning, promptCacheKey, ...options } = openrouter;
65
70
  return {
@@ -77,7 +82,7 @@ const bodyOptions = (input) => {
77
82
  ...(isRecord(web_search_options) ? { web_search_options } : {}),
78
83
  ...(isRecord(debug) ? { debug } : {}),
79
84
  ...(typeof user === "string" ? { user } : {}),
80
- ...(isRecord(reasoning) ? { reasoning } : {}),
85
+ ...(isRecord(reasoning) ? { reasoning: fitReasoning(reasoning, maxTokens) } : {}),
81
86
  };
82
87
  };
83
88
  export const route = Route.make({
@@ -106,7 +111,7 @@ export const configure = (input = {}) => {
106
111
  auth: AuthOptions.bearer(input, "OPENROUTER_API_KEY"),
107
112
  baseURL: input.baseURL ?? baseURL,
108
113
  headers: input.headers,
109
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
114
+ http: HttpOptions.make(input.http),
110
115
  });
111
116
  return {
112
117
  id,
@@ -1,5 +1,5 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { HttpOptions, type ModelID } from "../schema/index.js";
2
+ import { type HttpOptions, type ModelID } from "../schema/index.js";
3
3
  export type { ReplicateImageOptions } from "../protocols/replicate-images.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
5
  export type Config = ProviderAuthOption<"optional"> & {
@@ -1,17 +1,12 @@
1
1
  import { AuthOptions } from "../route/auth-options.js";
2
- import { HttpOptions, ProviderID } from "../schema/index.js";
3
- import { DEFAULT_BASE_URL, ReplicateImages } from "../protocols/replicate-images.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { ReplicateImages } from "../protocols/replicate-images.js";
4
5
  export const id = ProviderID.make("replicate");
5
- const baseURL = DEFAULT_BASE_URL;
6
6
  const auth = (options) => AuthOptions.bearer(options, "REPLICATE_API_TOKEN");
7
7
  export const configure = (input = {}) => {
8
- const image = (modelID) => ReplicateImages.model({
9
- id: modelID,
10
- auth: auth(input),
11
- baseURL: input.baseURL ?? baseURL,
12
- headers: input.headers,
13
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
14
- });
8
+ const media = MediaRoute.deployment(input, auth(input));
9
+ const image = (modelID) => ReplicateImages.model({ ...media, id: modelID });
15
10
  return {
16
11
  id,
17
12
  image,
@@ -1,5 +1,5 @@
1
1
  import { type ProviderAuthOption } from "../route/auth-options.js";
2
- import { HttpOptions, type ModelID } from "../schema/index.js";
2
+ import { type HttpOptions, type ModelID } from "../schema/index.js";
3
3
  export type { RunwayVideoOptions } from "../protocols/runway-video.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
5
  export type Config = ProviderAuthOption<"optional"> & {