@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
@@ -2,12 +2,10 @@ import { Effect, Schema } from "effect";
2
2
  import { Media } from "../media.js";
3
3
  import { MediaProtocol } from "../route/media-protocol.js";
4
4
  import { MediaRoute } from "../route/media.js";
5
- import { ProviderID, mergeJsonRecords } from "../schema/index.js";
5
+ import { mergeJsonRecords } from "../schema/index.js";
6
6
  import { VideoModel, VideoResponse } from "../video.js";
7
7
  import { ProviderShared, optionalNull } from "./shared.js";
8
- const ADAPTER = "xai-video";
9
- const NAME = "xAI Video";
10
- const PROVIDER = ProviderID.make("xai");
8
+ const route = MediaProtocol.identity({ id: "xai-video", name: "xAI Video", provider: "xai" });
11
9
  export const DEFAULT_BASE_URL = "https://api.x.ai/v1";
12
10
  export const PATH = "/videos/generations";
13
11
  export const EDIT_PATH = "/videos/edits";
@@ -41,7 +39,7 @@ const STATUS = {
41
39
  // ---------------------------------------------------------------------------
42
40
  // 5. Request body construction
43
41
  // ---------------------------------------------------------------------------
44
- const mediaInput = (asset) => ProviderShared.mediaReference(asset, PROVIDER, NAME).pipe(Effect.map((reference) => (reference.type === "ref" ? { file_id: reference.value } : { url: reference.value })));
42
+ const mediaInput = (asset) => ProviderShared.mediaReference(asset, route.provider, route.name).pipe(Effect.map((reference) => (reference.type === "ref" ? { file_id: reference.value } : { url: reference.value })));
45
43
  const nativeOptions = (options) => {
46
44
  if (!options)
47
45
  return undefined;
@@ -69,13 +67,13 @@ const fromRequest = Effect.fn("XAIVideo.fromRequest")(function* (request) {
69
67
  // ---------------------------------------------------------------------------
70
68
  // 6. Response decoding
71
69
  // ---------------------------------------------------------------------------
72
- const decodeStart = MediaProtocol.decodeStarted(ADAPTER, NAME, StartResponse, (value) => ({
70
+ const decodeStart = route.decodeStarted(StartResponse, (value) => ({
73
71
  token: { requestID: value.request_id },
74
72
  snapshot: { id: value.request_id, status: "running" },
75
73
  }));
76
74
  // `progress` is undocumented but observed live as a 0..100 percentage (recorded cassette: 1 → 10 → 37 → 100).
77
75
  const fraction = (progress) => progress !== undefined && progress !== null && progress >= 0 && progress <= 100 ? progress / 100 : undefined;
78
- const decodeVideoStatus = MediaProtocol.decodeJson(ADAPTER, NAME, VideoStatus);
76
+ const decodeVideoStatus = route.decodeJson(VideoStatus);
79
77
  const decodeStatus = Effect.fn("XAIVideo.decodeStatus")(function* (response, context) {
80
78
  const output = yield* decodeVideoStatus(response);
81
79
  const status = yield* MediaProtocol.status(STATUS, output.value.status, output);
@@ -86,23 +84,23 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
86
84
  const decoded = output.value;
87
85
  const status = yield* MediaProtocol.status(STATUS, decoded.status, output);
88
86
  if (status === "running")
89
- return yield* output.invalid(`${NAME} request ${context.token.requestID} has not finished`);
87
+ return yield* output.pending(context.token.requestID);
90
88
  if (status === "failed") {
91
89
  const code = decoded.error?.code ?? undefined;
92
90
  const message = decoded.error?.message ?? undefined;
93
- return yield* output.ended("failed", `${NAME} generation failed${code === undefined ? "" : ` (${code})`}${message === undefined ? "" : `: ${message}`}`);
91
+ return yield* output.ended("failed", `${route.name} generation failed${code === undefined ? "" : ` (${code})`}${message === undefined ? "" : `: ${message}`}`);
94
92
  }
95
93
  if (status !== "completed")
96
- return yield* output.ended("expired", `${NAME} request ${context.token.requestID} expired`);
94
+ return yield* output.ended("expired", `${route.name} request ${context.token.requestID} expired`);
97
95
  // `respect_moderation: false` marks a filtered result; a URL may still be present, so report it as a notice.
98
96
  const notices = decoded.video?.respect_moderation === false
99
- ? [{ type: "moderated", message: `${NAME} flagged the generated video for moderation` }]
97
+ ? [{ type: "moderated", message: `${route.name} flagged the generated video for moderation` }]
100
98
  : undefined;
101
99
  const url = decoded.video?.url ?? undefined;
102
100
  if (url === undefined && notices !== undefined)
103
- return yield* output.contentPolicy(`${NAME} withheld the video for moderation`);
101
+ return yield* output.contentPolicy(`${route.name} withheld the video for moderation`);
104
102
  if (url === undefined)
105
- return yield* output.invalid(`${NAME} completed without a video URL`);
103
+ return yield* output.invalid(`${route.name} completed without a video URL`);
106
104
  const duration = decoded.video?.duration ?? undefined;
107
105
  return new VideoResponse({
108
106
  videos: [
@@ -119,9 +117,7 @@ const decodeResult = Effect.fn("XAIVideo.decodeResult")(function* (response, con
119
117
  // 7. Protocol and route
120
118
  // ---------------------------------------------------------------------------
121
119
  const statusPath = (token) => `${STATUS_PATH}/${token.requestID}`;
122
- export const protocol = MediaProtocol.queued({
123
- id: ADAPTER,
124
- name: NAME,
120
+ export const protocol = MediaProtocol.queued(route, {
125
121
  token: Token,
126
122
  unsupported: ["n", "seed", "negativePrompt"],
127
123
  start: { body: { from: fromRequest }, decode: decodeStart },
@@ -135,8 +131,6 @@ const startPath = (request) => {
135
131
  return request.providerOptions?.mode === "extend" ? EXTEND_PATH : EDIT_PATH;
136
132
  };
137
133
  export const model = (input) => VideoModel.fromRoute({
138
- id: ADAPTER,
139
- provider: PROVIDER,
140
134
  protocol,
141
135
  baseURL: DEFAULT_BASE_URL,
142
136
  path: ({ request }) => startPath(request),
@@ -1,12 +1,12 @@
1
1
  import { ImageModel, ImageResponse, type ImageRequestFor } from "../image.js";
2
2
  import { MediaProtocol } from "../route/media-protocol.js";
3
3
  import { MediaRoute } from "../route/media.js";
4
+ import { type OpenString } from "../schema/index.js";
4
5
  export declare const DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
5
6
  export declare const PATH = "/images/generations";
6
- export type ZAIImageString<Known extends string> = Known | (string & {});
7
7
  /** Provider-native options. The common `size` field lives on the request. */
8
8
  export type ZAIImageOptions = {
9
- readonly quality?: ZAIImageString<"hd" | "standard">;
9
+ readonly quality?: OpenString<"hd" | "standard">;
10
10
  readonly userID?: string;
11
11
  } & Record<string, unknown>;
12
12
  export type Request = ImageRequestFor<ZAIImageOptions>;
@@ -1,14 +1,12 @@
1
- import { Effect, Schema } from "effect";
1
+ import { Duration, Effect, Schema } from "effect";
2
2
  import { ImageModel, ImageResponse } from "../image.js";
3
- import { Media } from "../media.js";
4
3
  import { MediaProtocol } from "../route/media-protocol.js";
5
4
  import { MediaRoute } from "../route/media.js";
6
- import { ProviderID, mergeJsonRecords } from "../schema/index.js";
7
- const ADAPTER = "zai-images";
8
- const NAME = "Z.ai Images";
9
- const PROVIDER = ProviderID.make("zai");
5
+ import { mergeJsonRecords } from "../schema/index.js";
6
+ const route = MediaProtocol.identity({ id: "zai-images", name: "Z.ai Images", provider: "zai" });
10
7
  export const DEFAULT_BASE_URL = "https://api.z.ai/api/paas/v4";
11
8
  export const PATH = "/images/generations";
9
+ const OUTPUT_RETENTION = Duration.days(30);
12
10
  // ---------------------------------------------------------------------------
13
11
  // 2. Response schema
14
12
  // ---------------------------------------------------------------------------
@@ -37,21 +35,22 @@ const fromRequest = Effect.fn("ZAIImages.fromRequest")(function* (request) {
37
35
  // ---------------------------------------------------------------------------
38
36
  // 6. Response decoding
39
37
  // ---------------------------------------------------------------------------
38
+ const decodeDocument = route.decodeJson(ZAIImageResponse);
40
39
  const decodeResponse = Effect.fn("ZAIImages.decodeResponse")(function* (response) {
41
- const output = yield* MediaProtocol.decodeJson(ADAPTER, NAME, ZAIImageResponse)(response);
40
+ const output = yield* decodeDocument(response);
42
41
  const decoded = output.value;
43
42
  if (decoded.data.length === 0)
44
- return yield* output.invalid(`${NAME} returned no images`);
43
+ return yield* output.invalid(`${route.name} returned no images`);
45
44
  const filters = decoded.content_filter ?? [];
46
45
  return new ImageResponse({
47
46
  // Z.ai returns only URLs and no content type; the media type resolves when the asset is materialized.
48
- images: decoded.data.map((item) => Media.url(item.url)),
47
+ images: yield* Effect.forEach(decoded.data, (item) => MediaProtocol.expiringUrl(item.url, OUTPUT_RETENTION)),
49
48
  // Z.ai reports applied content filters alongside a successful result; surface them instead of dropping them.
50
49
  notices: filters.length === 0
51
50
  ? undefined
52
51
  : filters.map((filter) => ({
53
52
  type: "moderated",
54
- message: `${NAME} applied a content filter${filter.role === undefined ? "" : ` for ${filter.role}`}${filter.level === undefined ? "" : ` at level ${filter.level}`}`,
53
+ message: `${route.name} applied a content filter${filter.role === undefined ? "" : ` for ${filter.role}`}${filter.level === undefined ? "" : ` at level ${filter.level}`}`,
55
54
  providerMetadata: { zai: filter },
56
55
  })),
57
56
  providerMetadata: {
@@ -67,14 +66,12 @@ const decodeResponse = Effect.fn("ZAIImages.decodeResponse")(function* (response
67
66
  // ---------------------------------------------------------------------------
68
67
  // 7. Protocol and route
69
68
  // ---------------------------------------------------------------------------
70
- export const protocol = MediaProtocol.inline({
71
- id: ADAPTER,
72
- name: NAME,
69
+ export const protocol = MediaProtocol.inline(route, {
73
70
  unsupported: ["images", "mask", "n", "aspectRatio", "seed", "format"],
74
71
  body: { from: fromRequest },
75
72
  response: { decode: decodeResponse },
76
73
  });
77
- export const model = (input) => ImageModel.fromRoute({ id: ADAPTER, provider: PROVIDER, protocol, baseURL: DEFAULT_BASE_URL, path: PATH }, input);
74
+ export const model = (input) => ImageModel.fromRoute({ protocol, baseURL: DEFAULT_BASE_URL, path: PATH }, input);
78
75
  export const ZAIImages = {
79
76
  protocol,
80
77
  model,
@@ -222,7 +222,7 @@ export declare const protocol: Protocol<{
222
222
  readonly thinking?: {
223
223
  readonly type: string;
224
224
  } | undefined;
225
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
225
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
226
226
  readonly container?: string | {
227
227
  readonly id?: string | null | undefined;
228
228
  readonly skills?: readonly {
@@ -59,7 +59,13 @@ const SERVER_CODES = new Set([
59
59
  "slow_down",
60
60
  "serviceunavailableexception",
61
61
  ]);
62
- const INVALID_REQUEST_CODES = new Set(["invalid_prompt", "invalid_request_error", "validationexception"]);
62
+ // `invalid_request` is the Vercel AI Gateway's code for an upstream request rejection.
63
+ const INVALID_REQUEST_CODES = new Set([
64
+ "invalid_prompt",
65
+ "invalid_request",
66
+ "invalid_request_error",
67
+ "validationexception",
68
+ ]);
63
69
  // Azure OpenAI reports `content_filter` with `innererror.code` ResponsibleAIPolicyViolation.
64
70
  // OpenRouter tags provider failures with a typed `error_type`; its Responses skin also
65
71
  // emits `image_content_policy_violation` as the native code.
@@ -372,7 +372,7 @@ export declare const routes: (Route<{
372
372
  readonly type: string;
373
373
  readonly budget_tokens?: number | undefined;
374
374
  } | undefined;
375
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
375
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
376
376
  readonly container?: string | {
377
377
  readonly id?: string | null | undefined;
378
378
  readonly skills?: readonly {
@@ -1,6 +1,7 @@
1
1
  import type { RouteDefaultsInput } from "../route/client.js";
2
2
  import type { ProviderPackage } from "../provider-package.js";
3
3
  import { type ModelID } from "../schema/index.js";
4
+ import * as BedrockConverse from "../protocols/bedrock-converse.js";
4
5
  import type { BedrockCredentials } from "../protocols/bedrock-converse.js";
5
6
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
6
7
  export type Config = RouteDefaultsInput & {
@@ -26,6 +27,7 @@ export interface Settings extends ProviderPackage.Settings {
26
27
  readonly profile?: string;
27
28
  readonly region?: string;
28
29
  readonly topP?: number;
30
+ readonly thinking?: BedrockConverse.OptionsInput["thinking"];
29
31
  }
30
32
  export declare const routes: import("../route/client.js").Route<{
31
33
  readonly messages: readonly ({
@@ -36,6 +36,7 @@ export const model = (modelID, settings) => configure({
36
36
  generation: settings.topP === undefined ? undefined : { topP: settings.topP },
37
37
  headers: settings.headers === undefined ? undefined : { ...settings.headers },
38
38
  http: settings.body === undefined ? undefined : { body: { ...settings.body } },
39
+ providerOptions: settings.thinking === undefined ? undefined : { thinking: settings.thinking },
39
40
  profile: settings.profile,
40
41
  region: settings.region,
41
42
  }).model(modelID);
@@ -238,20 +238,20 @@ export declare const routes: import("../route/client.js").Route<{
238
238
  readonly thinking?: {
239
239
  readonly type: "enabled";
240
240
  readonly budget_tokens: number;
241
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
241
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
242
242
  readonly block_binding?: {
243
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
243
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
244
244
  } | undefined;
245
245
  } | {
246
246
  readonly type: "adaptive";
247
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
247
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
248
248
  readonly block_binding?: {
249
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
249
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
250
250
  } | undefined;
251
251
  } | {
252
252
  readonly type: "disabled";
253
253
  } | undefined;
254
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
254
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
255
255
  readonly container?: string | {
256
256
  readonly id?: string | null | undefined;
257
257
  readonly skills?: readonly {
@@ -223,20 +223,20 @@ export declare const routes: import("../route/client.js").Route<{
223
223
  readonly thinking?: {
224
224
  readonly type: "enabled";
225
225
  readonly budget_tokens: number;
226
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
226
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
227
227
  readonly block_binding?: {
228
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
228
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
229
229
  } | undefined;
230
230
  } | {
231
231
  readonly type: "adaptive";
232
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
232
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
233
233
  readonly block_binding?: {
234
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
234
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
235
235
  } | undefined;
236
236
  } | {
237
237
  readonly type: "disabled";
238
238
  } | undefined;
239
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
239
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
240
240
  readonly container?: string | {
241
241
  readonly id?: string | null | undefined;
242
242
  readonly skills?: readonly {
@@ -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 { AssemblyAITranscriptionOptions } from "../protocols/assemblyai-transcription.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
5
  export type Config = ProviderAuthOption<"optional"> & {
@@ -1,8 +1,8 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { HttpOptions, ProviderID } from "../schema/index.js";
3
- import { AssemblyAITranscription, DEFAULT_BASE_URL } from "../protocols/assemblyai-transcription.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { AssemblyAITranscription } from "../protocols/assemblyai-transcription.js";
4
5
  export const id = ProviderID.make("assemblyai");
5
- const baseURL = DEFAULT_BASE_URL;
6
6
  // The key is the whole `authorization` value, without a scheme.
7
7
  const auth = (options) => {
8
8
  if ("auth" in options && options.auth)
@@ -12,13 +12,8 @@ const auth = (options) => {
12
12
  .pipe(Auth.header("authorization"));
13
13
  };
14
14
  export const configure = (input = {}) => {
15
- const transcription = (modelID) => AssemblyAITranscription.model({
16
- id: modelID,
17
- auth: auth(input),
18
- baseURL: input.baseURL ?? baseURL,
19
- headers: input.headers,
20
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
21
- });
15
+ const media = MediaRoute.deployment(input, auth(input));
16
+ const transcription = (modelID) => AssemblyAITranscription.model({ ...media, id: modelID });
22
17
  return {
23
18
  id,
24
19
  transcription,
@@ -166,8 +166,8 @@ declare const responsesRoute: Route<{
166
166
  readonly type: "image_generation_call";
167
167
  readonly status?: string | undefined;
168
168
  readonly result?: string | null | undefined;
169
- readonly revised_prompt?: string | null | undefined;
170
169
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
170
+ readonly revised_prompt?: string | null | undefined;
171
171
  })[];
172
172
  readonly model: string;
173
173
  readonly stream: true;
@@ -192,9 +192,9 @@ declare const responsesRoute: Route<{
192
192
  readonly size?: string | undefined;
193
193
  readonly action?: "generate" | "auto" | "edit" | undefined;
194
194
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
195
- readonly partial_images?: number | undefined;
196
195
  readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
197
196
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
197
+ readonly partial_images?: number | undefined;
198
198
  readonly output_compression?: number | undefined;
199
199
  readonly input_fidelity?: "low" | "high" | undefined;
200
200
  } | {
@@ -506,8 +506,8 @@ export declare const routes: (Route<{
506
506
  readonly type: "image_generation_call";
507
507
  readonly status?: string | undefined;
508
508
  readonly result?: string | null | undefined;
509
- readonly revised_prompt?: string | null | undefined;
510
509
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
510
+ readonly revised_prompt?: string | null | undefined;
511
511
  })[];
512
512
  readonly model: string;
513
513
  readonly stream: true;
@@ -532,9 +532,9 @@ export declare const routes: (Route<{
532
532
  readonly size?: string | undefined;
533
533
  readonly action?: "generate" | "auto" | "edit" | undefined;
534
534
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
535
- readonly partial_images?: number | undefined;
536
535
  readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
537
536
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
537
+ readonly partial_images?: number | undefined;
538
538
  readonly output_compression?: number | undefined;
539
539
  readonly input_fidelity?: "low" | "high" | undefined;
540
540
  } | {
@@ -1,9 +1,9 @@
1
1
  import { Auth } from "../route/auth.js";
2
2
  import {} from "../route/auth-options.js";
3
+ import { Endpoint } from "../route/endpoint.js";
3
4
  import { ProviderConfigurationError, ProviderID } from "../schema/index.js";
4
5
  import * as OpenAIChat from "../protocols/openai-chat.js";
5
6
  import * as OpenAIResponses from "../protocols/openai-responses.js";
6
- import { ProviderShared } from "../protocols/shared.js";
7
7
  import { withOpenAIOptions } from "./openai-options.js";
8
8
  export const id = ProviderID.make("azure");
9
9
  const routeAuth = Auth.remove("authorization");
@@ -58,7 +58,7 @@ const configuredRoute = (route, input, modelID) => route.with({
58
58
  endpoint: endpoint(input, modelID),
59
59
  });
60
60
  function endpoint(input, modelID) {
61
- const baseURL = ProviderShared.trimBaseUrl(input.baseURL ?? resourceBaseURL(input.resourceName));
61
+ const baseURL = Endpoint.trimBaseUrl(input.baseURL ?? resourceBaseURL(input.resourceName));
62
62
  const query = { "api-version": input.apiVersion ?? "v1", ...input.queryParams };
63
63
  if (input.useDeploymentBasedUrls)
64
64
  return { baseURL: `${baseURL}/deployments/${modelID}`, query };
@@ -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 { BlackForestLabsImageOptions } from "../protocols/bfl-images.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
5
  export type Config = ProviderAuthOption<"optional"> & {
@@ -1,8 +1,8 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { HttpOptions, ProviderID } from "../schema/index.js";
3
- import { BlackForestLabsImages, DEFAULT_BASE_URL } from "../protocols/bfl-images.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { BlackForestLabsImages } from "../protocols/bfl-images.js";
4
5
  export const id = ProviderID.make("black-forest-labs");
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("x-key"));
12
12
  };
13
13
  export const configure = (input = {}) => {
14
- const image = (modelID) => BlackForestLabsImages.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 image = (modelID) => BlackForestLabsImages.model({ ...media, id: modelID });
21
16
  return {
22
17
  id,
23
18
  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 { CartesiaEncoding, CartesiaSpeechOptions } from "../protocols/cartesia-speech.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 { CartesiaSpeech, DEFAULT_BASE_URL } from "../protocols/cartesia-speech.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { CartesiaSpeech } from "../protocols/cartesia-speech.js";
4
5
  export const id = ProviderID.make("cartesia");
5
- const baseURL = DEFAULT_BASE_URL;
6
6
  const auth = (options) => AuthOptions.bearer(options, "CARTESIA_API_KEY");
7
7
  export const configure = (input = {}) => {
8
- const speech = (modelID) => CartesiaSpeech.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 speech = (modelID) => CartesiaSpeech.model({ ...media, id: modelID });
15
10
  return {
16
11
  id,
17
12
  speech,
@@ -172,8 +172,8 @@ export declare const responsesRoute: import("../route/client.js").Route<{
172
172
  readonly type: "image_generation_call";
173
173
  readonly status?: string | undefined;
174
174
  readonly result?: string | null | undefined;
175
- readonly revised_prompt?: string | null | undefined;
176
175
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
176
+ readonly revised_prompt?: string | null | undefined;
177
177
  })[];
178
178
  readonly model: string;
179
179
  readonly stream: true;
@@ -198,9 +198,9 @@ export declare const responsesRoute: import("../route/client.js").Route<{
198
198
  readonly size?: string | undefined;
199
199
  readonly action?: "generate" | "auto" | "edit" | undefined;
200
200
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
201
- readonly partial_images?: number | undefined;
202
201
  readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
203
202
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
203
+ readonly partial_images?: number | undefined;
204
204
  readonly output_compression?: number | undefined;
205
205
  readonly input_fidelity?: "low" | "high" | undefined;
206
206
  } | {
@@ -474,20 +474,20 @@ export declare const messagesRoute: import("../route/client.js").Route<{
474
474
  readonly thinking?: {
475
475
  readonly type: "enabled";
476
476
  readonly budget_tokens: number;
477
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
477
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
478
478
  readonly block_binding?: {
479
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
479
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
480
480
  } | undefined;
481
481
  } | {
482
482
  readonly type: "adaptive";
483
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
483
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
484
484
  readonly block_binding?: {
485
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
485
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
486
486
  } | undefined;
487
487
  } | {
488
488
  readonly type: "disabled";
489
489
  } | undefined;
490
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
490
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
491
491
  readonly container?: string | {
492
492
  readonly id?: string | null | undefined;
493
493
  readonly skills?: readonly {
@@ -858,20 +858,20 @@ export declare const routes: (import("../route/client.js").Route<{
858
858
  readonly thinking?: {
859
859
  readonly type: "enabled";
860
860
  readonly budget_tokens: number;
861
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
861
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
862
862
  readonly block_binding?: {
863
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
863
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
864
864
  } | undefined;
865
865
  } | {
866
866
  readonly type: "adaptive";
867
- readonly display?: (string & {}) | "summarized" | "omitted" | undefined;
867
+ readonly display?: import("../schema/options.js").OpenString<"summarized" | "omitted"> | undefined;
868
868
  readonly block_binding?: {
869
- readonly prefix_mismatch_behavior?: (string & {}) | "error" | "drop_block" | undefined;
869
+ readonly prefix_mismatch_behavior?: import("../schema/options.js").OpenString<"error" | "drop_block"> | undefined;
870
870
  } | undefined;
871
871
  } | {
872
872
  readonly type: "disabled";
873
873
  } | undefined;
874
- readonly service_tier?: "auto" | (string & {}) | "standard_only" | undefined;
874
+ readonly service_tier?: import("../schema/options.js").OpenString<"auto" | "standard_only"> | undefined;
875
875
  readonly container?: string | {
876
876
  readonly id?: string | null | undefined;
877
877
  readonly skills?: readonly {
@@ -1169,8 +1169,8 @@ export declare const routes: (import("../route/client.js").Route<{
1169
1169
  readonly type: "image_generation_call";
1170
1170
  readonly status?: string | undefined;
1171
1171
  readonly result?: string | null | undefined;
1172
- readonly revised_prompt?: string | null | undefined;
1173
1172
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
1173
+ readonly revised_prompt?: string | null | undefined;
1174
1174
  })[];
1175
1175
  readonly model: string;
1176
1176
  readonly stream: true;
@@ -1195,9 +1195,9 @@ export declare const routes: (import("../route/client.js").Route<{
1195
1195
  readonly size?: string | undefined;
1196
1196
  readonly action?: "generate" | "auto" | "edit" | undefined;
1197
1197
  readonly output_format?: "png" | "jpeg" | "webp" | undefined;
1198
- readonly partial_images?: number | undefined;
1199
1198
  readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
1200
1199
  readonly background?: "auto" | "opaque" | "transparent" | undefined;
1200
+ readonly partial_images?: number | undefined;
1201
1201
  readonly output_compression?: number | undefined;
1202
1202
  readonly input_fidelity?: "low" | "high" | undefined;
1203
1203
  } | {
@@ -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 { DeepgramEncoding, DeepgramSpeechOptions } from "../protocols/deepgram-speech.js";
4
4
  export type { DeepgramTranscriptionOptions } from "../protocols/deepgram-transcription.js";
5
5
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
@@ -1,9 +1,9 @@
1
1
  import { Auth } from "../route/auth.js";
2
- import { HttpOptions, ProviderID } from "../schema/index.js";
3
- import { DEFAULT_BASE_URL, DeepgramSpeech } from "../protocols/deepgram-speech.js";
2
+ import { MediaRoute } from "../route/media.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ import { DeepgramSpeech } from "../protocols/deepgram-speech.js";
4
5
  import { DeepgramTranscription } from "../protocols/deepgram-transcription.js";
5
6
  export const id = ProviderID.make("deepgram");
6
- const baseURL = DEFAULT_BASE_URL;
7
7
  const auth = (options) => {
8
8
  if ("auth" in options && options.auth)
9
9
  return options.auth;
@@ -12,17 +12,11 @@ const auth = (options) => {
12
12
  .pipe(Auth.scheme("Token"));
13
13
  };
14
14
  export const configure = (input = {}) => {
15
- const media = (modelID) => ({
16
- id: modelID,
17
- auth: auth(input),
18
- baseURL: input.baseURL ?? baseURL,
19
- headers: input.headers,
20
- http: input.http === undefined ? undefined : HttpOptions.make(input.http),
21
- });
15
+ const media = MediaRoute.deployment(input, auth(input));
22
16
  return {
23
17
  id,
24
- speech: (modelID) => DeepgramSpeech.model(media(modelID)),
25
- transcription: (modelID) => DeepgramTranscription.model(media(modelID)),
18
+ speech: (modelID) => DeepgramSpeech.model({ ...media, id: modelID }),
19
+ transcription: (modelID) => DeepgramTranscription.model({ ...media, id: modelID }),
26
20
  configure,
27
21
  };
28
22
  };
@@ -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 { ElevenLabsOutputFormat, ElevenLabsSpeechOptions } from "../protocols/elevenlabs-speech.js";
4
4
  export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
5
5
  export type Config = ProviderAuthOption<"optional"> & {