@opencode/ai 2.0.31 → 2.1.0

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 (152) hide show
  1. package/dist/ai-client.d.ts +2 -2
  2. package/dist/experimental/evaluation-client.d.ts +1 -1
  3. package/dist/experimental/evaluation.d.ts +20 -20
  4. package/dist/experimental/realtime.d.ts +47 -0
  5. package/dist/experimental/realtime.js +99 -0
  6. package/dist/experimental/system-one.d.ts +1 -1
  7. package/dist/experimental.d.ts +2 -0
  8. package/dist/experimental.js +1 -0
  9. package/dist/image-client.d.ts +8 -8
  10. package/dist/image.d.ts +593 -437
  11. package/dist/llm.d.ts +51 -51
  12. package/dist/media-client.d.ts +1 -1
  13. package/dist/media.d.ts +4 -4
  14. package/dist/promise.d.ts +199 -198
  15. package/dist/protocols/alibaba-chat.d.ts +81 -82
  16. package/dist/protocols/alibaba-chat.js +0 -1
  17. package/dist/protocols/alibaba-messages.d.ts +99 -99
  18. package/dist/protocols/alibaba-responses.d.ts +120 -120
  19. package/dist/protocols/anthropic-messages.d.ts +187 -187
  20. package/dist/protocols/anthropic-messages.js +3 -2
  21. package/dist/protocols/assemblyai-transcription.d.ts +1 -1
  22. package/dist/protocols/bedrock-converse.d.ts +75 -79
  23. package/dist/protocols/bfl-images.d.ts +1 -1
  24. package/dist/protocols/cartesia-speech.d.ts +17 -17
  25. package/dist/protocols/cohere-chat.d.ts +26 -23
  26. package/dist/protocols/cohere-chat.js +22 -1
  27. package/dist/protocols/deepgram-speech.d.ts +17 -17
  28. package/dist/protocols/deepgram-transcription.d.ts +1 -1
  29. package/dist/protocols/elevenlabs-speech.d.ts +17 -17
  30. package/dist/protocols/elevenlabs-transcription.d.ts +1 -1
  31. package/dist/protocols/fal-images.d.ts +1 -1
  32. package/dist/protocols/fal-video.d.ts +1 -1
  33. package/dist/protocols/gemini.d.ts +55 -55
  34. package/dist/protocols/gemini.js +11 -1
  35. package/dist/protocols/google-images.d.ts +1 -1
  36. package/dist/protocols/google-interactions.d.ts +64 -62
  37. package/dist/protocols/google-interactions.js +19 -1
  38. package/dist/protocols/google-speech.d.ts +17 -17
  39. package/dist/protocols/google-transcription.d.ts +47 -47
  40. package/dist/protocols/google-video.d.ts +1 -1
  41. package/dist/protocols/meta-messages.d.ts +121 -121
  42. package/dist/protocols/meta-responses.d.ts +201 -201
  43. package/dist/protocols/mistral-chat.d.ts +45 -45
  44. package/dist/protocols/open-responses-channel.d.ts +1 -1
  45. package/dist/protocols/open-responses.d.ts +584 -450
  46. package/dist/protocols/open-responses.js +27 -35
  47. package/dist/protocols/openai-chat.d.ts +248 -248
  48. package/dist/protocols/openai-chat.js +11 -42
  49. package/dist/protocols/openai-compatible-chat.d.ts +32 -32
  50. package/dist/protocols/openai-compatible-responses.d.ts +88 -88
  51. package/dist/protocols/openai-images.d.ts +17 -17
  52. package/dist/protocols/openai-responses.d.ts +567 -567
  53. package/dist/protocols/openai-responses.js +1 -1
  54. package/dist/protocols/openai-speech.d.ts +17 -17
  55. package/dist/protocols/openai-transcription.d.ts +47 -47
  56. package/dist/protocols/replicate-images.d.ts +1 -1
  57. package/dist/protocols/runway-video.d.ts +1 -1
  58. package/dist/protocols/shared.d.ts +12 -1
  59. package/dist/protocols/shared.js +17 -1
  60. package/dist/protocols/stability-images.d.ts +2 -2
  61. package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
  62. package/dist/protocols/utils/bedrock-media.d.ts +4 -4
  63. package/dist/protocols/utils/openai-options.d.ts +1 -1
  64. package/dist/protocols/utils/speech-stream.d.ts +1 -1
  65. package/dist/protocols/utils/tool-schema.d.ts +10 -5
  66. package/dist/protocols/utils/tool-stream.d.ts +152 -152
  67. package/dist/protocols/venice-chat.d.ts +109 -110
  68. package/dist/protocols/venice-chat.js +0 -1
  69. package/dist/protocols/xai-images.d.ts +1 -1
  70. package/dist/protocols/xai-responses.d.ts +79 -79
  71. package/dist/protocols/xai-video.d.ts +1 -1
  72. package/dist/protocols/zai-chat.d.ts +77 -78
  73. package/dist/protocols/zai-chat.js +0 -1
  74. package/dist/protocols/zai-images.d.ts +1 -1
  75. package/dist/protocols/zai-messages.d.ts +97 -97
  76. package/dist/providers/alibaba.d.ts +222 -283
  77. package/dist/providers/amazon-bedrock-mantle.d.ts +291 -298
  78. package/dist/providers/amazon-bedrock.d.ts +22 -28
  79. package/dist/providers/anthropic-compatible.d.ts +86 -90
  80. package/dist/providers/anthropic.d.ts +86 -90
  81. package/dist/providers/assemblyai.d.ts +2 -6
  82. package/dist/providers/azure.d.ts +228 -238
  83. package/dist/providers/baseten.d.ts +66 -70
  84. package/dist/providers/black-forest-labs.d.ts +2 -6
  85. package/dist/providers/cartesia.d.ts +2 -6
  86. package/dist/providers/cerebras.d.ts +66 -70
  87. package/dist/providers/cerebras.js +0 -1
  88. package/dist/providers/cloudflare-ai-gateway.d.ts +352 -356
  89. package/dist/providers/cloudflare-workers-ai.d.ts +66 -70
  90. package/dist/providers/cohere.d.ts +122 -132
  91. package/dist/providers/cohere.js +0 -2
  92. package/dist/providers/deepgram.d.ts +2 -7
  93. package/dist/providers/deepinfra.d.ts +66 -70
  94. package/dist/providers/deepinfra.js +0 -1
  95. package/dist/providers/deepseek.d.ts +66 -70
  96. package/dist/providers/deepseek.js +1 -1
  97. package/dist/providers/digitalocean.d.ts +137 -141
  98. package/dist/providers/elevenlabs.d.ts +2 -7
  99. package/dist/providers/fal.d.ts +2 -7
  100. package/dist/providers/fireworks.d.ts +66 -70
  101. package/dist/providers/google-vertex-chat.d.ts +34 -38
  102. package/dist/providers/google-vertex-interactions.d.ts +31 -41
  103. package/dist/providers/google-vertex-messages.d.ts +81 -85
  104. package/dist/providers/google-vertex-mistral.d.ts +23 -27
  105. package/dist/providers/google-vertex-responses.d.ts +90 -94
  106. package/dist/providers/google-vertex.d.ts +26 -30
  107. package/dist/providers/google.d.ts +94 -109
  108. package/dist/providers/groq.d.ts +111 -115
  109. package/dist/providers/groq.js +0 -1
  110. package/dist/providers/meta.d.ts +309 -317
  111. package/dist/providers/meta.js +1 -1
  112. package/dist/providers/minimax.d.ts +296 -303
  113. package/dist/providers/minimax.js +1 -1
  114. package/dist/providers/mistral.d.ts +22 -26
  115. package/dist/providers/moonshot.d.ts +296 -303
  116. package/dist/providers/moonshot.js +0 -1
  117. package/dist/providers/openai-compatible-responses.d.ts +90 -94
  118. package/dist/providers/openai-compatible.d.ts +34 -38
  119. package/dist/providers/openai.d.ts +93 -108
  120. package/dist/providers/opencode.d.ts +2 -8
  121. package/dist/providers/openrouter.d.ts +137 -144
  122. package/dist/providers/replicate.d.ts +2 -6
  123. package/dist/providers/runway.d.ts +2 -6
  124. package/dist/providers/stability.d.ts +2 -7
  125. package/dist/providers/togetherai.d.ts +66 -70
  126. package/dist/providers/togetherai.js +1 -1
  127. package/dist/providers/typesafe-ai.d.ts +2 -8
  128. package/dist/providers/venice.d.ts +58 -63
  129. package/dist/providers/vercel-ai-gateway.d.ts +2 -12
  130. package/dist/providers/xai.d.ts +38 -50
  131. package/dist/providers/zai-coding-plan.d.ts +206 -213
  132. package/dist/providers/zai.d.ts +40 -46
  133. package/dist/route/client.d.ts +51 -51
  134. package/dist/route/media-protocol.d.ts +1 -1
  135. package/dist/route/transport/http.d.ts +1 -1
  136. package/dist/route/transport/websocket.d.ts +8 -8
  137. package/dist/schema/errors.d.ts +19 -19
  138. package/dist/schema/events.d.ts +3090 -3288
  139. package/dist/schema/messages.d.ts +8 -7
  140. package/dist/schema/options.d.ts +2 -1
  141. package/dist/schema/options.js +2 -1
  142. package/dist/speech-client.d.ts +8 -8
  143. package/dist/speech.d.ts +434 -398
  144. package/dist/testing.d.ts +338 -338
  145. package/dist/tool-runtime.d.ts +1 -1
  146. package/dist/transcription-client.d.ts +23 -23
  147. package/dist/transcription.d.ts +562 -646
  148. package/dist/utils/sanitize.d.ts +4 -0
  149. package/dist/utils/sanitize.js +23 -6
  150. package/dist/video-client.d.ts +8 -8
  151. package/dist/video.d.ts +416 -372
  152. package/package.json +6 -6
@@ -16,12 +16,12 @@ export type DeepgramSpeechOptions = {
16
16
  } & Record<string, unknown>;
17
17
  export type Request = SpeechRequestFor<DeepgramSpeechOptions>;
18
18
  export declare const protocol: MediaProtocol.Streamed<Request, {
19
- readonly id: string;
20
19
  readonly type: "generation-queued";
20
+ readonly id: string;
21
21
  readonly position?: number | undefined;
22
22
  } | {
23
- readonly id: string;
24
23
  readonly type: "generation-progress";
24
+ readonly id: string;
25
25
  readonly progress?: number | undefined;
26
26
  } | {
27
27
  readonly type: "audio-delta";
@@ -36,11 +36,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
36
36
  } | {
37
37
  readonly type: "finish";
38
38
  readonly audio: import("../media.js").Asset;
39
- readonly providerMetadata?: {
40
- readonly [x: string]: {
41
- readonly [x: string]: unknown;
42
- };
43
- } | undefined;
44
39
  readonly usage?: {
45
40
  readonly type: "tokens";
46
41
  readonly input?: number | undefined;
@@ -63,7 +58,7 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
63
58
  readonly seconds: number;
64
59
  } | undefined;
65
60
  readonly notices?: readonly {
66
- readonly type: "other" | "moderated" | "filtered";
61
+ readonly type: "filtered" | "moderated" | "other";
67
62
  readonly message: string;
68
63
  readonly providerMetadata?: {
69
64
  readonly [x: string]: {
@@ -71,16 +66,21 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
71
66
  };
72
67
  } | undefined;
73
68
  }[] | undefined;
69
+ readonly providerMetadata?: {
70
+ readonly [x: string]: {
71
+ readonly [x: string]: unknown;
72
+ };
73
+ } | undefined;
74
74
  }, Uint8Array<ArrayBufferLike>, SpeechStream.Audio>;
75
75
  export declare const model: (input: MediaRoute.ModelInput) => SpeechModel<DeepgramSpeechOptions>;
76
76
  export declare const DeepgramSpeech: {
77
77
  readonly protocol: MediaProtocol.Streamed<Request, {
78
- readonly id: string;
79
78
  readonly type: "generation-queued";
79
+ readonly id: string;
80
80
  readonly position?: number | undefined;
81
81
  } | {
82
- readonly id: string;
83
82
  readonly type: "generation-progress";
83
+ readonly id: string;
84
84
  readonly progress?: number | undefined;
85
85
  } | {
86
86
  readonly type: "audio-delta";
@@ -95,11 +95,6 @@ export declare const DeepgramSpeech: {
95
95
  } | {
96
96
  readonly type: "finish";
97
97
  readonly audio: import("../media.js").Asset;
98
- readonly providerMetadata?: {
99
- readonly [x: string]: {
100
- readonly [x: string]: unknown;
101
- };
102
- } | undefined;
103
98
  readonly usage?: {
104
99
  readonly type: "tokens";
105
100
  readonly input?: number | undefined;
@@ -122,7 +117,7 @@ export declare const DeepgramSpeech: {
122
117
  readonly seconds: number;
123
118
  } | undefined;
124
119
  readonly notices?: readonly {
125
- readonly type: "other" | "moderated" | "filtered";
120
+ readonly type: "filtered" | "moderated" | "other";
126
121
  readonly message: string;
127
122
  readonly providerMetadata?: {
128
123
  readonly [x: string]: {
@@ -130,6 +125,11 @@ export declare const DeepgramSpeech: {
130
125
  };
131
126
  } | undefined;
132
127
  }[] | undefined;
128
+ readonly providerMetadata?: {
129
+ readonly [x: string]: {
130
+ readonly [x: string]: unknown;
131
+ };
132
+ } | undefined;
133
133
  }, Uint8Array<ArrayBufferLike>, SpeechStream.Audio>;
134
- readonly model: (input: MediaRoute.ModelInput) => SpeechModel<DeepgramSpeechOptions>;
134
+ readonly model: typeof model;
135
135
  };
@@ -22,5 +22,5 @@ export declare const protocol: MediaProtocol.Inline<Request, TranscriptionRespon
22
22
  export declare const model: (input: MediaRoute.ModelInput) => TranscriptionModel<DeepgramTranscriptionOptions>;
23
23
  export declare const DeepgramTranscription: {
24
24
  readonly protocol: MediaProtocol.Inline<Request, TranscriptionResponse>;
25
- readonly model: (input: MediaRoute.ModelInput) => TranscriptionModel<DeepgramTranscriptionOptions>;
25
+ readonly model: typeof model;
26
26
  };
@@ -19,12 +19,12 @@ export type ElevenLabsSpeechOptions = {
19
19
  } & Record<string, unknown>;
20
20
  export type Request = SpeechRequestFor<ElevenLabsSpeechOptions>;
21
21
  export declare const protocol: MediaProtocol.Streamed<Request, {
22
- readonly id: string;
23
22
  readonly type: "generation-queued";
23
+ readonly id: string;
24
24
  readonly position?: number | undefined;
25
25
  } | {
26
- readonly id: string;
27
26
  readonly type: "generation-progress";
27
+ readonly id: string;
28
28
  readonly progress?: number | undefined;
29
29
  } | {
30
30
  readonly type: "audio-delta";
@@ -39,11 +39,6 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
39
39
  } | {
40
40
  readonly type: "finish";
41
41
  readonly audio: import("../media.js").Asset;
42
- readonly providerMetadata?: {
43
- readonly [x: string]: {
44
- readonly [x: string]: unknown;
45
- };
46
- } | undefined;
47
42
  readonly usage?: {
48
43
  readonly type: "tokens";
49
44
  readonly input?: number | undefined;
@@ -66,7 +61,7 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
66
61
  readonly seconds: number;
67
62
  } | undefined;
68
63
  readonly notices?: readonly {
69
- readonly type: "other" | "moderated" | "filtered";
64
+ readonly type: "filtered" | "moderated" | "other";
70
65
  readonly message: string;
71
66
  readonly providerMetadata?: {
72
67
  readonly [x: string]: {
@@ -74,16 +69,21 @@ export declare const protocol: MediaProtocol.Streamed<Request, {
74
69
  };
75
70
  } | undefined;
76
71
  }[] | undefined;
72
+ readonly providerMetadata?: {
73
+ readonly [x: string]: {
74
+ readonly [x: string]: unknown;
75
+ };
76
+ } | undefined;
77
77
  }, string | Uint8Array<ArrayBufferLike>, SpeechStream.Audio>;
78
78
  export declare const model: (input: MediaRoute.ModelInput) => SpeechModel<ElevenLabsSpeechOptions>;
79
79
  export declare const ElevenLabsSpeech: {
80
80
  readonly protocol: MediaProtocol.Streamed<Request, {
81
- readonly id: string;
82
81
  readonly type: "generation-queued";
82
+ readonly id: string;
83
83
  readonly position?: number | undefined;
84
84
  } | {
85
- readonly id: string;
86
85
  readonly type: "generation-progress";
86
+ readonly id: string;
87
87
  readonly progress?: number | undefined;
88
88
  } | {
89
89
  readonly type: "audio-delta";
@@ -98,11 +98,6 @@ export declare const ElevenLabsSpeech: {
98
98
  } | {
99
99
  readonly type: "finish";
100
100
  readonly audio: import("../media.js").Asset;
101
- readonly providerMetadata?: {
102
- readonly [x: string]: {
103
- readonly [x: string]: unknown;
104
- };
105
- } | undefined;
106
101
  readonly usage?: {
107
102
  readonly type: "tokens";
108
103
  readonly input?: number | undefined;
@@ -125,7 +120,7 @@ export declare const ElevenLabsSpeech: {
125
120
  readonly seconds: number;
126
121
  } | undefined;
127
122
  readonly notices?: readonly {
128
- readonly type: "other" | "moderated" | "filtered";
123
+ readonly type: "filtered" | "moderated" | "other";
129
124
  readonly message: string;
130
125
  readonly providerMetadata?: {
131
126
  readonly [x: string]: {
@@ -133,6 +128,11 @@ export declare const ElevenLabsSpeech: {
133
128
  };
134
129
  } | undefined;
135
130
  }[] | undefined;
131
+ readonly providerMetadata?: {
132
+ readonly [x: string]: {
133
+ readonly [x: string]: unknown;
134
+ };
135
+ } | undefined;
136
136
  }, string | Uint8Array<ArrayBufferLike>, SpeechStream.Audio>;
137
- readonly model: (input: MediaRoute.ModelInput) => SpeechModel<ElevenLabsSpeechOptions>;
137
+ readonly model: typeof model;
138
138
  };
@@ -24,5 +24,5 @@ export declare const protocol: MediaProtocol.Inline<Request, TranscriptionRespon
24
24
  export declare const model: (input: MediaRoute.ModelInput) => TranscriptionModel<ElevenLabsTranscriptionOptions>;
25
25
  export declare const ElevenLabsTranscription: {
26
26
  readonly protocol: MediaProtocol.Inline<Request, TranscriptionResponse>;
27
- readonly model: (input: MediaRoute.ModelInput) => TranscriptionModel<ElevenLabsTranscriptionOptions>;
27
+ readonly model: typeof model;
28
28
  };
@@ -21,5 +21,5 @@ export declare const FalImages: {
21
21
  readonly responseURL: string;
22
22
  readonly cancelURL: string;
23
23
  }>;
24
- readonly model: (input: MediaRoute.ModelInput) => ImageModel<FalImageOptions>;
24
+ readonly model: typeof model;
25
25
  };
@@ -25,5 +25,5 @@ export declare const FalVideo: {
25
25
  readonly responseURL: string;
26
26
  readonly cancelURL: string;
27
27
  }>;
28
- readonly model: (input: MediaRoute.ModelInput) => VideoModel<FalVideoOptions>;
28
+ readonly model: typeof model;
29
29
  };
@@ -11,14 +11,14 @@ export type ProviderOptionsInput = OptionsInput;
11
11
  declare const Options: Schema.Struct<{
12
12
  readonly cachedContent: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.String>, never>>;
13
13
  readonly safetySettings: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.$Array<Schema.Struct<{
14
- readonly category: Schema.declare<import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">, import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">>;
15
- readonly threshold: Schema.declare<import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">, import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">>;
14
+ readonly category: Schema.declare<import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">, import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">>;
15
+ readonly threshold: Schema.declare<import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">, import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">>;
16
16
  }>>>, never>>;
17
- readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"standard" | "flex" | "priority">, import("../schema/options.js").OpenString<"standard" | "flex" | "priority">>>, never>>;
17
+ readonly serviceTier: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"flex" | "priority" | "standard">, import("../schema/options.js").OpenString<"flex" | "priority" | "standard">>>, never>>;
18
18
  readonly thinkingConfig: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Struct<{
19
19
  readonly thinkingBudget: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Number>, never>>;
20
20
  readonly includeThoughts: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.Boolean>, never>>;
21
- readonly thinkingLevel: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high">, import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high">>>, never>>;
21
+ readonly thinkingLevel: Schema.optionalKey<Schema.middlewareDecoding<Schema.UndefinedOr<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal">, import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal">>>, never>>;
22
22
  }>>, never>>;
23
23
  }>;
24
24
  declare const GeminiBody: Schema.Struct<{
@@ -64,8 +64,8 @@ declare const GeminiBody: Schema.Struct<{
64
64
  }>>;
65
65
  labels: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
66
66
  safetySettings: Schema.optional<Schema.$Array<Schema.Struct<{
67
- readonly category: Schema.declare<import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">, import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">>;
68
- readonly threshold: Schema.declare<import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">, import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">>;
67
+ readonly category: Schema.declare<import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">, import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">>;
68
+ readonly threshold: Schema.declare<import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">, import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">>;
69
69
  }>>>;
70
70
  serviceTier: Schema.optional<Schema.String>;
71
71
  systemInstruction: Schema.optional<Schema.Struct<{
@@ -98,7 +98,7 @@ declare const GeminiBody: Schema.Struct<{
98
98
  readonly thinkingConfig: Schema.optional<Schema.Struct<{
99
99
  readonly thinkingBudget: Schema.optional<Schema.Number>;
100
100
  readonly includeThoughts: Schema.optional<Schema.Boolean>;
101
- readonly thinkingLevel: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high">, import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high">>>;
101
+ readonly thinkingLevel: Schema.optional<Schema.declare<import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal">, import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal">>>;
102
102
  }>>;
103
103
  }>>;
104
104
  continuationToken: Schema.optional<Schema.String>;
@@ -154,7 +154,9 @@ export declare const transport: Transport<GeminiBody, Prepared, unknown>;
154
154
  * streaming-event state machine shared by Google AI Studio and Vertex Gemini.
155
155
  */
156
156
  export declare const protocol: Protocol<{
157
+ readonly cachedContent?: string | undefined;
157
158
  readonly contents: readonly {
159
+ readonly role?: "model" | "user" | null | undefined;
158
160
  readonly parts?: readonly ({
159
161
  readonly inlineData: {
160
162
  readonly mimeType: string;
@@ -172,16 +174,16 @@ export declare const protocol: Protocol<{
172
174
  };
173
175
  } | {
174
176
  readonly functionCall: {
175
- readonly name: string;
176
177
  readonly id?: string | null | undefined;
178
+ readonly name: string;
177
179
  readonly args?: unknown;
178
180
  };
179
181
  readonly thoughtSignature?: string | null | undefined;
180
182
  } | {
181
183
  readonly functionResponse: {
184
+ readonly id?: string | undefined;
182
185
  readonly name: string;
183
186
  readonly response: unknown;
184
- readonly id?: string | undefined;
185
187
  readonly parts?: readonly {
186
188
  readonly inlineData: {
187
189
  readonly mimeType: string;
@@ -191,8 +193,20 @@ export declare const protocol: Protocol<{
191
193
  }[] | undefined;
192
194
  };
193
195
  })[] | null | undefined;
194
- readonly role?: "model" | "user" | null | undefined;
195
196
  }[];
197
+ readonly labels?: {
198
+ readonly [x: string]: string;
199
+ } | undefined;
200
+ readonly safetySettings?: readonly {
201
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">;
202
+ readonly threshold: import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">;
203
+ }[] | undefined;
204
+ readonly serviceTier?: string | undefined;
205
+ readonly systemInstruction?: {
206
+ readonly parts: readonly {
207
+ readonly text: string;
208
+ }[];
209
+ } | undefined;
196
210
  readonly tools?: readonly {
197
211
  readonly functionDeclarations: readonly {
198
212
  readonly name: string;
@@ -202,27 +216,14 @@ export declare const protocol: Protocol<{
202
216
  };
203
217
  }[];
204
218
  }[] | undefined;
205
- readonly serviceTier?: string | undefined;
206
219
  readonly toolConfig?: {
207
220
  readonly functionCallingConfig: {
208
- readonly mode: "NONE" | "AUTO" | "ANY";
221
+ readonly mode: "ANY" | "AUTO" | "NONE";
209
222
  readonly allowedFunctionNames?: readonly string[] | undefined;
210
223
  };
211
224
  } | undefined;
212
- readonly cachedContent?: string | undefined;
213
- readonly safetySettings?: readonly {
214
- readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">;
215
- readonly threshold: import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">;
216
- }[] | undefined;
217
- readonly labels?: {
218
- readonly [x: string]: string;
219
- } | undefined;
220
- readonly systemInstruction?: {
221
- readonly parts: readonly {
222
- readonly text: string;
223
- }[];
224
- } | undefined;
225
225
  readonly generationConfig?: {
226
+ readonly maxOutputTokens?: number | undefined;
226
227
  readonly temperature?: number | undefined;
227
228
  readonly topP?: number | undefined;
228
229
  readonly topK?: number | undefined;
@@ -233,17 +234,16 @@ export declare const protocol: Protocol<{
233
234
  readonly thinkingConfig?: {
234
235
  readonly thinkingBudget?: number | undefined;
235
236
  readonly includeThoughts?: boolean | undefined;
236
- readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
237
+ readonly thinkingLevel?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
237
238
  } | undefined;
238
- readonly maxOutputTokens?: number | undefined;
239
239
  } | undefined;
240
240
  readonly continuationToken?: string | undefined;
241
241
  }, NextRequest | {
242
242
  readonly error?: unknown;
243
243
  readonly candidates?: readonly {
244
244
  readonly content?: {
245
- readonly parts?: readonly unknown[] | null | undefined;
246
245
  readonly role?: "model" | "user" | null | undefined;
246
+ readonly parts?: readonly unknown[] | null | undefined;
247
247
  } | null | undefined;
248
248
  readonly finishReason?: string | null | undefined;
249
249
  }[] | null | undefined;
@@ -254,18 +254,18 @@ export declare const protocol: Protocol<{
254
254
  readonly safetyRatings?: unknown;
255
255
  } | null | undefined;
256
256
  readonly usageMetadata?: {
257
+ readonly cachedContentTokenCount?: number | null | undefined;
258
+ readonly thoughtsTokenCount?: number | null | undefined;
257
259
  readonly promptTokenCount?: number | null | undefined;
258
260
  readonly candidatesTokenCount?: number | null | undefined;
259
261
  readonly totalTokenCount?: number | null | undefined;
260
- readonly cachedContentTokenCount?: number | null | undefined;
261
- readonly thoughtsTokenCount?: number | null | undefined;
262
262
  } | null | undefined;
263
- }, {
263
+ }, NextRequest | {
264
264
  readonly error?: unknown;
265
265
  readonly candidates?: readonly {
266
266
  readonly content?: {
267
- readonly parts?: readonly unknown[] | null | undefined;
268
267
  readonly role?: "model" | "user" | null | undefined;
268
+ readonly parts?: readonly unknown[] | null | undefined;
269
269
  } | null | undefined;
270
270
  readonly finishReason?: string | null | undefined;
271
271
  }[] | null | undefined;
@@ -276,15 +276,17 @@ export declare const protocol: Protocol<{
276
276
  readonly safetyRatings?: unknown;
277
277
  } | null | undefined;
278
278
  readonly usageMetadata?: {
279
+ readonly cachedContentTokenCount?: number | null | undefined;
280
+ readonly thoughtsTokenCount?: number | null | undefined;
279
281
  readonly promptTokenCount?: number | null | undefined;
280
282
  readonly candidatesTokenCount?: number | null | undefined;
281
283
  readonly totalTokenCount?: number | null | undefined;
282
- readonly cachedContentTokenCount?: number | null | undefined;
283
- readonly thoughtsTokenCount?: number | null | undefined;
284
284
  } | null | undefined;
285
- } | NextRequest, ParserState>;
285
+ }, ParserState>;
286
286
  export declare const route: Route<{
287
+ readonly cachedContent?: string | undefined;
287
288
  readonly contents: readonly {
289
+ readonly role?: "model" | "user" | null | undefined;
288
290
  readonly parts?: readonly ({
289
291
  readonly inlineData: {
290
292
  readonly mimeType: string;
@@ -302,16 +304,16 @@ export declare const route: Route<{
302
304
  };
303
305
  } | {
304
306
  readonly functionCall: {
305
- readonly name: string;
306
307
  readonly id?: string | null | undefined;
308
+ readonly name: string;
307
309
  readonly args?: unknown;
308
310
  };
309
311
  readonly thoughtSignature?: string | null | undefined;
310
312
  } | {
311
313
  readonly functionResponse: {
314
+ readonly id?: string | undefined;
312
315
  readonly name: string;
313
316
  readonly response: unknown;
314
- readonly id?: string | undefined;
315
317
  readonly parts?: readonly {
316
318
  readonly inlineData: {
317
319
  readonly mimeType: string;
@@ -321,8 +323,20 @@ export declare const route: Route<{
321
323
  }[] | undefined;
322
324
  };
323
325
  })[] | null | undefined;
324
- readonly role?: "model" | "user" | null | undefined;
325
326
  }[];
327
+ readonly labels?: {
328
+ readonly [x: string]: string;
329
+ } | undefined;
330
+ readonly safetySettings?: readonly {
331
+ readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_UNSPECIFIED">;
332
+ readonly threshold: import("../schema/options.js").OpenString<"BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF">;
333
+ }[] | undefined;
334
+ readonly serviceTier?: string | undefined;
335
+ readonly systemInstruction?: {
336
+ readonly parts: readonly {
337
+ readonly text: string;
338
+ }[];
339
+ } | undefined;
326
340
  readonly tools?: readonly {
327
341
  readonly functionDeclarations: readonly {
328
342
  readonly name: string;
@@ -332,27 +346,14 @@ export declare const route: Route<{
332
346
  };
333
347
  }[];
334
348
  }[] | undefined;
335
- readonly serviceTier?: string | undefined;
336
349
  readonly toolConfig?: {
337
350
  readonly functionCallingConfig: {
338
- readonly mode: "NONE" | "AUTO" | "ANY";
351
+ readonly mode: "ANY" | "AUTO" | "NONE";
339
352
  readonly allowedFunctionNames?: readonly string[] | undefined;
340
353
  };
341
354
  } | undefined;
342
- readonly cachedContent?: string | undefined;
343
- readonly safetySettings?: readonly {
344
- readonly category: import("../schema/options.js").OpenString<"HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY">;
345
- readonly threshold: import("../schema/options.js").OpenString<"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF">;
346
- }[] | undefined;
347
- readonly labels?: {
348
- readonly [x: string]: string;
349
- } | undefined;
350
- readonly systemInstruction?: {
351
- readonly parts: readonly {
352
- readonly text: string;
353
- }[];
354
- } | undefined;
355
355
  readonly generationConfig?: {
356
+ readonly maxOutputTokens?: number | undefined;
356
357
  readonly temperature?: number | undefined;
357
358
  readonly topP?: number | undefined;
358
359
  readonly topK?: number | undefined;
@@ -363,9 +364,8 @@ export declare const route: Route<{
363
364
  readonly thinkingConfig?: {
364
365
  readonly thinkingBudget?: number | undefined;
365
366
  readonly includeThoughts?: boolean | undefined;
366
- readonly thinkingLevel?: import("../schema/options.js").OpenString<"minimal" | "low" | "medium" | "high"> | undefined;
367
+ readonly thinkingLevel?: import("../schema/options.js").OpenString<"high" | "low" | "medium" | "minimal"> | undefined;
367
368
  } | undefined;
368
- readonly maxOutputTokens?: number | undefined;
369
369
  } | undefined;
370
370
  readonly continuationToken?: string | undefined;
371
371
  }, Prepared, import("../route/client.js").CompactionOperations | undefined>;
@@ -5,7 +5,7 @@ import { Auth } from "../route/auth.js";
5
5
  import { Endpoint } from "../route/endpoint.js";
6
6
  import { Protocol } from "../route/protocol.js";
7
7
  import { HttpTransport, } from "../route/transport/index.js";
8
- import { AIError, LLMEvent, Usage, } from "../schema/index.js";
8
+ import { AIError, InvalidProviderOutputError, LLMEvent, Usage, } from "../schema/index.js";
9
9
  import { classifyProviderFailure } from "../provider-error.js";
10
10
  import { Media } from "../media.js";
11
11
  import { JsonObject, knownString, lenient, optionalArray, optionalNull, ProviderShared } from "./shared.js";
@@ -534,6 +534,16 @@ const step = (state, event) => {
534
534
  usage: event.usageMetadata ?? state.usage,
535
535
  finishReason: candidate?.finishReason ?? state.finishReason,
536
536
  };
537
+ // Gemini sporadically ends a valid request with MALFORMED_RESPONSE; continuing or resending it recovers.
538
+ if (candidate?.finishReason === "MALFORMED_RESPONSE")
539
+ return Effect.fail(new AIError({
540
+ reason: new InvalidProviderOutputError({
541
+ route: state.route,
542
+ message: `Gemini stopped with ${candidate.finishReason}`,
543
+ body: ProviderShared.encodeJson(event),
544
+ classification: "incomplete-stream",
545
+ }),
546
+ }));
537
547
  if (candidate?.finishReason && mapFinishReason(candidate.finishReason, state.hasToolCalls) === "error")
538
548
  return Effect.fail(ProviderShared.eventError(state.route, `Gemini stopped with ${candidate.finishReason}`, ProviderShared.encodeJson(event)));
539
549
  if (!candidate?.content)
@@ -14,5 +14,5 @@ export declare const protocol: MediaProtocol.Inline<Request, ImageResponse>;
14
14
  export declare const model: (input: MediaRoute.ModelInput) => ImageModel<GoogleImageOptions>;
15
15
  export declare const GoogleImages: {
16
16
  readonly protocol: MediaProtocol.Inline<Request, ImageResponse>;
17
- readonly model: (input: MediaRoute.ModelInput) => ImageModel<GoogleImageOptions>;
17
+ readonly model: typeof model;
18
18
  };