@opencode/ai 0.0.0-beta-19275

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 (252) hide show
  1. package/README.md +682 -0
  2. package/dist/cache-policy.d.ts +2 -0
  3. package/dist/cache-policy.js +129 -0
  4. package/dist/image-client.d.ts +19 -0
  5. package/dist/image-client.js +28 -0
  6. package/dist/image.d.ts +110 -0
  7. package/dist/image.js +103 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.js +12 -0
  10. package/dist/llm.d.ts +252 -0
  11. package/dist/llm.js +74 -0
  12. package/dist/protocols/anthropic-messages.d.ts +957 -0
  13. package/dist/protocols/anthropic-messages.js +1414 -0
  14. package/dist/protocols/bedrock-converse.d.ts +499 -0
  15. package/dist/protocols/bedrock-converse.js +643 -0
  16. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  17. package/dist/protocols/bedrock-event-stream.js +97 -0
  18. package/dist/protocols/gemini.d.ts +285 -0
  19. package/dist/protocols/gemini.js +671 -0
  20. package/dist/protocols/google-images.d.ts +30 -0
  21. package/dist/protocols/google-images.js +181 -0
  22. package/dist/protocols/index.d.ts +12 -0
  23. package/dist/protocols/index.js +12 -0
  24. package/dist/protocols/meta-images.d.ts +26 -0
  25. package/dist/protocols/meta-images.js +89 -0
  26. package/dist/protocols/meta-messages.d.ts +350 -0
  27. package/dist/protocols/meta-messages.js +41 -0
  28. package/dist/protocols/meta-responses.d.ts +473 -0
  29. package/dist/protocols/meta-responses.js +173 -0
  30. package/dist/protocols/mistral-chat.d.ts +540 -0
  31. package/dist/protocols/mistral-chat.js +624 -0
  32. package/dist/protocols/open-responses-channel.d.ts +23 -0
  33. package/dist/protocols/open-responses-channel.js +141 -0
  34. package/dist/protocols/open-responses-continuation.d.ts +12 -0
  35. package/dist/protocols/open-responses-continuation.js +161 -0
  36. package/dist/protocols/open-responses.d.ts +1583 -0
  37. package/dist/protocols/open-responses.js +1206 -0
  38. package/dist/protocols/openai-chat.d.ts +860 -0
  39. package/dist/protocols/openai-chat.js +966 -0
  40. package/dist/protocols/openai-compatible-chat.d.ts +109 -0
  41. package/dist/protocols/openai-compatible-chat.js +19 -0
  42. package/dist/protocols/openai-compatible-responses.d.ts +172 -0
  43. package/dist/protocols/openai-compatible-responses.js +18 -0
  44. package/dist/protocols/openai-images.d.ts +32 -0
  45. package/dist/protocols/openai-images.js +183 -0
  46. package/dist/protocols/openai-responses.d.ts +1389 -0
  47. package/dist/protocols/openai-responses.js +260 -0
  48. package/dist/protocols/shared.d.ts +193 -0
  49. package/dist/protocols/shared.js +290 -0
  50. package/dist/protocols/utils/bedrock-auth.d.ts +60 -0
  51. package/dist/protocols/utils/bedrock-auth.js +85 -0
  52. package/dist/protocols/utils/bedrock-cache.d.ts +19 -0
  53. package/dist/protocols/utils/bedrock-cache.js +49 -0
  54. package/dist/protocols/utils/bedrock-media.d.ts +55 -0
  55. package/dist/protocols/utils/bedrock-media.js +73 -0
  56. package/dist/protocols/utils/cache.d.ts +6 -0
  57. package/dist/protocols/utils/cache.js +5 -0
  58. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  59. package/dist/protocols/utils/gemini-tool-schema.js +103 -0
  60. package/dist/protocols/utils/image-input.d.ts +21 -0
  61. package/dist/protocols/utils/image-input.js +20 -0
  62. package/dist/protocols/utils/lifecycle.d.ts +24 -0
  63. package/dist/protocols/utils/lifecycle.js +72 -0
  64. package/dist/protocols/utils/meta-image.d.ts +2 -0
  65. package/dist/protocols/utils/meta-image.js +13 -0
  66. package/dist/protocols/utils/open-responses-options.d.ts +56 -0
  67. package/dist/protocols/utils/open-responses-options.js +61 -0
  68. package/dist/protocols/utils/openai-image.d.ts +5 -0
  69. package/dist/protocols/utils/openai-image.js +18 -0
  70. package/dist/protocols/utils/openai-options.d.ts +16 -0
  71. package/dist/protocols/utils/openai-options.js +14 -0
  72. package/dist/protocols/utils/partial-json-options.d.ts +62 -0
  73. package/dist/protocols/utils/partial-json-options.js +52 -0
  74. package/dist/protocols/utils/partial-json.d.ts +8 -0
  75. package/dist/protocols/utils/partial-json.js +279 -0
  76. package/dist/protocols/utils/responses-checkpoint.d.ts +4 -0
  77. package/dist/protocols/utils/responses-checkpoint.js +107 -0
  78. package/dist/protocols/utils/responses-compaction.d.ts +4 -0
  79. package/dist/protocols/utils/responses-compaction.js +129 -0
  80. package/dist/protocols/utils/responses-hosted-tools.d.ts +26 -0
  81. package/dist/protocols/utils/responses-hosted-tools.js +32 -0
  82. package/dist/protocols/utils/tool-schema.d.ts +8 -0
  83. package/dist/protocols/utils/tool-schema.js +54 -0
  84. package/dist/protocols/utils/tool-stream.d.ts +710 -0
  85. package/dist/protocols/utils/tool-stream.js +155 -0
  86. package/dist/protocols/xai-images.d.ts +26 -0
  87. package/dist/protocols/xai-images.js +106 -0
  88. package/dist/protocols/xai-responses.d.ts +250 -0
  89. package/dist/protocols/xai-responses.js +81 -0
  90. package/dist/protocols/zai-images.d.ts +22 -0
  91. package/dist/protocols/zai-images.js +79 -0
  92. package/dist/protocols.d.ts +1 -0
  93. package/dist/protocols.js +1 -0
  94. package/dist/provider-error.d.ts +15 -0
  95. package/dist/provider-error.js +125 -0
  96. package/dist/provider-package.d.ts +11 -0
  97. package/dist/provider-package.js +1 -0
  98. package/dist/provider.d.ts +23 -0
  99. package/dist/provider.js +2 -0
  100. package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
  101. package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
  102. package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
  103. package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
  104. package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
  105. package/dist/providers/amazon-bedrock/mantle.js +1 -0
  106. package/dist/providers/amazon-bedrock-mantle.d.ts +371 -0
  107. package/dist/providers/amazon-bedrock-mantle.js +76 -0
  108. package/dist/providers/amazon-bedrock.d.ts +173 -0
  109. package/dist/providers/amazon-bedrock.js +41 -0
  110. package/dist/providers/anthropic-compatible.d.ts +304 -0
  111. package/dist/providers/anthropic-compatible.js +44 -0
  112. package/dist/providers/anthropic.d.ts +302 -0
  113. package/dist/providers/anthropic.js +39 -0
  114. package/dist/providers/azure/chat.d.ts +2 -0
  115. package/dist/providers/azure/chat.js +1 -0
  116. package/dist/providers/azure/responses.d.ts +2 -0
  117. package/dist/providers/azure/responses.js +1 -0
  118. package/dist/providers/azure.d.ts +599 -0
  119. package/dist/providers/azure.js +115 -0
  120. package/dist/providers/baseten.d.ts +229 -0
  121. package/dist/providers/baseten.js +38 -0
  122. package/dist/providers/cerebras.d.ts +228 -0
  123. package/dist/providers/cerebras.js +40 -0
  124. package/dist/providers/cloudflare-ai-gateway.d.ts +238 -0
  125. package/dist/providers/cloudflare-ai-gateway.js +59 -0
  126. package/dist/providers/cloudflare-workers-ai.d.ts +232 -0
  127. package/dist/providers/cloudflare-workers-ai.js +45 -0
  128. package/dist/providers/deepinfra.d.ts +228 -0
  129. package/dist/providers/deepinfra.js +43 -0
  130. package/dist/providers/deepseek.d.ts +229 -0
  131. package/dist/providers/deepseek.js +41 -0
  132. package/dist/providers/fireworks.d.ts +229 -0
  133. package/dist/providers/fireworks.js +38 -0
  134. package/dist/providers/google-vertex/chat.d.ts +2 -0
  135. package/dist/providers/google-vertex/chat.js +1 -0
  136. package/dist/providers/google-vertex/gemini.d.ts +2 -0
  137. package/dist/providers/google-vertex/gemini.js +1 -0
  138. package/dist/providers/google-vertex/messages.d.ts +2 -0
  139. package/dist/providers/google-vertex/messages.js +1 -0
  140. package/dist/providers/google-vertex/responses.d.ts +2 -0
  141. package/dist/providers/google-vertex/responses.js +1 -0
  142. package/dist/providers/google-vertex-chat.d.ts +133 -0
  143. package/dist/providers/google-vertex-chat.js +55 -0
  144. package/dist/providers/google-vertex-messages.d.ts +301 -0
  145. package/dist/providers/google-vertex-messages.js +75 -0
  146. package/dist/providers/google-vertex-responses.d.ts +198 -0
  147. package/dist/providers/google-vertex-responses.js +56 -0
  148. package/dist/providers/google-vertex-shared.d.ts +22 -0
  149. package/dist/providers/google-vertex-shared.js +61 -0
  150. package/dist/providers/google-vertex.d.ts +120 -0
  151. package/dist/providers/google-vertex.js +92 -0
  152. package/dist/providers/google.d.ts +115 -0
  153. package/dist/providers/google.js +42 -0
  154. package/dist/providers/groq.d.ts +315 -0
  155. package/dist/providers/groq.js +81 -0
  156. package/dist/providers/index.d.ts +28 -0
  157. package/dist/providers/index.js +28 -0
  158. package/dist/providers/meta/chat.d.ts +2 -0
  159. package/dist/providers/meta/chat.js +1 -0
  160. package/dist/providers/meta/messages.d.ts +2 -0
  161. package/dist/providers/meta/messages.js +1 -0
  162. package/dist/providers/meta/responses.d.ts +2 -0
  163. package/dist/providers/meta/responses.js +1 -0
  164. package/dist/providers/meta.d.ts +631 -0
  165. package/dist/providers/meta.js +113 -0
  166. package/dist/providers/minimax/chat.d.ts +4 -0
  167. package/dist/providers/minimax/chat.js +8 -0
  168. package/dist/providers/minimax/messages.d.ts +1 -0
  169. package/dist/providers/minimax/messages.js +1 -0
  170. package/dist/providers/minimax/responses.d.ts +4 -0
  171. package/dist/providers/minimax/responses.js +8 -0
  172. package/dist/providers/minimax.d.ts +593 -0
  173. package/dist/providers/minimax.js +89 -0
  174. package/dist/providers/mistral.d.ts +208 -0
  175. package/dist/providers/mistral.js +28 -0
  176. package/dist/providers/open-responses-options.d.ts +6 -0
  177. package/dist/providers/open-responses-options.js +1 -0
  178. package/dist/providers/openai/chat.d.ts +2 -0
  179. package/dist/providers/openai/chat.js +1 -0
  180. package/dist/providers/openai/responses.d.ts +2 -0
  181. package/dist/providers/openai/responses.js +1 -0
  182. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  183. package/dist/providers/openai-compatible/responses.js +1 -0
  184. package/dist/providers/openai-compatible-responses.d.ts +196 -0
  185. package/dist/providers/openai-compatible-responses.js +32 -0
  186. package/dist/providers/openai-compatible.d.ts +131 -0
  187. package/dist/providers/openai-compatible.js +33 -0
  188. package/dist/providers/openai-options.d.ts +26 -0
  189. package/dist/providers/openai-options.js +41 -0
  190. package/dist/providers/openai.d.ts +405 -0
  191. package/dist/providers/openai.js +82 -0
  192. package/dist/providers/openrouter.d.ts +564 -0
  193. package/dist/providers/openrouter.js +114 -0
  194. package/dist/providers/togetherai.d.ts +228 -0
  195. package/dist/providers/togetherai.js +40 -0
  196. package/dist/providers/xai.d.ts +164 -0
  197. package/dist/providers/xai.js +84 -0
  198. package/dist/providers/zai.d.ts +24 -0
  199. package/dist/providers/zai.js +21 -0
  200. package/dist/providers.d.ts +1 -0
  201. package/dist/providers.js +1 -0
  202. package/dist/route/auth-options.d.ts +34 -0
  203. package/dist/route/auth-options.js +14 -0
  204. package/dist/route/auth.d.ts +51 -0
  205. package/dist/route/auth.js +87 -0
  206. package/dist/route/client.d.ts +430 -0
  207. package/dist/route/client.js +304 -0
  208. package/dist/route/endpoint.d.ts +28 -0
  209. package/dist/route/endpoint.js +21 -0
  210. package/dist/route/executor.d.ts +27 -0
  211. package/dist/route/executor.js +183 -0
  212. package/dist/route/framing.d.ts +29 -0
  213. package/dist/route/framing.js +14 -0
  214. package/dist/route/index.d.ts +16 -0
  215. package/dist/route/index.js +9 -0
  216. package/dist/route/protocol.d.ts +76 -0
  217. package/dist/route/protocol.js +16 -0
  218. package/dist/route/transport/http.d.ts +34 -0
  219. package/dist/route/transport/http.js +68 -0
  220. package/dist/route/transport/index.d.ts +41 -0
  221. package/dist/route/transport/index.js +4 -0
  222. package/dist/route/transport/websocket-channel.d.ts +57 -0
  223. package/dist/route/transport/websocket-channel.js +1 -0
  224. package/dist/route/transport/websocket.d.ts +56 -0
  225. package/dist/route/transport/websocket.js +366 -0
  226. package/dist/route.d.ts +1 -0
  227. package/dist/route.js +1 -0
  228. package/dist/schema/errors.d.ts +158 -0
  229. package/dist/schema/errors.js +120 -0
  230. package/dist/schema/events.d.ts +8123 -0
  231. package/dist/schema/events.js +550 -0
  232. package/dist/schema/ids.d.ts +17 -0
  233. package/dist/schema/ids.js +10 -0
  234. package/dist/schema/index.d.ts +5 -0
  235. package/dist/schema/index.js +5 -0
  236. package/dist/schema/messages.d.ts +646 -0
  237. package/dist/schema/messages.js +301 -0
  238. package/dist/schema/options.d.ts +157 -0
  239. package/dist/schema/options.js +187 -0
  240. package/dist/testing.d.ts +1693 -0
  241. package/dist/testing.js +129 -0
  242. package/dist/tool-history.d.ts +2 -0
  243. package/dist/tool-history.js +84 -0
  244. package/dist/tool-runtime.d.ts +15 -0
  245. package/dist/tool-runtime.js +62 -0
  246. package/dist/tool.d.ts +136 -0
  247. package/dist/tool.js +66 -0
  248. package/dist/utils/record.d.ts +2 -0
  249. package/dist/utils/record.js +2 -0
  250. package/dist/utils/sanitize.d.ts +1 -0
  251. package/dist/utils/sanitize.js +12 -0
  252. package/package.json +48 -0
@@ -0,0 +1,228 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { type ProviderAuthOption } from "../route/auth-options.js";
3
+ import { Route, type RouteDefaultsInput } from "../route/client.js";
4
+ import { type ModelID } from "../schema/index.js";
5
+ import type { OpenAIProviderOptionsInput } from "./openai-options.js";
6
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
+ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
8
+ readonly baseURL?: string;
9
+ readonly providerOptions?: OpenAIProviderOptionsInput;
10
+ };
11
+ export interface Settings extends ProviderPackage.Settings {
12
+ readonly apiKey?: string;
13
+ readonly baseURL?: string;
14
+ readonly providerOptions?: OpenAIProviderOptionsInput;
15
+ }
16
+ export declare const route: Route<{
17
+ readonly model: string;
18
+ readonly messages: readonly ({
19
+ readonly role: "system";
20
+ readonly content: string | readonly ({
21
+ readonly type: "text";
22
+ readonly text: string;
23
+ readonly cache_control?: {
24
+ readonly type: "ephemeral";
25
+ readonly ttl?: string | undefined;
26
+ } | undefined;
27
+ } | {
28
+ readonly type: "image_url";
29
+ readonly image_url: {
30
+ readonly url: string;
31
+ };
32
+ })[];
33
+ } | {
34
+ readonly role: "user";
35
+ readonly content: string | readonly ({
36
+ readonly type: "text";
37
+ readonly text: string;
38
+ readonly cache_control?: {
39
+ readonly type: "ephemeral";
40
+ readonly ttl?: string | undefined;
41
+ } | undefined;
42
+ } | {
43
+ readonly type: "image_url";
44
+ readonly image_url: {
45
+ readonly url: string;
46
+ };
47
+ })[];
48
+ } | {
49
+ readonly [x: string]: unknown;
50
+ readonly content: string | null;
51
+ readonly role: "assistant";
52
+ readonly reasoning?: string | undefined;
53
+ readonly reasoning_content?: string | undefined;
54
+ readonly reasoning_text?: string | undefined;
55
+ readonly cache_control?: {
56
+ readonly type: "ephemeral";
57
+ readonly ttl?: string | undefined;
58
+ } | undefined;
59
+ readonly tool_calls?: readonly {
60
+ readonly id: string;
61
+ readonly type: "function";
62
+ readonly function: {
63
+ readonly name: string;
64
+ readonly arguments: string;
65
+ };
66
+ }[] | undefined;
67
+ readonly reasoning_details?: unknown;
68
+ } | {
69
+ readonly content: string;
70
+ readonly role: "tool";
71
+ readonly tool_call_id: string;
72
+ readonly cache_control?: {
73
+ readonly type: "ephemeral";
74
+ readonly ttl?: string | undefined;
75
+ } | undefined;
76
+ })[];
77
+ readonly stream: true;
78
+ readonly max_completion_tokens?: number | undefined;
79
+ readonly max_tokens?: number | undefined;
80
+ readonly tools?: readonly {
81
+ readonly function: {
82
+ readonly description: string;
83
+ readonly name: string;
84
+ readonly parameters: {
85
+ readonly [x: string]: unknown;
86
+ };
87
+ readonly strict?: boolean | undefined;
88
+ };
89
+ readonly type: "function";
90
+ readonly cache_control?: {
91
+ readonly type: "ephemeral";
92
+ readonly ttl?: string | undefined;
93
+ } | undefined;
94
+ }[] | undefined;
95
+ readonly stop?: readonly string[] | undefined;
96
+ readonly temperature?: number | undefined;
97
+ readonly seed?: number | undefined;
98
+ readonly tool_choice?: "required" | "auto" | "none" | {
99
+ readonly type: "function";
100
+ readonly function: {
101
+ readonly name: string;
102
+ };
103
+ } | undefined;
104
+ readonly top_p?: number | undefined;
105
+ readonly frequency_penalty?: number | undefined;
106
+ readonly presence_penalty?: number | undefined;
107
+ readonly prompt_cache_key?: string | undefined;
108
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
109
+ readonly store?: boolean | undefined;
110
+ readonly stream_options?: {
111
+ readonly include_usage: boolean;
112
+ } | undefined;
113
+ readonly tool_stream?: boolean | undefined;
114
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>;
115
+ export declare const routes: Route<{
116
+ readonly model: string;
117
+ readonly messages: readonly ({
118
+ readonly role: "system";
119
+ readonly content: string | readonly ({
120
+ readonly type: "text";
121
+ readonly text: string;
122
+ readonly cache_control?: {
123
+ readonly type: "ephemeral";
124
+ readonly ttl?: string | undefined;
125
+ } | undefined;
126
+ } | {
127
+ readonly type: "image_url";
128
+ readonly image_url: {
129
+ readonly url: string;
130
+ };
131
+ })[];
132
+ } | {
133
+ readonly role: "user";
134
+ readonly content: string | readonly ({
135
+ readonly type: "text";
136
+ readonly text: string;
137
+ readonly cache_control?: {
138
+ readonly type: "ephemeral";
139
+ readonly ttl?: string | undefined;
140
+ } | undefined;
141
+ } | {
142
+ readonly type: "image_url";
143
+ readonly image_url: {
144
+ readonly url: string;
145
+ };
146
+ })[];
147
+ } | {
148
+ readonly [x: string]: unknown;
149
+ readonly content: string | null;
150
+ readonly role: "assistant";
151
+ readonly reasoning?: string | undefined;
152
+ readonly reasoning_content?: string | undefined;
153
+ readonly reasoning_text?: string | undefined;
154
+ readonly cache_control?: {
155
+ readonly type: "ephemeral";
156
+ readonly ttl?: string | undefined;
157
+ } | undefined;
158
+ readonly tool_calls?: readonly {
159
+ readonly id: string;
160
+ readonly type: "function";
161
+ readonly function: {
162
+ readonly name: string;
163
+ readonly arguments: string;
164
+ };
165
+ }[] | undefined;
166
+ readonly reasoning_details?: unknown;
167
+ } | {
168
+ readonly content: string;
169
+ readonly role: "tool";
170
+ readonly tool_call_id: string;
171
+ readonly cache_control?: {
172
+ readonly type: "ephemeral";
173
+ readonly ttl?: string | undefined;
174
+ } | undefined;
175
+ })[];
176
+ readonly stream: true;
177
+ readonly max_completion_tokens?: number | undefined;
178
+ readonly max_tokens?: number | undefined;
179
+ readonly tools?: readonly {
180
+ readonly function: {
181
+ readonly description: string;
182
+ readonly name: string;
183
+ readonly parameters: {
184
+ readonly [x: string]: unknown;
185
+ };
186
+ readonly strict?: boolean | undefined;
187
+ };
188
+ readonly type: "function";
189
+ readonly cache_control?: {
190
+ readonly type: "ephemeral";
191
+ readonly ttl?: string | undefined;
192
+ } | undefined;
193
+ }[] | undefined;
194
+ readonly stop?: readonly string[] | undefined;
195
+ readonly temperature?: number | undefined;
196
+ readonly seed?: number | undefined;
197
+ readonly tool_choice?: "required" | "auto" | "none" | {
198
+ readonly type: "function";
199
+ readonly function: {
200
+ readonly name: string;
201
+ };
202
+ } | undefined;
203
+ readonly top_p?: number | undefined;
204
+ readonly frequency_penalty?: number | undefined;
205
+ readonly presence_penalty?: number | undefined;
206
+ readonly prompt_cache_key?: string | undefined;
207
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
208
+ readonly store?: boolean | undefined;
209
+ readonly stream_options?: {
210
+ readonly include_usage: boolean;
211
+ } | undefined;
212
+ readonly tool_stream?: boolean | undefined;
213
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined>[];
214
+ export declare const configure: (input?: LanguageModelOptions) => {
215
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
216
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
217
+ configure: (input?: LanguageModelOptions) => /*elided*/ any;
218
+ };
219
+ export declare const provider: {
220
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
221
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
222
+ configure: (input?: LanguageModelOptions) => {
223
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
224
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./openai-options.js").OpenAIOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
225
+ configure: /*elided*/ any;
226
+ };
227
+ };
228
+ export declare const model: ProviderPackage.Definition<Settings, OpenAIProviderOptionsInput>["model"];
@@ -0,0 +1,40 @@
1
+ import { OpenAIChat } from "../protocols/openai-chat.js";
2
+ import { AuthOptions } from "../route/auth-options.js";
3
+ import { Route } from "../route/client.js";
4
+ import { Endpoint } from "../route/endpoint.js";
5
+ import { ProviderID } from "../schema/index.js";
6
+ export const id = ProviderID.make("togetherai");
7
+ const baseURL = "https://api.together.xyz/v1";
8
+ export const route = Route.make({
9
+ id: "togetherai-chat",
10
+ provider: id,
11
+ providerMetadataKey: "togetherai",
12
+ protocol: OpenAIChat.protocol,
13
+ endpoint: Endpoint.path("/chat/completions", { baseURL }),
14
+ framing: OpenAIChat.framing,
15
+ });
16
+ export const routes = [route];
17
+ export const configure = (input = {}) => {
18
+ const { apiKey: _apiKey, auth: _auth, baseURL: endpoint, ...defaults } = input;
19
+ const configured = route.with({
20
+ ...defaults,
21
+ endpoint: { baseURL: endpoint ?? baseURL },
22
+ auth: AuthOptions.bearer(input, ["TOGETHER_API_KEY", "TOGETHER_AI_API_KEY"]),
23
+ });
24
+ return {
25
+ id,
26
+ model: (modelID) => configured.model({
27
+ id: modelID,
28
+ compatibility: { maxTokensField: "max_tokens", supportsStore: false, supportsStrictMode: false },
29
+ }),
30
+ configure,
31
+ };
32
+ };
33
+ export const provider = configure();
34
+ export const model = (modelID, settings) => configure({
35
+ apiKey: settings.apiKey,
36
+ baseURL: settings.baseURL,
37
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
38
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
39
+ providerOptions: settings.providerOptions,
40
+ }).model(modelID);
@@ -0,0 +1,164 @@
1
+ import { type ProviderAuthOption } from "../route/auth-options.js";
2
+ import { Route, type RouteDefaultsInput } from "../route/client.js";
3
+ import { type ModelID } from "../schema/index.js";
4
+ import type { OpenAIOptionsInput } from "./openai-options.js";
5
+ import type { ProviderPackage } from "../provider-package.js";
6
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
7
+ export type XAIProviderOptionsInput = OpenAIOptionsInput & {
8
+ readonly contextManagement?: never;
9
+ };
10
+ export type LanguageModelOptions = Omit<RouteDefaultsInput, "providerOptions"> & ProviderAuthOption<"optional"> & {
11
+ readonly baseURL?: string;
12
+ readonly providerOptions?: XAIProviderOptionsInput;
13
+ };
14
+ export interface Settings extends ProviderPackage.Settings {
15
+ readonly apiKey?: string;
16
+ readonly baseURL?: string;
17
+ readonly providerOptions?: XAIProviderOptionsInput;
18
+ }
19
+ export type { XAIImageOptions } from "../protocols/xai-images.js";
20
+ declare const responsesRoute: Route<unknown, import("../protocols/open-responses-channel.js").Prepared, {
21
+ endpoint: import("../route/client.js").CompactOperation;
22
+ }>;
23
+ export declare const routes: (Route<{
24
+ readonly model: string;
25
+ readonly messages: readonly ({
26
+ readonly role: "system";
27
+ readonly content: string | readonly ({
28
+ readonly type: "text";
29
+ readonly text: string;
30
+ readonly cache_control?: {
31
+ readonly type: "ephemeral";
32
+ readonly ttl?: string | undefined;
33
+ } | undefined;
34
+ } | {
35
+ readonly type: "image_url";
36
+ readonly image_url: {
37
+ readonly url: string;
38
+ };
39
+ })[];
40
+ } | {
41
+ readonly role: "user";
42
+ readonly content: string | readonly ({
43
+ readonly type: "text";
44
+ readonly text: string;
45
+ readonly cache_control?: {
46
+ readonly type: "ephemeral";
47
+ readonly ttl?: string | undefined;
48
+ } | undefined;
49
+ } | {
50
+ readonly type: "image_url";
51
+ readonly image_url: {
52
+ readonly url: string;
53
+ };
54
+ })[];
55
+ } | {
56
+ readonly [x: string]: unknown;
57
+ readonly content: string | null;
58
+ readonly role: "assistant";
59
+ readonly reasoning?: string | undefined;
60
+ readonly reasoning_content?: string | undefined;
61
+ readonly reasoning_text?: string | undefined;
62
+ readonly cache_control?: {
63
+ readonly type: "ephemeral";
64
+ readonly ttl?: string | undefined;
65
+ } | undefined;
66
+ readonly tool_calls?: readonly {
67
+ readonly id: string;
68
+ readonly type: "function";
69
+ readonly function: {
70
+ readonly name: string;
71
+ readonly arguments: string;
72
+ };
73
+ }[] | undefined;
74
+ readonly reasoning_details?: unknown;
75
+ } | {
76
+ readonly content: string;
77
+ readonly role: "tool";
78
+ readonly tool_call_id: string;
79
+ readonly cache_control?: {
80
+ readonly type: "ephemeral";
81
+ readonly ttl?: string | undefined;
82
+ } | undefined;
83
+ })[];
84
+ readonly stream: true;
85
+ readonly max_completion_tokens?: number | undefined;
86
+ readonly max_tokens?: number | undefined;
87
+ readonly tools?: readonly {
88
+ readonly function: {
89
+ readonly description: string;
90
+ readonly name: string;
91
+ readonly parameters: {
92
+ readonly [x: string]: unknown;
93
+ };
94
+ readonly strict?: boolean | undefined;
95
+ };
96
+ readonly type: "function";
97
+ readonly cache_control?: {
98
+ readonly type: "ephemeral";
99
+ readonly ttl?: string | undefined;
100
+ } | undefined;
101
+ }[] | undefined;
102
+ readonly stop?: readonly string[] | undefined;
103
+ readonly temperature?: number | undefined;
104
+ readonly seed?: number | undefined;
105
+ readonly tool_choice?: "required" | "auto" | "none" | {
106
+ readonly type: "function";
107
+ readonly function: {
108
+ readonly name: string;
109
+ };
110
+ } | undefined;
111
+ readonly top_p?: number | undefined;
112
+ readonly frequency_penalty?: number | undefined;
113
+ readonly presence_penalty?: number | undefined;
114
+ readonly prompt_cache_key?: string | undefined;
115
+ readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
116
+ readonly store?: boolean | undefined;
117
+ readonly stream_options?: {
118
+ readonly include_usage: boolean;
119
+ } | undefined;
120
+ readonly tool_stream?: boolean | undefined;
121
+ }, import("../route/transport/http.js").HttpPrepared<string>, import("../route/client.js").CompactionOperations | undefined> | Route<unknown, import("../protocols/open-responses-channel.js").Prepared, {
122
+ endpoint: import("../route/client.js").CompactOperation;
123
+ }>)[];
124
+ export declare const configure: (input?: LanguageModelOptions) => {
125
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
126
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
127
+ endpoint: import("../route/client.js").CompactOperation;
128
+ }>;
129
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
130
+ endpoint: import("../route/client.js").CompactOperation;
131
+ }>;
132
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
133
+ image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
134
+ configure: (input?: LanguageModelOptions) => /*elided*/ any;
135
+ };
136
+ export declare const provider: {
137
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
138
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
139
+ endpoint: import("../route/client.js").CompactOperation;
140
+ }>;
141
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
142
+ endpoint: import("../route/client.js").CompactOperation;
143
+ }>;
144
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
145
+ image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
146
+ configure: (input?: LanguageModelOptions) => {
147
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
148
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
149
+ endpoint: import("../route/client.js").CompactOperation;
150
+ }>;
151
+ responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
152
+ endpoint: import("../route/client.js").CompactOperation;
153
+ }>;
154
+ chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
155
+ image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
156
+ configure: /*elided*/ any;
157
+ };
158
+ };
159
+ export declare const model: ProviderPackage.Definition<Settings, XAIProviderOptionsInput, typeof responsesRoute.compact>["model"];
160
+ export declare const responses: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, {
161
+ endpoint: import("../route/client.js").CompactOperation;
162
+ }>;
163
+ export declare const chat: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<XAIProviderOptionsInput, import("../route/client.js").CompactionOperations | undefined>;
164
+ export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/xai-images.js").XAIImageOptions>;
@@ -0,0 +1,84 @@
1
+ import { AuthOptions } from "../route/auth-options.js";
2
+ import { Route } from "../route/client.js";
3
+ import { Endpoint } from "../route/endpoint.js";
4
+ import { HttpOptions, ProviderID } from "../schema/index.js";
5
+ import { OpenAIChat } from "../protocols/openai-chat.js";
6
+ import { OpenResponsesChannel } from "../protocols/open-responses-channel.js";
7
+ import { XAIResponses } from "../protocols/xai-responses.js";
8
+ import { XAIImages } from "../protocols/xai-images.js";
9
+ export const id = ProviderID.make("xai");
10
+ const baseURL = "https://api.x.ai/v1";
11
+ const RESPONSES_WEBSOCKET_ROTATE_AFTER_MS = 24 * 60 * 1000;
12
+ const responsesRoute = Route.make({
13
+ compact: { endpoint: XAIResponses.compact },
14
+ id: "openai-responses",
15
+ provider: id,
16
+ providerMetadataKey: "xai",
17
+ protocol: XAIResponses.protocol,
18
+ endpoint: Endpoint.path("/responses", { baseURL }),
19
+ transport: OpenResponsesChannel.transport({
20
+ id: "openai-responses",
21
+ name: "xAI Responses",
22
+ rotateAfterMs: RESPONSES_WEBSOCKET_ROTATE_AFTER_MS,
23
+ }),
24
+ defaults: { providerOptions: { store: false, include: ["reasoning.encrypted_content"] } },
25
+ });
26
+ const chatRoute = Route.make({
27
+ id: "openai-compatible-chat",
28
+ provider: id,
29
+ providerMetadataKey: "xai",
30
+ protocol: OpenAIChat.protocol,
31
+ endpoint: Endpoint.path("/chat/completions", { baseURL }),
32
+ framing: OpenAIChat.framing,
33
+ headers: ({ request }) => request.promptCacheKey ? { "x-grok-conv-id": request.promptCacheKey } : {},
34
+ });
35
+ export const routes = [responsesRoute, chatRoute];
36
+ const auth = (options) => AuthOptions.bearer(options, "XAI_API_KEY");
37
+ const configuredResponsesRoute = (input) => {
38
+ const { apiKey: _, auth: _auth, baseURL: endpoint, ...rest } = input;
39
+ return responsesRoute.with({
40
+ ...rest,
41
+ endpoint: { baseURL: endpoint ?? baseURL },
42
+ auth: auth(input),
43
+ });
44
+ };
45
+ const configuredChatRoute = (input) => {
46
+ const { apiKey: _, auth: _auth, baseURL: endpoint, ...rest } = input;
47
+ return chatRoute.with({
48
+ ...rest,
49
+ endpoint: { baseURL: endpoint ?? baseURL },
50
+ auth: auth(input),
51
+ });
52
+ };
53
+ export const configure = (input = {}) => {
54
+ const responsesRoute = configuredResponsesRoute(input);
55
+ const chatRoute = configuredChatRoute(input);
56
+ const responses = (modelID) => responsesRoute.model({ id: modelID });
57
+ const chat = (modelID) => chatRoute.model({ id: modelID });
58
+ const image = (modelID) => XAIImages.model({
59
+ id: modelID,
60
+ auth: auth(input),
61
+ baseURL: input.baseURL ?? baseURL,
62
+ headers: input.headers,
63
+ http: input.http === undefined ? undefined : HttpOptions.make(input.http),
64
+ });
65
+ return {
66
+ id,
67
+ model: responses,
68
+ responses,
69
+ chat,
70
+ image,
71
+ configure,
72
+ };
73
+ };
74
+ export const provider = configure();
75
+ export const model = (modelID, settings) => configure({
76
+ apiKey: settings.apiKey,
77
+ baseURL: settings.baseURL,
78
+ headers: settings.headers,
79
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
80
+ providerOptions: settings.providerOptions,
81
+ }).model(modelID);
82
+ export const responses = provider.responses;
83
+ export const chat = provider.chat;
84
+ export const image = provider.image;
@@ -0,0 +1,24 @@
1
+ import { type ProviderAuthOption } from "../route/auth-options.js";
2
+ import { HttpOptions, type ModelID } from "../schema/index.js";
3
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
4
+ export type Config = ProviderAuthOption<"optional"> & {
5
+ readonly baseURL?: string;
6
+ readonly headers?: Record<string, string>;
7
+ readonly http?: HttpOptions.Input;
8
+ };
9
+ export type { ZAIImageOptions } from "../protocols/zai-images.js";
10
+ export declare const configure: (input?: Config) => {
11
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
12
+ image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
13
+ configure: (input?: Config) => /*elided*/ any;
14
+ };
15
+ export declare const provider: {
16
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
17
+ image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
18
+ configure: (input?: Config) => {
19
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
20
+ image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
21
+ configure: /*elided*/ any;
22
+ };
23
+ };
24
+ export declare const image: (modelID: string | ModelID) => import("../image.js").ImageModel<import("../protocols/zai-images.js").ZAIImageOptions>;
@@ -0,0 +1,21 @@
1
+ import { ZAIImages } from "../protocols/zai-images.js";
2
+ import { AuthOptions } from "../route/auth-options.js";
3
+ import { HttpOptions, ProviderID } from "../schema/index.js";
4
+ export const id = ProviderID.make("zai");
5
+ const auth = (options) => AuthOptions.bearer(options, "ZAI_API_KEY");
6
+ export const configure = (input = {}) => {
7
+ const image = (modelID) => ZAIImages.model({
8
+ id: modelID,
9
+ auth: auth(input),
10
+ baseURL: input.baseURL,
11
+ headers: input.headers,
12
+ http: input.http === undefined ? undefined : HttpOptions.make(input.http),
13
+ });
14
+ return {
15
+ id,
16
+ image,
17
+ configure,
18
+ };
19
+ };
20
+ export const provider = configure();
21
+ export const image = provider.image;
@@ -0,0 +1 @@
1
+ export * from "./providers/index.js";
@@ -0,0 +1 @@
1
+ export * from "./providers/index.js";
@@ -0,0 +1,34 @@
1
+ import type { Config, Redacted } from "effect";
2
+ import { Auth } from "./auth.js";
3
+ export type ApiKeyMode = "optional" | "required";
4
+ export type AuthOverride = {
5
+ readonly auth: Auth.Definition;
6
+ readonly apiKey?: never;
7
+ };
8
+ export type OptionalApiKeyAuth = {
9
+ readonly apiKey?: string | Redacted.Redacted<string> | Config.Config<string | Redacted.Redacted<string>>;
10
+ readonly auth?: never;
11
+ };
12
+ export type RequiredApiKeyAuth = {
13
+ readonly apiKey: string | Redacted.Redacted<string> | Config.Config<string | Redacted.Redacted<string>>;
14
+ readonly auth?: never;
15
+ };
16
+ export type ProviderAuthOption<Mode extends ApiKeyMode> = AuthOverride | (Mode extends "optional" ? OptionalApiKeyAuth : RequiredApiKeyAuth);
17
+ export type LanguageModelOptions<Base, Mode extends ApiKeyMode> = Omit<Base, "apiKey" | "auth"> & ProviderAuthOption<Mode>;
18
+ export type LanguageModelArgs<Base, Mode extends ApiKeyMode> = Mode extends "optional" ? readonly [options?: LanguageModelOptions<Base, Mode>] : readonly [options: LanguageModelOptions<Base, Mode>];
19
+ export type LanguageModelFactory<Base, Mode extends ApiKeyMode, LanguageModel> = (id: string, ...args: LanguageModelArgs<Base, Mode>) => LanguageModel;
20
+ /**
21
+ * Require at least one of the keys in `T`. Use for option shapes where any
22
+ * subset of fields is acceptable but at least one must be present (e.g. Azure
23
+ * accepts `resourceName` or `baseURL`).
24
+ */
25
+ export type AtLeastOne<T> = {
26
+ [K in keyof T]: Required<Pick<T, K>> & Partial<Omit<T, K>>;
27
+ }[keyof T];
28
+ /**
29
+ * Standard bearer-auth resolution for providers: honor an explicit `auth`
30
+ * override, otherwise resolve `apiKey` (option > config var) and apply it as
31
+ * a bearer token.
32
+ */
33
+ export declare const bearer: (options: ProviderAuthOption<"optional">, envVar: string | ReadonlyArray<string>) => Auth.Definition;
34
+ export * as AuthOptions from "./auth-options.js";
@@ -0,0 +1,14 @@
1
+ import { Auth } from "./auth.js";
2
+ /**
3
+ * Standard bearer-auth resolution for providers: honor an explicit `auth`
4
+ * override, otherwise resolve `apiKey` (option > config var) and apply it as
5
+ * a bearer token.
6
+ */
7
+ export const bearer = (options, envVar) => {
8
+ if ("auth" in options && options.auth)
9
+ return options.auth;
10
+ return (Array.isArray(envVar) ? envVar : [envVar])
11
+ .reduce((auth, name) => auth.orElse(Auth.config(name)), Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey"))
12
+ .bearer();
13
+ };
14
+ export * as AuthOptions from "./auth-options.js";