@opencode/ai 0.0.0-dev-338 → 0.0.0-dev-354

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.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @opencode/ai
2
2
 
3
- Schema-first APIs for text, images, video, speech, transcription, and decisions, built with Effect.
3
+ Schema-first APIs for text, images, and decisions, built with Effect. Video, speech, transcription, extraction, and
4
+ realtime voice are [experimental](#experimental).
4
5
 
5
6
  `@opencode/ai` is the Promise API: one managed runtime behind the LLM and media methods, plus asset helpers. `ai.file`
6
7
  and `ai.write` load `node:fs/promises` on first use, so no Effect `FileSystem` is needed:
@@ -165,8 +166,8 @@ Raw usage is preserved in `usage.providerMetadata.google`. `inputTokens` follows
165
166
  `contextTokens` uses its full `raw_prompt_token` count when supplied. These can differ substantially with server-side
166
167
  continuation. Explicit caches, hosted tools, and generated media are not supported by this initial protocol.
167
168
 
168
- The same configured facade names image, video, speech, and transcription models. `Image.generate` resolves the
169
- provider's image route from the model and returns `Media.Asset`s with lazily decoded bytes:
169
+ The same configured facade names image models (and the experimental video, speech, and transcription models).
170
+ `Image.generate` resolves the provider's image route from the model and returns `Media.Asset`s with lazily decoded bytes:
170
171
 
171
172
  ```ts
172
173
  import { NodeFileSystem } from "@effect/platform-node"
@@ -309,38 +310,6 @@ CloudflareAIGateway.configure({ accountId }).decision("typesafe/jev")
309
310
  OpenAI and Vercel AI Gateway use OpenAI's `/v1/decisions` API. TypeSafe, OpenCode, OpenRouter, Baseten and
310
311
  DigitalOcean use System One (`/systemone`), and Cloudflare sends the System One body through `/ai/run`.
311
312
 
312
- ### Extraction (experimental)
313
-
314
- Extraction models read typed values out of text instead of answering questions with probabilities. A field of type
315
- `text`, `number`, `date`, `time`, `datetime`, `duration`, `list`, `estimate` or `forecast` gets an answer typed to
316
- match; other types are sent and answered as-is. Only Cloudflare's Clairic serves it today, so it lives under
317
- `@opencode/ai/experimental`.
318
-
319
- ```ts
320
- import { ai } from "@opencode/ai"
321
- import { Extraction } from "@opencode/ai/experimental"
322
- import { CloudflareWorkersAI } from "@opencode/ai/providers"
323
-
324
- const response = await ai.run(
325
- Extraction.generate({
326
- model: CloudflareWorkersAI.configure({ accountId }).experimental.extraction("@cf/cloudflare/clairic"),
327
- input: "Invoice INV-2291, issued 2026-09-02, net 30. Total $1,080.00. Contact: Dana Ruiz, Priya Shah.",
328
- fields: {
329
- invoiceNumber: { type: "text" },
330
- dueDate: { type: "date", instructions: "Issue date plus the net payment days" },
331
- total: { type: "number", decimals: 2, unit: "USD" },
332
- contacts: { type: "list", items: "text" },
333
- },
334
- }),
335
- )
336
- response.answers.total.value // 1080, or null when the input does not say
337
- ```
338
-
339
- Value answers carry `guess`, `nullProbability` and `confidence`; text answers carry a `span` into `input`. Estimates and
340
- forecasts return `median`, `p10` and `p90`. Field options other than `type`, `instructions` and `nullThreshold` go to
341
- Clairic as written. Effect users provide `RequestExecutor.fetchLayer` (or `AIClient.layer`). Images are not supported
342
- yet.
343
-
344
313
  ## Alibaba Cloud Model Studio
345
314
 
346
315
  `Alibaba` provides standard Model Studio inference. Configure a region explicitly, then select
@@ -910,7 +879,42 @@ const program = Effect.gen(function* () {
910
879
 
911
880
  The hosted result is represented as a provider-executed tool call and a tool result whose content carries the generated image as a file. Gemini image-capable models instead emit a first-class `media` `LLMEvent` for inline image output (`response.message` then carries a `media` part). Retaining `response.message` preserves the generated image for continuation on both routes.
912
881
 
913
- ## Video generation
882
+ ## Public API
883
+
884
+ Everything below is exported from `@opencode/ai/effect` unless noted.
885
+
886
+ - **`LLM.request({...})`** — build a provider-neutral `LLMRequest`. Accepts ergonomic inputs (`system: string`, `prompt: string`) that normalize into the canonical Schema classes.
887
+ - **`LLM.generate` / `LLM.stream`** — run direct input or an `LLMRequest` through `LLMClient` for one-import use.
888
+ - **`LLM.loop`** — stream model calls, running `tool(...)` tools between them until the model stops calling tools.
889
+ - **`Message.user(...)` / `Message.assistant(...)` / `Message.tool(...)`** — message constructors from the canonical schema model.
890
+ - **`LanguageModel.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model.
891
+ - **`LLMEvent.is.*`** — typed guards (`is.textDelta`, `is.toolCall`, `is.finish`, …) for filtering streams.
892
+ - **`Image.request` / `generate` / `stream` / `start` / `resume`** — images over inline, streaming (partial previews), and queued routes through a provider-neutral request and response model.
893
+ - **`ImageClient`** — Effect service and layer for image execution, parallel to `LLMClient`.
894
+ - **`Media`** — the shared asset type (`Media.Asset`, `Media.Source`) and constructors used by messages, tool results, and media requests.
895
+ - **`Generation`** — provider-neutral handle for an in-flight media generation (`await`, `refresh`, `cancel`, `events`) used by queued media routes.
896
+ - **`Decision.request` / `Decision.generate`** — typed predicate, choice, and score questions over text, JSON, and media input; `DecisionClient` is its Effect service and layer.
897
+ - **`AIClient.layer` / `AIClient.layerWith(executor)`** — every modality client plus the request executor in one layer.
898
+ - **`@opencode/ai`** (Promise root) — `AI.make({ layer?, clients? })` and a default `ai` client exposing `llm`, `image`, and `decision` (plus `experimental.video`, `experimental.speech`, and `experimental.transcription`) as Promise / `AsyncIterable` APIs, `run(effect)` for any package Effect, plus `file`, `write`, `bytes`, `base64`, and `materialize` for assets.
899
+ - **`@opencode/ai/experimental`** — APIs that may change without compatibility guarantees: `Video`, `Speech`, `Transcription`, `Extraction`, and `Realtime`. See [Experimental](#experimental).
900
+
901
+ ## Experimental
902
+
903
+ These APIs may change without compatibility guarantees. The Effect API is exported from `@opencode/ai/experimental`,
904
+ the Promise client exposes it under `ai.experimental`, and test layers come from `@opencode/ai/experimental/testing`.
905
+
906
+ - **`Video`**, **`Speech`**, and **`Transcription`** — media generation and speech-to-text, with `VideoClient`,
907
+ `SpeechClient`, and `TranscriptionClient` as their Effect services. Promise: `ai.experimental.video`, `.speech`, and
908
+ `.transcription`. Testing: `TestVideo`, `TestSpeech`, and `TestTranscription`.
909
+ - **`Extraction`** — typed values read out of text.
910
+ - **`Realtime`** — `Realtime.connect` starts an OpenAI, xAI, or Gemini voice session and returns a WebRTC answer SDP or
911
+ a short-lived WebSocket URL and token.
912
+
913
+ The provider selectors for these modalities (`.video(...)`, `.speech(...)`, `.transcription(...)`,
914
+ `.experimental.extraction(...)`) and their protocol entrypoints (such as `@opencode/ai/protocols/openai-speech`) are
915
+ part of the same experimental surface.
916
+
917
+ ### Video generation
914
918
 
915
919
  Video mirrors `Image` with one difference: every provider is asynchronous, so the route is a submit-then-poll
916
920
  `Generation`. Models come from `.video(...)` selectors on the `Google` (Veo), `XAI`, and `Runway` facades.
@@ -919,7 +923,7 @@ Common fields (`frames`, `references`, `video`, `durationSeconds`, `aspect`, `re
919
923
  under `providerOptions`, inferred from the selected model.
920
924
 
921
925
  ```ts
922
- import { Video } from "@opencode/ai/effect"
926
+ import { Video } from "@opencode/ai/experimental"
923
927
  import { Google, Runway } from "@opencode/ai/providers"
924
928
 
925
929
  const google = Google.configure({ apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY })
@@ -981,9 +985,9 @@ Provider notes:
981
985
  - **Runway** expects pixel ratios in `aspect` for most models (`"1280:720"`), pins `X-Runway-Version`, reports
982
986
  `usage: { type: "credits" }`, and its output URLs expire after 24–48 hours.
983
987
 
984
- The promise client exposes the same surface: `ai.video.start(...)` resolves to a handle with `await`, `events`,
985
- `result`, `refresh`, `cancel`, and `token`; `ai.video.generate`, `ai.video.resume(model, token)`, and
986
- `ai.video.stream` mirror the Effect API. The handle's `status` and `progress` are a snapshot from when it was
988
+ The promise client exposes the same surface: `ai.experimental.video.start(...)` resolves to a handle with `await`, `events`,
989
+ `result`, `refresh`, `cancel`, and `token`; `ai.experimental.video.generate`, `ai.experimental.video.resume(model, token)`, and
990
+ `ai.experimental.video.stream` mirror the Effect API. The handle's `status` and `progress` are a snapshot from when it was
987
991
  created; `refresh()` resolves to a new handle. Every promise method and stream accepts `{ signal }`: like `fetch`,
988
992
  aborting rejects the Promise or throws from the `for await` loop with `signal.reason` (an `AbortError` `DOMException`
989
993
  unless `abort(reason)` passed one), while `break` stops a stream without throwing.
@@ -991,13 +995,13 @@ unless `abort(reason)` passed one), while `break` stops a stream without throwin
991
995
  ```ts
992
996
  import { ai } from "@opencode/ai"
993
997
 
994
- const generation = await ai.video.start({ model, prompt })
998
+ const generation = await ai.experimental.video.start({ model, prompt })
995
999
  for await (const event of generation.events({ poll: { interval: 10_000 } })) console.log(event.type)
996
1000
  const video = await generation.result({ signal })
997
1001
  await ai.write(video.video, "./kite.mp4")
998
1002
  ```
999
1003
 
1000
- ## Speech generation
1004
+ ### Speech generation
1001
1005
 
1002
1006
  Speech (text-to-speech) is one request whose response is parsed incrementally, so every route supports both
1003
1007
  `Speech.generate` (the whole file) and `Speech.stream` (audio chunks as they arrive). Models come from `.speech(...)`
@@ -1006,7 +1010,8 @@ selectors on the `OpenAI`, `Google` (Gemini TTS), `ElevenLabs`, `Cartesia`, and
1006
1010
  before any network call; provider-native controls live under `providerOptions`, inferred from the selected model.
1007
1011
 
1008
1012
  ```ts
1009
- import { Media, Speech, SpeechClient, SpeechEvent } from "@opencode/ai/effect"
1013
+ import { Media } from "@opencode/ai/effect"
1014
+ import { Speech, SpeechEvent } from "@opencode/ai/experimental"
1010
1015
  import { ElevenLabs, OpenAI } from "@opencode/ai/providers"
1011
1016
 
1012
1017
  const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
@@ -1068,20 +1073,20 @@ Provider notes:
1068
1073
  and `providerOptions` lower to query parameters (`encoding`, `container`, `sample_rate`, `bit_rate`); `pcm` is
1069
1074
  `linear16` without a container. Auth is `Authorization: Token <DEEPGRAM_API_KEY>`.
1070
1075
 
1071
- The promise client mirrors the Effect API; `ai.speech.stream` is an `AsyncIterable`.
1076
+ The promise client mirrors the Effect API; `ai.experimental.speech.stream` is an `AsyncIterable`.
1072
1077
 
1073
1078
  ```ts
1074
1079
  import { ai } from "@opencode/ai"
1075
1080
 
1076
- const response = await ai.speech.generate({ model, text: "Hello from OpenCode.", voice: "coral" })
1081
+ const response = await ai.experimental.speech.generate({ model, text: "Hello from OpenCode.", voice: "coral" })
1077
1082
  await ai.write(response.audio, "hello.mp3")
1078
1083
 
1079
- for await (const event of ai.speech.stream({ model, text: "Hello from OpenCode.", voice: "coral" })) {
1084
+ for await (const event of ai.experimental.speech.stream({ model, text: "Hello from OpenCode.", voice: "coral" })) {
1080
1085
  if (event.type === "audio-delta") player.write(event.chunk)
1081
1086
  }
1082
1087
  ```
1083
1088
 
1084
- ## Transcription
1089
+ ### Transcription
1085
1090
 
1086
1091
  Transcription (speech-to-text) is the one modality whose providers use every route kind: OpenAI and Gemini stream,
1087
1092
  Deepgram and ElevenLabs answer inline, and AssemblyAI is queued. `Transcription.generate` and `Transcription.stream`
@@ -1093,7 +1098,8 @@ any network call; a route may return more than asked.
1093
1098
 
1094
1099
  ```ts
1095
1100
  import { Console, Effect, Stream } from "effect"
1096
- import { Media, Transcription, TranscriptionEvent } from "@opencode/ai/effect"
1101
+ import { Media } from "@opencode/ai/effect"
1102
+ import { Transcription, TranscriptionEvent } from "@opencode/ai/experimental"
1097
1103
  import { AssemblyAI, Deepgram, OpenAI } from "@opencode/ai/providers"
1098
1104
 
1099
1105
  const openai = OpenAI.configure({ apiKey: process.env.OPENAI_API_KEY })
@@ -1146,33 +1152,43 @@ The promise client mirrors the Effect API:
1146
1152
 
1147
1153
  ```ts
1148
1154
  const audio = await ai.file("./call.mp3")
1149
- const text = (await ai.transcription.generate({ model, audio })).text
1150
- for await (const event of ai.transcription.stream({ model, audio })) if (event.type === "text-delta") write(event.delta)
1151
- const generation = await ai.transcription.start({ model: assemblyai, audio })
1155
+ const text = (await ai.experimental.transcription.generate({ model, audio })).text
1156
+ for await (const event of ai.experimental.transcription.stream({ model, audio }))
1157
+ if (event.type === "text-delta") write(event.delta)
1158
+ const generation = await ai.experimental.transcription.start({ model: assemblyai, audio })
1152
1159
  const transcript = await generation.await({ poll: { interval: 3_000 } })
1153
1160
  ```
1154
1161
 
1155
- ## Public API
1162
+ ### Extraction
1156
1163
 
1157
- Everything below is exported from `@opencode/ai/effect` unless noted.
1164
+ Extraction models read typed values out of text instead of answering questions with probabilities. A field of type
1165
+ `text`, `number`, `date`, `time`, `datetime`, `duration`, `list`, `estimate` or `forecast` gets an answer typed to
1166
+ match; other types are sent and answered as-is. Only Cloudflare's Clairic serves it today.
1158
1167
 
1159
- - **`LLM.request({...})`** — build a provider-neutral `LLMRequest`. Accepts ergonomic inputs (`system: string`, `prompt: string`) that normalize into the canonical Schema classes.
1160
- - **`LLM.generate` / `LLM.stream`** — run direct input or an `LLMRequest` through `LLMClient` for one-import use.
1161
- - **`LLM.loop`** — stream model calls, running `tool(...)` tools between them until the model stops calling tools.
1162
- - **`Message.user(...)` / `Message.assistant(...)` / `Message.tool(...)`** — message constructors from the canonical schema model.
1163
- - **`LanguageModel.make(...)` / `ToolCallPart.make(...)` / `ToolResultPart.make(...)` / `ToolDefinition.make(...)`** — model and tool-related constructors from the canonical schema model.
1164
- - **`LLMEvent.is.*`** — typed guards (`is.textDelta`, `is.toolCall`, `is.finish`, …) for filtering streams.
1165
- - **`Image.request` / `generate` / `stream` / `start` / `resume`** — images over inline, streaming (partial previews), and queued routes through a provider-neutral request and response model.
1166
- - **`ImageClient`** — Effect service and layer for image execution, parallel to `LLMClient`.
1167
- - **`Media`** — the shared asset type (`Media.Asset`, `Media.Source`) and constructors used by messages, tool results, and media requests.
1168
- - **`Generation`** — provider-neutral handle for an in-flight media generation (`await`, `refresh`, `cancel`, `events`) used by queued media routes.
1169
- - **`Video.request` / `generate` / `stream` / `start` / `resume`** — queued video generation through a provider-neutral request; `VideoClient` is its Effect service and layer.
1170
- - **`Speech.request` / `Speech.generate` / `Speech.stream`** — text-to-speech through a provider-neutral request; `SpeechClient` is its Effect service and layer.
1171
- - **`Transcription.request` / `generate` / `stream` / `start` / `resume`** — speech-to-text over inline, streaming, and queued routes; `TranscriptionClient` is its Effect service and layer.
1172
- - **`Decision.request` / `Decision.generate`** — typed predicate, choice, and score questions over text, JSON, and media input; `DecisionClient` is its Effect service and layer.
1173
- - **`AIClient.layer` / `AIClient.layerWith(executor)`** — every modality client plus the request executor in one layer.
1174
- - **`@opencode/ai`** (Promise root) — `AI.make({ layer?, clients? })` and a default `ai` client exposing `llm`, `image`, `video`, `speech`, `transcription`, and `decision` as Promise / `AsyncIterable` APIs, `run(effect)` for any package Effect, plus `file`, `write`, `bytes`, `base64`, and `materialize` for assets.
1175
- - **`@opencode/ai/experimental`** — APIs that may still change: `Extraction` (typed values read out of text) and `Realtime` (`Realtime.connect` starts an OpenAI, xAI, or Gemini voice session and returns a WebRTC answer SDP or a short-lived WebSocket URL and token).
1168
+ ```ts
1169
+ import { ai } from "@opencode/ai"
1170
+ import { Extraction } from "@opencode/ai/experimental"
1171
+ import { CloudflareWorkersAI } from "@opencode/ai/providers"
1172
+
1173
+ const response = await ai.run(
1174
+ Extraction.generate({
1175
+ model: CloudflareWorkersAI.configure({ accountId }).experimental.extraction("@cf/cloudflare/clairic"),
1176
+ input: "Invoice INV-2291, issued 2026-09-02, net 30. Total $1,080.00. Contact: Dana Ruiz, Priya Shah.",
1177
+ fields: {
1178
+ invoiceNumber: { type: "text" },
1179
+ dueDate: { type: "date", instructions: "Issue date plus the net payment days" },
1180
+ total: { type: "number", decimals: 2, unit: "USD" },
1181
+ contacts: { type: "list", items: "text" },
1182
+ },
1183
+ }),
1184
+ )
1185
+ response.answers.total.value // 1080, or null when the input does not say
1186
+ ```
1187
+
1188
+ Value answers carry `guess`, `nullProbability` and `confidence`; text answers carry a `span` into `input`. Estimates and
1189
+ forecasts return `median`, `p10` and `p90`. Field options other than `type`, `instructions` and `nullThreshold` go to
1190
+ Clairic as written. Effect users provide `RequestExecutor.fetchLayer` (or `AIClient.layer`). Images are not supported
1191
+ yet.
1176
1192
 
1177
1193
  ## Testing
1178
1194
 
@@ -1218,7 +1234,7 @@ For explicit compaction, script a `CompactionResponse` through `push`, `always`,
1218
1234
 
1219
1235
  For `compact(request, { mechanism: "trigger" })`, script a `CompactionCheckpointResponse` instead. It carries `checkpoint`, `responseID`, and optional `usage`. Endpoint and trigger calls reject each other's fixtures; both share the same queue, gates, lazy recording, and fallback controls.
1220
1236
 
1221
- `TestImage`, `TestVideo`, `TestSpeech`, `TestTranscription`, and `TestDecision` follow the same pattern: `testLayer()` provides the modality's client and `Test`, with the same `push`, `always`, `serve`, `requests`, `wait`, and `gate` controls. Script an `ImageResponse` (or the modality's response) or an `AIError`. `stream` expands the response into its events, and `start` returns an already finished generation that `resume` accepts by token. Decision responses are returned as scripted, without checking the answers against the questions.
1237
+ `TestImage` and `TestDecision` (and `TestVideo`, `TestSpeech`, and `TestTranscription` from `@opencode/ai/experimental/testing`) follow the same pattern: `testLayer()` provides the modality's client and `Test`, with the same `push`, `always`, `serve`, `requests`, `wait`, and `gate` controls. Script an `ImageResponse` (or the modality's response) or an `AIError`. `stream` expands the response into its events, and `start` returns an already finished generation that `resume` accepts by token. Decision responses are returned as scripted, without checking the answers against the questions.
1222
1238
 
1223
1239
  The Promise client accepts the same layers as `AI.make({ clients: TestImage.testLayer() })`; `ai.run(TestImage.Test.use(...))` reaches the controls.
1224
1240
 
package/dist/effect.d.ts CHANGED
@@ -10,18 +10,6 @@ export type { GenerationOptionsFields, GenerationOptionsInput, LanguageModelInpu
10
10
  export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageRequest, ImageResponse } from "./image.js";
11
11
  export type { ImageModelOptions, ImageOptions, ImageRequestFor, ImageRequestInput, ImageResolution, ImageRoute, } from "./image.js";
12
12
  export { Image } from "./image.js";
13
- export { VideoClient } from "./video-client.js";
14
- export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
15
- export type { VideoModelOptions, VideoOptions, VideoRequestFor, VideoRequestInput, VideoResolution, VideoRoute, } from "./video.js";
16
- export { Video } from "./video.js";
17
- export { SpeechClient } from "./speech-client.js";
18
- export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
19
- export type { SpeechFormat, SpeechModelOptions, SpeechOptions, SpeechRequestFor, SpeechRequestInput, SpeechRoute, } from "./speech.js";
20
- export { Speech } from "./speech.js";
21
- export { TranscriptionClient } from "./transcription-client.js";
22
- export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
23
- export type { TranscriptionModelOptions, TranscriptionOptions, TranscriptionRequestFor, TranscriptionRequestInput, TranscriptionRoute, } from "./transcription.js";
24
- export { Transcription } from "./transcription.js";
25
13
  export { DecisionClient } from "./decision-client.js";
26
14
  export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionRequest, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
27
15
  export type { AnswerFor, AnswersFor, DecisionInput, DecisionModelOptions, DecisionOptions, DecisionQuestions, DecisionRequestFor, DecisionRequestInput, DecisionResponseFor, DecisionModelRoute, } from "./decision.js";
package/dist/effect.js CHANGED
@@ -7,15 +7,6 @@ export { isContextOverflow, isContextOverflowFailure, isRetryable } from "./prov
7
7
  export { ProtocolID, RouteID, ModelID, ProviderID, ResponseID, ContentBlockID, ToolCallID, JsonSchema, ProviderOptions, ProviderMetadata, HttpTimeout, RequestEncoding, HttpOptions, GenerationOptions, LanguageModelDefaults, ReasoningEfforts, ReasoningEffort, LanguageModelCompatibility, LanguageModel, LanguageModelSchema, CacheTTL, CacheHint, CachePolicyObject, CachePolicy, MessageRole, SystemPart, TextPart, MediaPart, ToolResultValue, ToolOutput, ToolCallPart, ToolResultPart, ReasoningPart, CompactionPart, EffortPart, ContentPart, Message, Freeform, ToolDefinition, ToolNamespace, ToolEntry, ToolChoice, LLMRequest, FinishReason, Usage, MediaUsage, CompactionResponse, CompactionCheckpointResponse, StepStart, TextStart, TextDelta, TextEnd, ReasoningStart, ReasoningDelta, ReasoningEnd, ToolInputStart, ToolInputDelta, ToolInputEnd, ToolInputError, ToolCall, ToolResult, ToolError, FinishReasonDetails, StepFinish, Finish, MediaEvent, ProviderErrorEvent, LLMEvent, LLMResponse, HttpContext, HttpRateLimitDetails, InvalidRequestError, UnsupportedOperationError, ProviderConfigurationError, NoRouteError, AuthenticationError, RateLimitError, QuotaExceededError, ContentPolicyError, ProviderInternalError, TransportType, TransportOperation, TransportError, InvalidProviderOutputError, UnknownProviderError, TimeoutError, AIErrorReason, AIError, } from "./schema/index.js";
8
8
  export { ImageAspectRatio, ImageEvent, ImageModel, ImageModelSchema, ImageRequest, ImageResponse } from "./image.js";
9
9
  export { Image } from "./image.js";
10
- export { VideoClient } from "./video-client.js";
11
- export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
12
- export { Video } from "./video.js";
13
- export { SpeechClient } from "./speech-client.js";
14
- export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
15
- export { Speech } from "./speech.js";
16
- export { TranscriptionClient } from "./transcription-client.js";
17
- export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
18
- export { Transcription } from "./transcription.js";
19
10
  export { DecisionClient } from "./decision-client.js";
20
11
  export { ChoiceAnswer, ChoiceQuestion, ChoiceValue, DecisionAnswer, DecisionJsonPart, DecisionMediaPart, DecisionModel, DecisionModelCompatibility, DecisionModelSchema, DecisionPart, DecisionQuestion, DecisionRequest, DecisionResponse, DecisionTextPart, DecisionUsage, ErrorAnswer, ErrorReason, PredicateAnswer, PredicateQuestion, ScoreAnswer, ScoreQuestion, } from "./decision.js";
21
12
  export { Decision } from "./decision.js";
@@ -0,0 +1,3 @@
1
+ export { TestSpeech } from "../testing/speech.js";
2
+ export { TestTranscription } from "../testing/transcription.js";
3
+ export { TestVideo } from "../testing/video.js";
@@ -0,0 +1,3 @@
1
+ export { TestSpeech } from "../testing/speech.js";
2
+ export { TestTranscription } from "../testing/transcription.js";
3
+ export { TestVideo } from "../testing/video.js";
@@ -1,3 +1,15 @@
1
+ export { VideoClient } from "./video-client.js";
2
+ export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
3
+ export type { VideoModelOptions, VideoOptions, VideoRequestFor, VideoRequestInput, VideoResolution, VideoRoute, } from "./video.js";
4
+ export { Video } from "./video.js";
5
+ export { SpeechClient } from "./speech-client.js";
6
+ export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
7
+ export type { SpeechFormat, SpeechModelOptions, SpeechOptions, SpeechRequestFor, SpeechRequestInput, SpeechRoute, } from "./speech.js";
8
+ export { Speech } from "./speech.js";
9
+ export { TranscriptionClient } from "./transcription-client.js";
10
+ export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
11
+ export type { TranscriptionModelOptions, TranscriptionOptions, TranscriptionRequestFor, TranscriptionRequestInput, TranscriptionRoute, } from "./transcription.js";
12
+ export { Transcription } from "./transcription.js";
1
13
  export { Extraction, ExtractionModel, ExtractionRequest, ExtractionResponse } from "./experimental/extraction.js";
2
14
  export type { ExtractionAnswerFor, ExtractionAnswersFor, ExtractionField, ExtractionFields, ExtractionModelOptions, ExtractionOptions, ExtractionRequestFor, ExtractionRequestInput, ExtractionResponseFor, ExtractionRoute, } from "./experimental/extraction.js";
3
15
  export { Realtime } from "./experimental/realtime.js";
@@ -1,2 +1,11 @@
1
+ export { VideoClient } from "./video-client.js";
2
+ export { VideoAspectRatio, VideoEvent, VideoFrames, VideoModel, VideoModelSchema, VideoRequest, VideoResponse, } from "./video.js";
3
+ export { Video } from "./video.js";
4
+ export { SpeechClient } from "./speech-client.js";
5
+ export { SpeechEvent, SpeechModel, SpeechModelSchema, SpeechRequest, SpeechResponse, SpeechTimestamp, SpeechVoice, } from "./speech.js";
6
+ export { Speech } from "./speech.js";
7
+ export { TranscriptionClient } from "./transcription-client.js";
8
+ export { TranscriptionEvent, TranscriptionModel, TranscriptionModelSchema, TranscriptionRequest, TranscriptionResponse, TranscriptionSegment, TranscriptionTimestamps, TranscriptionWord, } from "./transcription.js";
9
+ export { Transcription } from "./transcription.js";
1
10
  export { Extraction, ExtractionModel, ExtractionRequest, ExtractionResponse } from "./experimental/extraction.js";
2
11
  export { Realtime } from "./experimental/realtime.js";
package/dist/index.d.ts CHANGED
@@ -561,178 +561,181 @@ export declare const make: <R = never>(options?: Options<R>) => {
561
561
  start: <const Model extends ImageModel>(input: ImageRequestInput<Model> | ImageRequest, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
562
562
  resume: (model: ImageModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
563
563
  };
564
- video: {
565
- request: typeof import("./video.js").request;
566
- start: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
567
- generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
568
- resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
569
- stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
570
- readonly type: "video";
571
- readonly index: number;
572
- readonly video: Media.Asset;
573
- } | {
574
- readonly type: "generation-queued";
575
- readonly id: string;
576
- readonly position?: number | undefined;
577
- } | {
578
- readonly type: "generation-progress";
579
- readonly id: string;
580
- readonly progress?: number | undefined;
581
- } | {
582
- readonly type: "finish";
583
- readonly usage?: {
584
- readonly type: "seconds";
585
- readonly seconds: number;
564
+ decision: {
565
+ request: typeof import("./decision.js").request;
566
+ generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
567
+ };
568
+ /** Experimental: may change without compatibility guarantees. */
569
+ experimental: {
570
+ speech: {
571
+ request: typeof import("./speech.js").request;
572
+ generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
573
+ stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
574
+ readonly type: "audio-delta";
575
+ readonly chunk: Uint8Array<ArrayBufferLike>;
586
576
  } | {
587
- readonly type: "characters";
588
- readonly characters: number;
577
+ readonly type: "timestamps";
578
+ readonly items: readonly {
579
+ readonly text: string;
580
+ readonly startSeconds: number;
581
+ readonly endSeconds: number;
582
+ }[];
589
583
  } | {
590
- readonly type: "credits";
591
- readonly credits: number;
584
+ readonly type: "generation-queued";
585
+ readonly id: string;
586
+ readonly position?: number | undefined;
592
587
  } | {
593
- readonly type: "compute";
594
- readonly seconds: number;
588
+ readonly type: "generation-progress";
589
+ readonly id: string;
590
+ readonly progress?: number | undefined;
595
591
  } | {
596
- readonly type: "tokens";
597
- readonly input?: number | undefined;
598
- readonly output?: number | undefined;
599
- readonly total?: number | undefined;
600
- readonly details?: {
601
- readonly [x: string]: unknown;
592
+ readonly type: "finish";
593
+ readonly audio: Media.Asset;
594
+ readonly usage?: {
595
+ readonly type: "seconds";
596
+ readonly seconds: number;
597
+ } | {
598
+ readonly type: "characters";
599
+ readonly characters: number;
600
+ } | {
601
+ readonly type: "credits";
602
+ readonly credits: number;
603
+ } | {
604
+ readonly type: "compute";
605
+ readonly seconds: number;
606
+ } | {
607
+ readonly type: "tokens";
608
+ readonly input?: number | undefined;
609
+ readonly output?: number | undefined;
610
+ readonly total?: number | undefined;
611
+ readonly details?: {
612
+ readonly [x: string]: unknown;
613
+ } | undefined;
602
614
  } | undefined;
603
- } | undefined;
604
- readonly providerMetadata?: {
605
- readonly [x: string]: {
606
- readonly [x: string]: unknown;
607
- };
608
- } | undefined;
609
- }>;
610
- };
611
- speech: {
612
- request: typeof import("./speech.js").request;
613
- generate: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
614
- stream: <const Model extends SpeechModel>(input: SpeechRequestInput<Model> | SpeechRequest, options?: RunOptions) => AsyncIterable<{
615
- readonly type: "audio-delta";
616
- readonly chunk: Uint8Array<ArrayBufferLike>;
617
- } | {
618
- readonly type: "timestamps";
619
- readonly items: readonly {
620
- readonly text: string;
621
- readonly startSeconds: number;
622
- readonly endSeconds: number;
623
- }[];
624
- } | {
625
- readonly type: "generation-queued";
626
- readonly id: string;
627
- readonly position?: number | undefined;
628
- } | {
629
- readonly type: "generation-progress";
630
- readonly id: string;
631
- readonly progress?: number | undefined;
632
- } | {
633
- readonly type: "finish";
634
- readonly audio: Media.Asset;
635
- readonly usage?: {
636
- readonly type: "seconds";
637
- readonly seconds: number;
615
+ readonly providerMetadata?: {
616
+ readonly [x: string]: {
617
+ readonly [x: string]: unknown;
618
+ };
619
+ } | undefined;
620
+ }>;
621
+ };
622
+ transcription: {
623
+ request: typeof import("./transcription.js").request;
624
+ generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
625
+ stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
626
+ readonly type: "text-delta";
627
+ readonly delta: string;
638
628
  } | {
639
- readonly type: "characters";
640
- readonly characters: number;
629
+ readonly type: "segment";
630
+ readonly segment: {
631
+ readonly text: string;
632
+ readonly startSeconds: number;
633
+ readonly endSeconds: number;
634
+ readonly speaker?: string | undefined;
635
+ };
641
636
  } | {
642
- readonly type: "credits";
643
- readonly credits: number;
637
+ readonly type: "generation-queued";
638
+ readonly id: string;
639
+ readonly position?: number | undefined;
644
640
  } | {
645
- readonly type: "compute";
646
- readonly seconds: number;
641
+ readonly type: "generation-progress";
642
+ readonly id: string;
643
+ readonly progress?: number | undefined;
647
644
  } | {
648
- readonly type: "tokens";
649
- readonly input?: number | undefined;
650
- readonly output?: number | undefined;
651
- readonly total?: number | undefined;
652
- readonly details?: {
653
- readonly [x: string]: unknown;
654
- } | undefined;
655
- } | undefined;
656
- readonly providerMetadata?: {
657
- readonly [x: string]: {
658
- readonly [x: string]: unknown;
659
- };
660
- } | undefined;
661
- }>;
662
- };
663
- transcription: {
664
- request: typeof import("./transcription.js").request;
665
- generate: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
666
- stream: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
667
- readonly type: "text-delta";
668
- readonly delta: string;
669
- } | {
670
- readonly type: "segment";
671
- readonly segment: {
672
645
  readonly text: string;
673
- readonly startSeconds: number;
674
- readonly endSeconds: number;
675
- readonly speaker?: string | undefined;
676
- };
677
- } | {
678
- readonly type: "generation-queued";
679
- readonly id: string;
680
- readonly position?: number | undefined;
681
- } | {
682
- readonly type: "generation-progress";
683
- readonly id: string;
684
- readonly progress?: number | undefined;
685
- } | {
686
- readonly text: string;
687
- readonly segments?: readonly {
688
- readonly text: string;
689
- readonly startSeconds: number;
690
- readonly endSeconds: number;
691
- readonly speaker?: string | undefined;
692
- }[] | undefined;
693
- readonly words?: readonly {
694
- readonly text: string;
695
- readonly startSeconds: number;
696
- readonly endSeconds: number;
697
- readonly speaker?: string | undefined;
698
- readonly confidence?: number | undefined;
699
- }[] | undefined;
700
- readonly language?: string | undefined;
701
- readonly durationSeconds?: number | undefined;
702
- readonly usage?: {
703
- readonly type: "seconds";
704
- readonly seconds: number;
705
- } | {
706
- readonly type: "characters";
707
- readonly characters: number;
646
+ readonly segments?: readonly {
647
+ readonly text: string;
648
+ readonly startSeconds: number;
649
+ readonly endSeconds: number;
650
+ readonly speaker?: string | undefined;
651
+ }[] | undefined;
652
+ readonly words?: readonly {
653
+ readonly text: string;
654
+ readonly startSeconds: number;
655
+ readonly endSeconds: number;
656
+ readonly speaker?: string | undefined;
657
+ readonly confidence?: number | undefined;
658
+ }[] | undefined;
659
+ readonly language?: string | undefined;
660
+ readonly durationSeconds?: number | undefined;
661
+ readonly usage?: {
662
+ readonly type: "seconds";
663
+ readonly seconds: number;
664
+ } | {
665
+ readonly type: "characters";
666
+ readonly characters: number;
667
+ } | {
668
+ readonly type: "credits";
669
+ readonly credits: number;
670
+ } | {
671
+ readonly type: "compute";
672
+ readonly seconds: number;
673
+ } | {
674
+ readonly type: "tokens";
675
+ readonly input?: number | undefined;
676
+ readonly output?: number | undefined;
677
+ readonly total?: number | undefined;
678
+ readonly details?: {
679
+ readonly [x: string]: unknown;
680
+ } | undefined;
681
+ } | undefined;
682
+ readonly providerMetadata?: {
683
+ readonly [x: string]: {
684
+ readonly [x: string]: unknown;
685
+ };
686
+ } | undefined;
687
+ readonly type: "finish";
688
+ }>;
689
+ start: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
690
+ resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
691
+ };
692
+ video: {
693
+ request: typeof import("./video.js").request;
694
+ start: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
695
+ generate: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
696
+ resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
697
+ stream: <const Model extends VideoModel>(input: VideoRequestInput<Model> | VideoRequest, options?: AwaitOptions & RunOptions) => AsyncIterable<{
698
+ readonly type: "video";
699
+ readonly index: number;
700
+ readonly video: Media.Asset;
708
701
  } | {
709
- readonly type: "credits";
710
- readonly credits: number;
702
+ readonly type: "generation-queued";
703
+ readonly id: string;
704
+ readonly position?: number | undefined;
711
705
  } | {
712
- readonly type: "compute";
713
- readonly seconds: number;
706
+ readonly type: "generation-progress";
707
+ readonly id: string;
708
+ readonly progress?: number | undefined;
714
709
  } | {
715
- readonly type: "tokens";
716
- readonly input?: number | undefined;
717
- readonly output?: number | undefined;
718
- readonly total?: number | undefined;
719
- readonly details?: {
720
- readonly [x: string]: unknown;
710
+ readonly type: "finish";
711
+ readonly usage?: {
712
+ readonly type: "seconds";
713
+ readonly seconds: number;
714
+ } | {
715
+ readonly type: "characters";
716
+ readonly characters: number;
717
+ } | {
718
+ readonly type: "credits";
719
+ readonly credits: number;
720
+ } | {
721
+ readonly type: "compute";
722
+ readonly seconds: number;
723
+ } | {
724
+ readonly type: "tokens";
725
+ readonly input?: number | undefined;
726
+ readonly output?: number | undefined;
727
+ readonly total?: number | undefined;
728
+ readonly details?: {
729
+ readonly [x: string]: unknown;
730
+ } | undefined;
721
731
  } | undefined;
722
- } | undefined;
723
- readonly providerMetadata?: {
724
- readonly [x: string]: {
725
- readonly [x: string]: unknown;
726
- };
727
- } | undefined;
728
- readonly type: "finish";
729
- }>;
730
- start: <const Model extends TranscriptionModel>(input: TranscriptionRequestInput<Model> | TranscriptionRequest, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
731
- resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
732
- };
733
- decision: {
734
- request: typeof import("./decision.js").request;
735
- generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
732
+ readonly providerMetadata?: {
733
+ readonly [x: string]: {
734
+ readonly [x: string]: unknown;
735
+ };
736
+ } | undefined;
737
+ }>;
738
+ };
736
739
  };
737
740
  dispose: () => Promise<void>;
738
741
  };
@@ -1262,178 +1265,181 @@ export declare const ai: {
1262
1265
  start: <const Model extends ImageModel>(input: ImageRequest | ImageRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
1263
1266
  resume: (model: ImageModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./image.js").ImageResponse>>;
1264
1267
  };
1265
- video: {
1266
- request: typeof import("./video.js").request;
1267
- start: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
1268
- generate: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
1269
- resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
1270
- stream: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions & RunOptions) => AsyncIterable<{
1271
- readonly type: "video";
1272
- readonly index: number;
1273
- readonly video: Media.Asset;
1274
- } | {
1275
- readonly type: "generation-queued";
1276
- readonly id: string;
1277
- readonly position?: number | undefined;
1278
- } | {
1279
- readonly type: "generation-progress";
1280
- readonly id: string;
1281
- readonly progress?: number | undefined;
1282
- } | {
1283
- readonly type: "finish";
1284
- readonly usage?: {
1285
- readonly type: "seconds";
1286
- readonly seconds: number;
1268
+ decision: {
1269
+ request: typeof import("./decision.js").request;
1270
+ generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
1271
+ };
1272
+ /** Experimental: may change without compatibility guarantees. */
1273
+ experimental: {
1274
+ speech: {
1275
+ request: typeof import("./speech.js").request;
1276
+ generate: <const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
1277
+ stream: <const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>, options?: RunOptions) => AsyncIterable<{
1278
+ readonly type: "audio-delta";
1279
+ readonly chunk: Uint8Array<ArrayBufferLike>;
1287
1280
  } | {
1288
- readonly type: "characters";
1289
- readonly characters: number;
1281
+ readonly type: "timestamps";
1282
+ readonly items: readonly {
1283
+ readonly text: string;
1284
+ readonly startSeconds: number;
1285
+ readonly endSeconds: number;
1286
+ }[];
1290
1287
  } | {
1291
- readonly type: "credits";
1292
- readonly credits: number;
1288
+ readonly type: "generation-queued";
1289
+ readonly id: string;
1290
+ readonly position?: number | undefined;
1293
1291
  } | {
1294
- readonly type: "compute";
1295
- readonly seconds: number;
1292
+ readonly type: "generation-progress";
1293
+ readonly id: string;
1294
+ readonly progress?: number | undefined;
1296
1295
  } | {
1297
- readonly type: "tokens";
1298
- readonly input?: number | undefined;
1299
- readonly output?: number | undefined;
1300
- readonly total?: number | undefined;
1301
- readonly details?: {
1302
- readonly [x: string]: unknown;
1296
+ readonly type: "finish";
1297
+ readonly audio: Media.Asset;
1298
+ readonly usage?: {
1299
+ readonly type: "seconds";
1300
+ readonly seconds: number;
1301
+ } | {
1302
+ readonly type: "characters";
1303
+ readonly characters: number;
1304
+ } | {
1305
+ readonly type: "credits";
1306
+ readonly credits: number;
1307
+ } | {
1308
+ readonly type: "compute";
1309
+ readonly seconds: number;
1310
+ } | {
1311
+ readonly type: "tokens";
1312
+ readonly input?: number | undefined;
1313
+ readonly output?: number | undefined;
1314
+ readonly total?: number | undefined;
1315
+ readonly details?: {
1316
+ readonly [x: string]: unknown;
1317
+ } | undefined;
1303
1318
  } | undefined;
1304
- } | undefined;
1305
- readonly providerMetadata?: {
1306
- readonly [x: string]: {
1307
- readonly [x: string]: unknown;
1308
- };
1309
- } | undefined;
1310
- }>;
1311
- };
1312
- speech: {
1313
- request: typeof import("./speech.js").request;
1314
- generate: <const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>, options?: RunOptions) => Promise<import("./speech.js").SpeechResponse>;
1315
- stream: <const Model extends SpeechModel>(input: SpeechRequest | SpeechRequestInput<Model>, options?: RunOptions) => AsyncIterable<{
1316
- readonly type: "audio-delta";
1317
- readonly chunk: Uint8Array<ArrayBufferLike>;
1318
- } | {
1319
- readonly type: "timestamps";
1320
- readonly items: readonly {
1321
- readonly text: string;
1322
- readonly startSeconds: number;
1323
- readonly endSeconds: number;
1324
- }[];
1325
- } | {
1326
- readonly type: "generation-queued";
1327
- readonly id: string;
1328
- readonly position?: number | undefined;
1329
- } | {
1330
- readonly type: "generation-progress";
1331
- readonly id: string;
1332
- readonly progress?: number | undefined;
1333
- } | {
1334
- readonly type: "finish";
1335
- readonly audio: Media.Asset;
1336
- readonly usage?: {
1337
- readonly type: "seconds";
1338
- readonly seconds: number;
1319
+ readonly providerMetadata?: {
1320
+ readonly [x: string]: {
1321
+ readonly [x: string]: unknown;
1322
+ };
1323
+ } | undefined;
1324
+ }>;
1325
+ };
1326
+ transcription: {
1327
+ request: typeof import("./transcription.js").request;
1328
+ generate: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
1329
+ stream: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions & RunOptions) => AsyncIterable<{
1330
+ readonly type: "text-delta";
1331
+ readonly delta: string;
1339
1332
  } | {
1340
- readonly type: "characters";
1341
- readonly characters: number;
1333
+ readonly type: "segment";
1334
+ readonly segment: {
1335
+ readonly text: string;
1336
+ readonly startSeconds: number;
1337
+ readonly endSeconds: number;
1338
+ readonly speaker?: string | undefined;
1339
+ };
1342
1340
  } | {
1343
- readonly type: "credits";
1344
- readonly credits: number;
1341
+ readonly type: "generation-queued";
1342
+ readonly id: string;
1343
+ readonly position?: number | undefined;
1345
1344
  } | {
1346
- readonly type: "compute";
1347
- readonly seconds: number;
1345
+ readonly type: "generation-progress";
1346
+ readonly id: string;
1347
+ readonly progress?: number | undefined;
1348
1348
  } | {
1349
- readonly type: "tokens";
1350
- readonly input?: number | undefined;
1351
- readonly output?: number | undefined;
1352
- readonly total?: number | undefined;
1353
- readonly details?: {
1354
- readonly [x: string]: unknown;
1355
- } | undefined;
1356
- } | undefined;
1357
- readonly providerMetadata?: {
1358
- readonly [x: string]: {
1359
- readonly [x: string]: unknown;
1360
- };
1361
- } | undefined;
1362
- }>;
1363
- };
1364
- transcription: {
1365
- request: typeof import("./transcription.js").request;
1366
- generate: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions & RunOptions) => Promise<import("./transcription.js").TranscriptionResponse>;
1367
- stream: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: AwaitOptions & RunOptions) => AsyncIterable<{
1368
- readonly type: "text-delta";
1369
- readonly delta: string;
1370
- } | {
1371
- readonly type: "segment";
1372
- readonly segment: {
1373
1349
  readonly text: string;
1374
- readonly startSeconds: number;
1375
- readonly endSeconds: number;
1376
- readonly speaker?: string | undefined;
1377
- };
1378
- } | {
1379
- readonly type: "generation-queued";
1380
- readonly id: string;
1381
- readonly position?: number | undefined;
1382
- } | {
1383
- readonly type: "generation-progress";
1384
- readonly id: string;
1385
- readonly progress?: number | undefined;
1386
- } | {
1387
- readonly text: string;
1388
- readonly segments?: readonly {
1389
- readonly text: string;
1390
- readonly startSeconds: number;
1391
- readonly endSeconds: number;
1392
- readonly speaker?: string | undefined;
1393
- }[] | undefined;
1394
- readonly words?: readonly {
1395
- readonly text: string;
1396
- readonly startSeconds: number;
1397
- readonly endSeconds: number;
1398
- readonly speaker?: string | undefined;
1399
- readonly confidence?: number | undefined;
1400
- }[] | undefined;
1401
- readonly language?: string | undefined;
1402
- readonly durationSeconds?: number | undefined;
1403
- readonly usage?: {
1404
- readonly type: "seconds";
1405
- readonly seconds: number;
1406
- } | {
1407
- readonly type: "characters";
1408
- readonly characters: number;
1350
+ readonly segments?: readonly {
1351
+ readonly text: string;
1352
+ readonly startSeconds: number;
1353
+ readonly endSeconds: number;
1354
+ readonly speaker?: string | undefined;
1355
+ }[] | undefined;
1356
+ readonly words?: readonly {
1357
+ readonly text: string;
1358
+ readonly startSeconds: number;
1359
+ readonly endSeconds: number;
1360
+ readonly speaker?: string | undefined;
1361
+ readonly confidence?: number | undefined;
1362
+ }[] | undefined;
1363
+ readonly language?: string | undefined;
1364
+ readonly durationSeconds?: number | undefined;
1365
+ readonly usage?: {
1366
+ readonly type: "seconds";
1367
+ readonly seconds: number;
1368
+ } | {
1369
+ readonly type: "characters";
1370
+ readonly characters: number;
1371
+ } | {
1372
+ readonly type: "credits";
1373
+ readonly credits: number;
1374
+ } | {
1375
+ readonly type: "compute";
1376
+ readonly seconds: number;
1377
+ } | {
1378
+ readonly type: "tokens";
1379
+ readonly input?: number | undefined;
1380
+ readonly output?: number | undefined;
1381
+ readonly total?: number | undefined;
1382
+ readonly details?: {
1383
+ readonly [x: string]: unknown;
1384
+ } | undefined;
1385
+ } | undefined;
1386
+ readonly providerMetadata?: {
1387
+ readonly [x: string]: {
1388
+ readonly [x: string]: unknown;
1389
+ };
1390
+ } | undefined;
1391
+ readonly type: "finish";
1392
+ }>;
1393
+ start: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
1394
+ resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
1395
+ };
1396
+ video: {
1397
+ request: typeof import("./video.js").request;
1398
+ start: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
1399
+ generate: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions & RunOptions) => Promise<import("./video.js").VideoResponse>;
1400
+ resume: (model: VideoModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./video.js").VideoResponse>>;
1401
+ stream: <const Model extends VideoModel>(input: VideoRequest | VideoRequestInput<Model>, options?: AwaitOptions & RunOptions) => AsyncIterable<{
1402
+ readonly type: "video";
1403
+ readonly index: number;
1404
+ readonly video: Media.Asset;
1409
1405
  } | {
1410
- readonly type: "credits";
1411
- readonly credits: number;
1406
+ readonly type: "generation-queued";
1407
+ readonly id: string;
1408
+ readonly position?: number | undefined;
1412
1409
  } | {
1413
- readonly type: "compute";
1414
- readonly seconds: number;
1410
+ readonly type: "generation-progress";
1411
+ readonly id: string;
1412
+ readonly progress?: number | undefined;
1415
1413
  } | {
1416
- readonly type: "tokens";
1417
- readonly input?: number | undefined;
1418
- readonly output?: number | undefined;
1419
- readonly total?: number | undefined;
1420
- readonly details?: {
1421
- readonly [x: string]: unknown;
1414
+ readonly type: "finish";
1415
+ readonly usage?: {
1416
+ readonly type: "seconds";
1417
+ readonly seconds: number;
1418
+ } | {
1419
+ readonly type: "characters";
1420
+ readonly characters: number;
1421
+ } | {
1422
+ readonly type: "credits";
1423
+ readonly credits: number;
1424
+ } | {
1425
+ readonly type: "compute";
1426
+ readonly seconds: number;
1427
+ } | {
1428
+ readonly type: "tokens";
1429
+ readonly input?: number | undefined;
1430
+ readonly output?: number | undefined;
1431
+ readonly total?: number | undefined;
1432
+ readonly details?: {
1433
+ readonly [x: string]: unknown;
1434
+ } | undefined;
1422
1435
  } | undefined;
1423
- } | undefined;
1424
- readonly providerMetadata?: {
1425
- readonly [x: string]: {
1426
- readonly [x: string]: unknown;
1427
- };
1428
- } | undefined;
1429
- readonly type: "finish";
1430
- }>;
1431
- start: <const Model extends TranscriptionModel>(input: TranscriptionRequest | TranscriptionRequestInput<Model>, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
1432
- resume: (model: TranscriptionModel, token: unknown, options?: RunOptions) => Promise<GenerationHandle<import("./transcription.js").TranscriptionResponse>>;
1433
- };
1434
- decision: {
1435
- request: typeof import("./decision.js").request;
1436
- generate: <const Model extends DecisionModel, const Questions extends DecisionQuestions>(input: DecisionRequestInput<Model, Questions>, options?: RunOptions) => Promise<import("./decision.js").DecisionResponseFor<Questions>>;
1436
+ readonly providerMetadata?: {
1437
+ readonly [x: string]: {
1438
+ readonly [x: string]: unknown;
1439
+ };
1440
+ } | undefined;
1441
+ }>;
1442
+ };
1437
1443
  };
1438
1444
  dispose: () => Promise<void>;
1439
1445
  };
package/dist/index.js CHANGED
@@ -96,29 +96,32 @@ export const make = (options = {}) => {
96
96
  start: (input, options) => run(Image.start(input), options).then(handle),
97
97
  resume: (model, token, options) => run(Image.resume(model, token), options).then(handle),
98
98
  },
99
- video: {
100
- request: Video.request,
101
- start: (input, options) => run(Video.start(input), options).then(handle),
102
- generate: (input, options) => run(Video.generate(input, { poll: options?.poll }), options),
103
- resume: (model, token, options) => run(Video.resume(model, token), options).then(handle),
104
- stream: (input, options) => iterate(Video.stream(input, { poll: options?.poll }), options),
105
- },
106
- speech: {
107
- request: Speech.request,
108
- generate: (input, options) => run(Speech.generate(input), options),
109
- stream: (input, options) => iterate(Speech.stream(input), options),
110
- },
111
- transcription: {
112
- request: Transcription.request,
113
- generate: (input, options) => run(Transcription.generate(input, { poll: options?.poll }), options),
114
- stream: (input, options) => iterate(Transcription.stream(input, { poll: options?.poll }), options),
115
- start: (input, options) => run(Transcription.start(input), options).then(handle),
116
- resume: (model, token, options) => run(Transcription.resume(model, token), options).then(handle),
117
- },
118
99
  decision: {
119
100
  request: Decision.request,
120
101
  generate: (input, options) => run(Decision.generate(input), options),
121
102
  },
103
+ /** Experimental: may change without compatibility guarantees. */
104
+ experimental: {
105
+ speech: {
106
+ request: Speech.request,
107
+ generate: (input, options) => run(Speech.generate(input), options),
108
+ stream: (input, options) => iterate(Speech.stream(input), options),
109
+ },
110
+ transcription: {
111
+ request: Transcription.request,
112
+ generate: (input, options) => run(Transcription.generate(input, { poll: options?.poll }), options),
113
+ stream: (input, options) => iterate(Transcription.stream(input, { poll: options?.poll }), options),
114
+ start: (input, options) => run(Transcription.start(input), options).then(handle),
115
+ resume: (model, token, options) => run(Transcription.resume(model, token), options).then(handle),
116
+ },
117
+ video: {
118
+ request: Video.request,
119
+ start: (input, options) => run(Video.start(input), options).then(handle),
120
+ generate: (input, options) => run(Video.generate(input, { poll: options?.poll }), options),
121
+ resume: (model, token, options) => run(Video.resume(model, token), options).then(handle),
122
+ stream: (input, options) => iterate(Video.stream(input, { poll: options?.poll }), options),
123
+ },
124
+ },
122
125
  dispose: () => runtime.dispose(),
123
126
  };
124
127
  };
package/dist/testing.d.ts CHANGED
@@ -2,9 +2,6 @@ export * as TestLLM from "./testing.js";
2
2
  export { compileRequest } from "./route/client.js";
3
3
  export { TestDecision } from "./testing/decision.js";
4
4
  export { TestImage } from "./testing/image.js";
5
- export { TestSpeech } from "./testing/speech.js";
6
- export { TestTranscription } from "./testing/transcription.js";
7
- export { TestVideo } from "./testing/video.js";
8
5
  import { LLMClient } from "./route/client.js";
9
6
  import { LLMEvent, CompactionResponse, CompactionCheckpointResponse, type FinishReasonDetails, type AIError, type LLMRequest, type ProviderMetadata, type UsageInput } from "./schema/index.js";
10
7
  import { Context, Layer, Stream } from "effect";
package/dist/testing.js CHANGED
@@ -2,9 +2,6 @@ export * as TestLLM from "./testing.js";
2
2
  export { compileRequest } from "./route/client.js";
3
3
  export { TestDecision } from "./testing/decision.js";
4
4
  export { TestImage } from "./testing/image.js";
5
- export { TestSpeech } from "./testing/speech.js";
6
- export { TestTranscription } from "./testing/transcription.js";
7
- export { TestVideo } from "./testing/video.js";
8
5
  import { LLMClient, generateWith, } from "./route/client.js";
9
6
  import { LLMEvent, CompactionResponse, CompactionCheckpointResponse, } from "./schema/index.js";
10
7
  import { Context, Effect, Layer, Stream } from "effect";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "0.0.0-dev-338",
3
+ "version": "0.0.0-dev-354",
4
4
  "name": "@opencode/ai",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -32,6 +32,10 @@
32
32
  "import": "./dist/experimental.js",
33
33
  "types": "./dist/experimental.d.ts"
34
34
  },
35
+ "./experimental/testing": {
36
+ "import": "./dist/experimental/testing.js",
37
+ "types": "./dist/experimental/testing.d.ts"
38
+ },
35
39
  "./route": {
36
40
  "import": "./dist/route.js",
37
41
  "types": "./dist/route.d.ts"
@@ -516,7 +520,7 @@
516
520
  "devDependencies": {
517
521
  "@clack/prompts": "1.0.0-alpha.1",
518
522
  "@effect/platform-node": "4.0.6",
519
- "@opencode/http-recorder": "0.0.0-dev-338",
523
+ "@opencode/http-recorder": "0.0.0-dev-354",
520
524
  "@tsconfig/bun": "1.0.9",
521
525
  "@types/bun": "1.4.3",
522
526
  "@typescript/native": "npm:typescript@7.1.0-beta",
@@ -526,7 +530,7 @@
526
530
  "@aws-sdk/credential-providers": "3.1057.0",
527
531
  "@smithy/eventstream-codec": "4.2.14",
528
532
  "@smithy/util-utf8": "4.2.2",
529
- "@opencode/schema": "0.0.0-dev-338",
533
+ "@opencode/schema": "0.0.0-dev-354",
530
534
  "aws4fetch": "1.0.20",
531
535
  "effect": "4.0.6",
532
536
  "google-auth-library": "10.5.0"