@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,115 @@
1
+ import { Headers } from "effect/unstable/http";
2
+ import { Auth } from "../route/auth.js";
3
+ import {} from "../route/auth-options.js";
4
+ import { ProviderID } from "../schema/index.js";
5
+ import * as OpenAIChat from "../protocols/openai-chat.js";
6
+ import * as OpenAIResponses from "../protocols/openai-responses.js";
7
+ import { ProviderShared } from "../protocols/shared.js";
8
+ import { withOpenAIOptions } from "./openai-options.js";
9
+ export const id = ProviderID.make("azure");
10
+ const routeAuth = Auth.remove("authorization");
11
+ const RESPONSES_WEBSOCKET_ROTATE_AFTER_MS = 55 * 60 * 1000;
12
+ const resourceBaseURL = (resourceName) => `https://${resourceName.trim()}.openai.azure.com/openai`;
13
+ const responsesRoute = OpenAIResponses.route.with({
14
+ compact: { endpoint: OpenAIResponses.route.compact.endpoint },
15
+ id: "azure-openai-responses",
16
+ provider: id,
17
+ auth: routeAuth,
18
+ transport: OpenAIResponses.channelTransport({
19
+ id: "azure-openai-responses",
20
+ name: "Azure OpenAI Responses",
21
+ rotateAfterMs: RESPONSES_WEBSOCKET_ROTATE_AFTER_MS,
22
+ enabled: (value) => {
23
+ const url = new URL(value);
24
+ return (url.protocol === "https:" &&
25
+ url.hostname.endsWith(".openai.azure.com") &&
26
+ url.pathname.endsWith("/openai/v1/responses") &&
27
+ url.searchParams.get("api-version") === "v1");
28
+ },
29
+ url: (value) => {
30
+ const url = new URL(value);
31
+ url.searchParams.delete("api-version");
32
+ return url.toString();
33
+ },
34
+ headers: (headers) => {
35
+ const apiKey = headers["api-key"];
36
+ if (!apiKey)
37
+ return headers;
38
+ return Headers.remove(Headers.set(headers, "authorization", `Bearer ${apiKey}`), "api-key");
39
+ },
40
+ }),
41
+ });
42
+ const chatRoute = OpenAIChat.route.with({
43
+ id: "azure-openai-chat",
44
+ provider: id,
45
+ auth: routeAuth,
46
+ });
47
+ export const routes = [responsesRoute, chatRoute];
48
+ const defaults = (input) => {
49
+ const { apiKey: _, apiVersion: _apiVersion, resourceName: _resourceName, useDeploymentBasedUrls: _useDeploymentBasedUrls, baseURL: _baseURL, queryParams: _queryParams, ...rest } = input;
50
+ if ("auth" in rest) {
51
+ const { auth: _, ...withoutAuth } = rest;
52
+ return withoutAuth;
53
+ }
54
+ return rest;
55
+ };
56
+ const auth = (input) => {
57
+ if ("auth" in input && input.auth)
58
+ return input.auth;
59
+ return Auth.remove("authorization").andThen(Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey")
60
+ .orElse(Auth.config("AZURE_OPENAI_API_KEY"))
61
+ .pipe(Auth.header("api-key")));
62
+ };
63
+ const configuredRoute = (route, input, modelID) => route.with({
64
+ auth: auth(input),
65
+ endpoint: endpoint(input, modelID),
66
+ });
67
+ function endpoint(input, modelID) {
68
+ const baseURL = ProviderShared.trimBaseUrl(input.baseURL ?? resourceBaseURL(input.resourceName));
69
+ const query = { "api-version": input.apiVersion ?? "v1", ...input.queryParams };
70
+ if (input.useDeploymentBasedUrls)
71
+ return { baseURL: `${baseURL}/deployments/${modelID}`, query };
72
+ if (input.baseURL !== undefined && !new URL(input.baseURL).hostname.endsWith(".openai.azure.com")) {
73
+ return { baseURL, query: input.queryParams };
74
+ }
75
+ return { baseURL: `${baseURL}/v1`, query };
76
+ }
77
+ export const configure = (input) => {
78
+ const modelDefaults = defaults(input);
79
+ const responses = (modelID) => configuredRoute(responsesRoute, input, modelID)
80
+ .with(withOpenAIOptions(modelID, modelDefaults))
81
+ .model({ id: modelID });
82
+ const chat = (modelID) => configuredRoute(chatRoute, input, modelID)
83
+ .with(withOpenAIOptions(modelID, modelDefaults))
84
+ .model({ id: modelID });
85
+ return {
86
+ id,
87
+ model: responses,
88
+ responses,
89
+ chat,
90
+ configure,
91
+ };
92
+ };
93
+ export const provider = {
94
+ id,
95
+ configure,
96
+ };
97
+ const config = (settings) => {
98
+ const common = {
99
+ apiKey: settings.apiKey,
100
+ apiVersion: settings.apiVersion,
101
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
102
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
103
+ providerOptions: settings.providerOptions,
104
+ queryParams: settings.queryParams === undefined ? undefined : { ...settings.queryParams },
105
+ useDeploymentBasedUrls: settings.useDeploymentBasedUrls,
106
+ };
107
+ if (settings.baseURL !== undefined)
108
+ return { ...common, baseURL: settings.baseURL };
109
+ if (settings.resourceName !== undefined)
110
+ return { ...common, resourceName: settings.resourceName };
111
+ throw new Error("Azure requires resourceName or baseURL");
112
+ };
113
+ export const responsesModel = (modelID, settings) => configure(config(settings)).responses(modelID);
114
+ export const chatModel = (modelID, settings) => configure(config(settings)).chat(modelID);
115
+ export const model = responsesModel;
@@ -0,0 +1,229 @@
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"];
229
+ export * as Baseten from "./baseten.js";
@@ -0,0 +1,38 @@
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("baseten");
7
+ const baseURL = "https://inference.baseten.co/v1";
8
+ export const route = Route.make({
9
+ id: "baseten-chat",
10
+ provider: id,
11
+ providerMetadataKey: "baseten",
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, "BASETEN_API_KEY"),
23
+ });
24
+ return {
25
+ id,
26
+ model: (modelID) => configured.model({ id: modelID }),
27
+ configure,
28
+ };
29
+ };
30
+ export const provider = configure();
31
+ export const model = (modelID, settings) => configure({
32
+ apiKey: settings.apiKey,
33
+ baseURL: settings.baseURL,
34
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
35
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
36
+ providerOptions: settings.providerOptions,
37
+ }).model(modelID);
38
+ export * as Baseten from "./baseten.js";
@@ -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("cerebras");
7
+ const baseURL = "https://api.cerebras.ai/v1";
8
+ export const route = Route.make({
9
+ id: "cerebras-chat",
10
+ provider: id,
11
+ providerMetadataKey: "cerebras",
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, "CEREBRAS_API_KEY"),
23
+ });
24
+ return {
25
+ id,
26
+ model: (modelID) => configured.model({
27
+ id: modelID,
28
+ compatibility: { maxTokensField: "max_tokens", reasoningField: "reasoning", supportsStore: 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);