@opencode-ai/ai 0.0.0-beta-17492

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 (194) hide show
  1. package/README.md +392 -0
  2. package/dist/cache-policy.d.ts +2 -0
  3. package/dist/cache-policy.js +121 -0
  4. package/dist/image-client.d.ts +19 -0
  5. package/dist/image-client.js +19 -0
  6. package/dist/image.d.ts +110 -0
  7. package/dist/image.js +102 -0
  8. package/dist/index.d.ts +18 -0
  9. package/dist/index.js +12 -0
  10. package/dist/llm.d.ts +230 -0
  11. package/dist/llm.js +77 -0
  12. package/dist/protocols/anthropic-messages.d.ts +633 -0
  13. package/dist/protocols/anthropic-messages.js +860 -0
  14. package/dist/protocols/bedrock-converse.d.ts +533 -0
  15. package/dist/protocols/bedrock-converse.js +584 -0
  16. package/dist/protocols/bedrock-event-stream.d.ts +9 -0
  17. package/dist/protocols/bedrock-event-stream.js +73 -0
  18. package/dist/protocols/gemini.d.ts +300 -0
  19. package/dist/protocols/gemini.js +512 -0
  20. package/dist/protocols/google-images.d.ts +30 -0
  21. package/dist/protocols/google-images.js +191 -0
  22. package/dist/protocols/index.d.ts +10 -0
  23. package/dist/protocols/index.js +10 -0
  24. package/dist/protocols/open-responses-channel.d.ts +26 -0
  25. package/dist/protocols/open-responses-channel.js +120 -0
  26. package/dist/protocols/open-responses.d.ts +951 -0
  27. package/dist/protocols/open-responses.js +873 -0
  28. package/dist/protocols/openai-chat.d.ts +795 -0
  29. package/dist/protocols/openai-chat.js +718 -0
  30. package/dist/protocols/openai-compatible-chat.d.ts +107 -0
  31. package/dist/protocols/openai-compatible-chat.js +20 -0
  32. package/dist/protocols/openai-compatible-responses.d.ts +96 -0
  33. package/dist/protocols/openai-compatible-responses.js +17 -0
  34. package/dist/protocols/openai-images.d.ts +32 -0
  35. package/dist/protocols/openai-images.js +188 -0
  36. package/dist/protocols/openai-responses-channel.d.ts +12 -0
  37. package/dist/protocols/openai-responses-channel.js +142 -0
  38. package/dist/protocols/openai-responses.d.ts +596 -0
  39. package/dist/protocols/openai-responses.js +208 -0
  40. package/dist/protocols/shared.d.ts +194 -0
  41. package/dist/protocols/shared.js +238 -0
  42. package/dist/protocols/utils/bedrock-auth.d.ts +21 -0
  43. package/dist/protocols/utils/bedrock-auth.js +43 -0
  44. package/dist/protocols/utils/bedrock-cache.d.ts +15 -0
  45. package/dist/protocols/utils/bedrock-cache.js +29 -0
  46. package/dist/protocols/utils/bedrock-media.d.ts +49 -0
  47. package/dist/protocols/utils/bedrock-media.js +70 -0
  48. package/dist/protocols/utils/cache.d.ts +6 -0
  49. package/dist/protocols/utils/cache.js +8 -0
  50. package/dist/protocols/utils/gemini-tool-schema.d.ts +2 -0
  51. package/dist/protocols/utils/gemini-tool-schema.js +103 -0
  52. package/dist/protocols/utils/image-input.d.ts +21 -0
  53. package/dist/protocols/utils/image-input.js +22 -0
  54. package/dist/protocols/utils/lifecycle.d.ts +20 -0
  55. package/dist/protocols/utils/lifecycle.js +68 -0
  56. package/dist/protocols/utils/open-responses-options.d.ts +21 -0
  57. package/dist/protocols/utils/open-responses-options.js +41 -0
  58. package/dist/protocols/utils/openai-image.d.ts +5 -0
  59. package/dist/protocols/utils/openai-image.js +18 -0
  60. package/dist/protocols/utils/openai-options.d.ts +14 -0
  61. package/dist/protocols/utils/openai-options.js +14 -0
  62. package/dist/protocols/utils/tool-schema.d.ts +8 -0
  63. package/dist/protocols/utils/tool-schema.js +81 -0
  64. package/dist/protocols/utils/tool-stream.d.ts +639 -0
  65. package/dist/protocols/utils/tool-stream.js +141 -0
  66. package/dist/protocols/xai-images.d.ts +26 -0
  67. package/dist/protocols/xai-images.js +111 -0
  68. package/dist/protocols/zai-images.d.ts +22 -0
  69. package/dist/protocols/zai-images.js +84 -0
  70. package/dist/protocols.d.ts +1 -0
  71. package/dist/protocols.js +1 -0
  72. package/dist/provider-error.d.ts +14 -0
  73. package/dist/provider-error.js +130 -0
  74. package/dist/provider-package.d.ts +15 -0
  75. package/dist/provider-package.js +1 -0
  76. package/dist/provider.d.ts +23 -0
  77. package/dist/provider.js +2 -0
  78. package/dist/providers/amazon-bedrock/mantle/chat.d.ts +2 -0
  79. package/dist/providers/amazon-bedrock/mantle/chat.js +1 -0
  80. package/dist/providers/amazon-bedrock/mantle/responses.d.ts +2 -0
  81. package/dist/providers/amazon-bedrock/mantle/responses.js +1 -0
  82. package/dist/providers/amazon-bedrock/mantle.d.ts +2 -0
  83. package/dist/providers/amazon-bedrock/mantle.js +1 -0
  84. package/dist/providers/amazon-bedrock-mantle.d.ts +247 -0
  85. package/dist/providers/amazon-bedrock-mantle.js +68 -0
  86. package/dist/providers/amazon-bedrock.d.ts +172 -0
  87. package/dist/providers/amazon-bedrock.js +41 -0
  88. package/dist/providers/anthropic-compatible.d.ts +218 -0
  89. package/dist/providers/anthropic-compatible.js +45 -0
  90. package/dist/providers/anthropic.d.ts +216 -0
  91. package/dist/providers/anthropic.js +40 -0
  92. package/dist/providers/azure/chat.d.ts +2 -0
  93. package/dist/providers/azure/chat.js +1 -0
  94. package/dist/providers/azure/responses.d.ts +2 -0
  95. package/dist/providers/azure/responses.js +1 -0
  96. package/dist/providers/azure.d.ts +248 -0
  97. package/dist/providers/azure.js +90 -0
  98. package/dist/providers/cloudflare.d.ts +338 -0
  99. package/dist/providers/cloudflare.js +87 -0
  100. package/dist/providers/google-vertex/chat.d.ts +2 -0
  101. package/dist/providers/google-vertex/chat.js +1 -0
  102. package/dist/providers/google-vertex/gemini.d.ts +2 -0
  103. package/dist/providers/google-vertex/gemini.js +1 -0
  104. package/dist/providers/google-vertex/messages.d.ts +2 -0
  105. package/dist/providers/google-vertex/messages.js +1 -0
  106. package/dist/providers/google-vertex/responses.d.ts +2 -0
  107. package/dist/providers/google-vertex/responses.js +1 -0
  108. package/dist/providers/google-vertex-chat.d.ts +131 -0
  109. package/dist/providers/google-vertex-chat.js +50 -0
  110. package/dist/providers/google-vertex-messages.d.ts +215 -0
  111. package/dist/providers/google-vertex-messages.js +75 -0
  112. package/dist/providers/google-vertex-responses.d.ts +122 -0
  113. package/dist/providers/google-vertex-responses.js +51 -0
  114. package/dist/providers/google-vertex-shared.d.ts +22 -0
  115. package/dist/providers/google-vertex-shared.js +61 -0
  116. package/dist/providers/google-vertex.d.ts +115 -0
  117. package/dist/providers/google-vertex.js +64 -0
  118. package/dist/providers/google.d.ts +112 -0
  119. package/dist/providers/google.js +43 -0
  120. package/dist/providers/index.d.ts +18 -0
  121. package/dist/providers/index.js +18 -0
  122. package/dist/providers/open-responses-options.d.ts +16 -0
  123. package/dist/providers/open-responses-options.js +1 -0
  124. package/dist/providers/openai/chat.d.ts +2 -0
  125. package/dist/providers/openai/chat.js +1 -0
  126. package/dist/providers/openai/responses.d.ts +2 -0
  127. package/dist/providers/openai/responses.js +1 -0
  128. package/dist/providers/openai-compatible/responses.d.ts +1 -0
  129. package/dist/providers/openai-compatible/responses.js +1 -0
  130. package/dist/providers/openai-compatible-profile.d.ts +43 -0
  131. package/dist/providers/openai-compatible-profile.js +12 -0
  132. package/dist/providers/openai-compatible-responses.d.ts +120 -0
  133. package/dist/providers/openai-compatible-responses.js +33 -0
  134. package/dist/providers/openai-compatible.d.ts +167 -0
  135. package/dist/providers/openai-compatible.js +55 -0
  136. package/dist/providers/openai-options.d.ts +21 -0
  137. package/dist/providers/openai-options.js +41 -0
  138. package/dist/providers/openai.d.ts +264 -0
  139. package/dist/providers/openai.js +83 -0
  140. package/dist/providers/openrouter.d.ts +537 -0
  141. package/dist/providers/openrouter.js +117 -0
  142. package/dist/providers/xai.d.ts +249 -0
  143. package/dist/providers/xai.js +79 -0
  144. package/dist/providers/zai.d.ts +24 -0
  145. package/dist/providers/zai.js +21 -0
  146. package/dist/providers.d.ts +1 -0
  147. package/dist/providers.js +1 -0
  148. package/dist/route/auth-options.d.ts +34 -0
  149. package/dist/route/auth-options.js +14 -0
  150. package/dist/route/auth.d.ts +51 -0
  151. package/dist/route/auth.js +89 -0
  152. package/dist/route/client.d.ts +348 -0
  153. package/dist/route/client.js +214 -0
  154. package/dist/route/endpoint.d.ts +28 -0
  155. package/dist/route/endpoint.js +21 -0
  156. package/dist/route/executor.d.ts +23 -0
  157. package/dist/route/executor.js +227 -0
  158. package/dist/route/framing.d.ts +23 -0
  159. package/dist/route/framing.js +4 -0
  160. package/dist/route/index.d.ts +16 -0
  161. package/dist/route/index.js +9 -0
  162. package/dist/route/protocol.d.ts +77 -0
  163. package/dist/route/protocol.js +17 -0
  164. package/dist/route/transport/http.d.ts +34 -0
  165. package/dist/route/transport/http.js +63 -0
  166. package/dist/route/transport/index.d.ts +39 -0
  167. package/dist/route/transport/index.js +4 -0
  168. package/dist/route/transport/websocket-channel.d.ts +56 -0
  169. package/dist/route/transport/websocket-channel.js +1 -0
  170. package/dist/route/transport/websocket.d.ts +55 -0
  171. package/dist/route/transport/websocket.js +326 -0
  172. package/dist/route.d.ts +1 -0
  173. package/dist/route.js +1 -0
  174. package/dist/schema/errors.d.ts +159 -0
  175. package/dist/schema/errors.js +155 -0
  176. package/dist/schema/events.d.ts +4587 -0
  177. package/dist/schema/events.js +492 -0
  178. package/dist/schema/ids.d.ts +30 -0
  179. package/dist/schema/ids.js +19 -0
  180. package/dist/schema/index.d.ts +5 -0
  181. package/dist/schema/index.js +5 -0
  182. package/dist/schema/messages.d.ts +402 -0
  183. package/dist/schema/messages.js +244 -0
  184. package/dist/schema/options.d.ts +159 -0
  185. package/dist/schema/options.js +202 -0
  186. package/dist/testing.d.ts +1493 -0
  187. package/dist/testing.js +88 -0
  188. package/dist/tool-runtime.d.ts +15 -0
  189. package/dist/tool-runtime.js +54 -0
  190. package/dist/tool.d.ts +135 -0
  191. package/dist/tool.js +66 -0
  192. package/dist/utils/record.d.ts +2 -0
  193. package/dist/utils/record.js +2 -0
  194. package/package.json +47 -0
@@ -0,0 +1,218 @@
1
+ import type { ProviderPackage } from "../provider-package.js";
2
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
3
+ import type { ProviderAuthOption } from "../route/auth-options.js";
4
+ import type { RouteDefaultsInput } from "../route/client.js";
5
+ import { type ModelID } from "../schema/index.js";
6
+ export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
7
+ export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
8
+ export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
9
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
10
+ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
11
+ readonly provider?: string;
12
+ readonly baseURL: string;
13
+ readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
14
+ };
15
+ export type Settings = ProviderPackage.Settings & ({
16
+ readonly apiKey?: string;
17
+ readonly authToken?: never;
18
+ } | {
19
+ readonly apiKey?: never;
20
+ readonly authToken?: string;
21
+ }) & {
22
+ readonly baseURL: string;
23
+ readonly provider?: string;
24
+ readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
25
+ };
26
+ export declare const routes: import("../route/client.js").Route<{
27
+ readonly max_tokens: number;
28
+ readonly model: string;
29
+ readonly messages: readonly ({
30
+ readonly role: "user";
31
+ readonly content: readonly ({
32
+ readonly type: "text";
33
+ readonly text: string;
34
+ readonly cache_control?: {
35
+ readonly type: "ephemeral";
36
+ readonly ttl?: "1h" | "5m" | undefined;
37
+ } | undefined;
38
+ } | {
39
+ readonly type: "image";
40
+ readonly source: {
41
+ readonly type: "base64";
42
+ readonly media_type: string;
43
+ readonly data: string;
44
+ };
45
+ readonly cache_control?: {
46
+ readonly type: "ephemeral";
47
+ readonly ttl?: "1h" | "5m" | undefined;
48
+ } | undefined;
49
+ } | {
50
+ readonly type: "document";
51
+ readonly source: {
52
+ readonly type: "base64";
53
+ readonly media_type: "application/pdf";
54
+ readonly data: string;
55
+ };
56
+ readonly cache_control?: {
57
+ readonly type: "ephemeral";
58
+ readonly ttl?: "1h" | "5m" | undefined;
59
+ } | undefined;
60
+ } | {
61
+ readonly type: "tool_result";
62
+ readonly content: string | readonly ({
63
+ readonly type: "text";
64
+ readonly text: string;
65
+ readonly cache_control?: {
66
+ readonly type: "ephemeral";
67
+ readonly ttl?: "1h" | "5m" | undefined;
68
+ } | undefined;
69
+ } | {
70
+ readonly type: "image";
71
+ readonly source: {
72
+ readonly type: "base64";
73
+ readonly media_type: string;
74
+ readonly data: string;
75
+ };
76
+ readonly cache_control?: {
77
+ readonly type: "ephemeral";
78
+ readonly ttl?: "1h" | "5m" | undefined;
79
+ } | undefined;
80
+ } | {
81
+ readonly type: "document";
82
+ readonly source: {
83
+ readonly type: "base64";
84
+ readonly media_type: "application/pdf";
85
+ readonly data: string;
86
+ };
87
+ readonly cache_control?: {
88
+ readonly type: "ephemeral";
89
+ readonly ttl?: "1h" | "5m" | undefined;
90
+ } | undefined;
91
+ })[];
92
+ readonly tool_use_id: string;
93
+ readonly cache_control?: {
94
+ readonly type: "ephemeral";
95
+ readonly ttl?: "1h" | "5m" | undefined;
96
+ } | undefined;
97
+ readonly is_error?: boolean | undefined;
98
+ })[];
99
+ } | {
100
+ readonly role: "assistant";
101
+ readonly content: readonly ({
102
+ readonly type: "text";
103
+ readonly text: string;
104
+ readonly cache_control?: {
105
+ readonly type: "ephemeral";
106
+ readonly ttl?: "1h" | "5m" | undefined;
107
+ } | undefined;
108
+ } | {
109
+ readonly id: string;
110
+ readonly type: "tool_use";
111
+ readonly name: string;
112
+ readonly input: unknown;
113
+ readonly cache_control?: {
114
+ readonly type: "ephemeral";
115
+ readonly ttl?: "1h" | "5m" | undefined;
116
+ } | undefined;
117
+ } | {
118
+ readonly id: string;
119
+ readonly type: "server_tool_use";
120
+ readonly name: string;
121
+ readonly input: unknown;
122
+ readonly cache_control?: {
123
+ readonly type: "ephemeral";
124
+ readonly ttl?: "1h" | "5m" | undefined;
125
+ } | undefined;
126
+ } | {
127
+ readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
128
+ readonly content: unknown;
129
+ readonly tool_use_id: string;
130
+ readonly cache_control?: {
131
+ readonly type: "ephemeral";
132
+ readonly ttl?: "1h" | "5m" | undefined;
133
+ } | undefined;
134
+ } | {
135
+ readonly type: "thinking";
136
+ readonly thinking: string;
137
+ readonly cache_control?: {
138
+ readonly type: "ephemeral";
139
+ readonly ttl?: "1h" | "5m" | undefined;
140
+ } | undefined;
141
+ readonly signature?: string | undefined;
142
+ } | {
143
+ readonly data: string;
144
+ readonly type: "redacted_thinking";
145
+ readonly cache_control?: {
146
+ readonly type: "ephemeral";
147
+ readonly ttl?: "1h" | "5m" | undefined;
148
+ } | undefined;
149
+ })[];
150
+ } | {
151
+ readonly role: "system";
152
+ readonly content: readonly {
153
+ readonly type: "text";
154
+ readonly text: string;
155
+ readonly cache_control?: {
156
+ readonly type: "ephemeral";
157
+ readonly ttl?: "1h" | "5m" | undefined;
158
+ } | undefined;
159
+ }[];
160
+ })[];
161
+ readonly stream: true;
162
+ readonly system?: readonly {
163
+ readonly type: "text";
164
+ readonly text: string;
165
+ readonly cache_control?: {
166
+ readonly type: "ephemeral";
167
+ readonly ttl?: "1h" | "5m" | undefined;
168
+ } | undefined;
169
+ }[] | undefined;
170
+ readonly tools?: readonly {
171
+ readonly description: string;
172
+ readonly name: string;
173
+ readonly input_schema: {
174
+ readonly [x: string]: unknown;
175
+ };
176
+ readonly cache_control?: {
177
+ readonly type: "ephemeral";
178
+ readonly ttl?: "1h" | "5m" | undefined;
179
+ } | undefined;
180
+ }[] | undefined;
181
+ readonly temperature?: number | undefined;
182
+ readonly thinking?: {
183
+ readonly type: "enabled";
184
+ readonly budget_tokens: number;
185
+ } | {
186
+ readonly type: "adaptive";
187
+ readonly display?: "summarized" | "omitted" | undefined;
188
+ } | {
189
+ readonly type: "disabled";
190
+ } | undefined;
191
+ readonly tool_choice?: {
192
+ readonly type: "none" | "auto" | "any";
193
+ } | {
194
+ readonly type: "tool";
195
+ readonly name: string;
196
+ } | undefined;
197
+ readonly top_p?: number | undefined;
198
+ readonly top_k?: number | undefined;
199
+ readonly stop_sequences?: readonly string[] | undefined;
200
+ readonly output_config?: {
201
+ readonly effort?: string | undefined;
202
+ } | undefined;
203
+ }, import("../route/transport/http.js").HttpPrepared<string>>[];
204
+ export declare const configure: (input: Config) => {
205
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
206
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.ProviderOptionsInput>;
207
+ configure: (input: Config) => /*elided*/ any;
208
+ };
209
+ export declare const provider: {
210
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
211
+ configure: (input: Config) => {
212
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
213
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.ProviderOptionsInput>;
214
+ configure: /*elided*/ any;
215
+ };
216
+ };
217
+ export declare const model: ProviderPackage.Definition<Settings, AnthropicMessages.ProviderOptionsInput>["model"];
218
+ export * as AnthropicCompatible from "./anthropic-compatible.js";
@@ -0,0 +1,45 @@
1
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
2
+ import { Auth } from "../route/auth.js";
3
+ import { ProviderID } from "../schema/index.js";
4
+ export const id = ProviderID.make("anthropic-compatible");
5
+ export const routes = [AnthropicMessages.route];
6
+ const auth = (input) => {
7
+ if ("auth" in input && input.auth)
8
+ return input.auth;
9
+ return Auth.optional("apiKey" in input ? input.apiKey : undefined, "apiKey").pipe(Auth.header("x-api-key"));
10
+ };
11
+ export const configure = (input) => {
12
+ if (!input.baseURL)
13
+ throw new Error("Anthropic-compatible providers require a baseURL");
14
+ const provider = input.provider ?? "anthropic-compatible";
15
+ const { provider: _, baseURL, apiKey: _apiKey, auth: _auth, ...rest } = input;
16
+ const route = AnthropicMessages.route.with({
17
+ ...rest,
18
+ provider,
19
+ endpoint: { baseURL },
20
+ auth: auth(input),
21
+ });
22
+ return {
23
+ id: ProviderID.make(provider),
24
+ model: (modelID) => route.model({ id: modelID }),
25
+ configure,
26
+ };
27
+ };
28
+ export const provider = {
29
+ id,
30
+ configure,
31
+ };
32
+ export const model = (modelID, settings) => {
33
+ if (settings.apiKey !== undefined && settings.authToken !== undefined)
34
+ throw new Error("Anthropic-compatible apiKey cannot be combined with authToken");
35
+ return configure({
36
+ ...(settings.authToken === undefined ? { apiKey: settings.apiKey } : { auth: Auth.bearer(settings.authToken) }),
37
+ baseURL: settings.baseURL,
38
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
39
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
40
+ limits: settings.limits,
41
+ provider: settings.provider,
42
+ providerOptions: settings.providerOptions,
43
+ }).model(modelID);
44
+ };
45
+ export * as AnthropicCompatible from "./anthropic-compatible.js";
@@ -0,0 +1,216 @@
1
+ import type { RouteDefaultsInput } from "../route/client.js";
2
+ import type { ProviderAuthOption } from "../route/auth-options.js";
3
+ import type { ProviderPackage } from "../provider-package.js";
4
+ import { type ModelID } from "../schema/index.js";
5
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
6
+ export type AnthropicOptionsInput = AnthropicMessages.OptionsInput;
7
+ export type AnthropicProviderOptionsInput = AnthropicMessages.ProviderOptionsInput;
8
+ export type AnthropicThinkingInput = AnthropicMessages.ThinkingInput;
9
+ export declare const id: string & import("effect/Brand").Brand<"AI.ProviderID">;
10
+ export declare const routes: import("../route/client.js").Route<{
11
+ readonly max_tokens: number;
12
+ readonly model: string;
13
+ readonly messages: readonly ({
14
+ readonly role: "user";
15
+ readonly content: readonly ({
16
+ readonly type: "text";
17
+ readonly text: string;
18
+ readonly cache_control?: {
19
+ readonly type: "ephemeral";
20
+ readonly ttl?: "1h" | "5m" | undefined;
21
+ } | undefined;
22
+ } | {
23
+ readonly type: "image";
24
+ readonly source: {
25
+ readonly type: "base64";
26
+ readonly media_type: string;
27
+ readonly data: string;
28
+ };
29
+ readonly cache_control?: {
30
+ readonly type: "ephemeral";
31
+ readonly ttl?: "1h" | "5m" | undefined;
32
+ } | undefined;
33
+ } | {
34
+ readonly type: "document";
35
+ readonly source: {
36
+ readonly type: "base64";
37
+ readonly media_type: "application/pdf";
38
+ readonly data: string;
39
+ };
40
+ readonly cache_control?: {
41
+ readonly type: "ephemeral";
42
+ readonly ttl?: "1h" | "5m" | undefined;
43
+ } | undefined;
44
+ } | {
45
+ readonly type: "tool_result";
46
+ readonly content: string | readonly ({
47
+ readonly type: "text";
48
+ readonly text: string;
49
+ readonly cache_control?: {
50
+ readonly type: "ephemeral";
51
+ readonly ttl?: "1h" | "5m" | undefined;
52
+ } | undefined;
53
+ } | {
54
+ readonly type: "image";
55
+ readonly source: {
56
+ readonly type: "base64";
57
+ readonly media_type: string;
58
+ readonly data: string;
59
+ };
60
+ readonly cache_control?: {
61
+ readonly type: "ephemeral";
62
+ readonly ttl?: "1h" | "5m" | undefined;
63
+ } | undefined;
64
+ } | {
65
+ readonly type: "document";
66
+ readonly source: {
67
+ readonly type: "base64";
68
+ readonly media_type: "application/pdf";
69
+ readonly data: string;
70
+ };
71
+ readonly cache_control?: {
72
+ readonly type: "ephemeral";
73
+ readonly ttl?: "1h" | "5m" | undefined;
74
+ } | undefined;
75
+ })[];
76
+ readonly tool_use_id: string;
77
+ readonly cache_control?: {
78
+ readonly type: "ephemeral";
79
+ readonly ttl?: "1h" | "5m" | undefined;
80
+ } | undefined;
81
+ readonly is_error?: boolean | undefined;
82
+ })[];
83
+ } | {
84
+ readonly role: "assistant";
85
+ readonly content: readonly ({
86
+ readonly type: "text";
87
+ readonly text: string;
88
+ readonly cache_control?: {
89
+ readonly type: "ephemeral";
90
+ readonly ttl?: "1h" | "5m" | undefined;
91
+ } | undefined;
92
+ } | {
93
+ readonly id: string;
94
+ readonly type: "tool_use";
95
+ readonly name: string;
96
+ readonly input: unknown;
97
+ readonly cache_control?: {
98
+ readonly type: "ephemeral";
99
+ readonly ttl?: "1h" | "5m" | undefined;
100
+ } | undefined;
101
+ } | {
102
+ readonly id: string;
103
+ readonly type: "server_tool_use";
104
+ readonly name: string;
105
+ readonly input: unknown;
106
+ readonly cache_control?: {
107
+ readonly type: "ephemeral";
108
+ readonly ttl?: "1h" | "5m" | undefined;
109
+ } | undefined;
110
+ } | {
111
+ readonly type: "web_search_tool_result" | "code_execution_tool_result" | "web_fetch_tool_result";
112
+ readonly content: unknown;
113
+ readonly tool_use_id: string;
114
+ readonly cache_control?: {
115
+ readonly type: "ephemeral";
116
+ readonly ttl?: "1h" | "5m" | undefined;
117
+ } | undefined;
118
+ } | {
119
+ readonly type: "thinking";
120
+ readonly thinking: string;
121
+ readonly cache_control?: {
122
+ readonly type: "ephemeral";
123
+ readonly ttl?: "1h" | "5m" | undefined;
124
+ } | undefined;
125
+ readonly signature?: string | undefined;
126
+ } | {
127
+ readonly data: string;
128
+ readonly type: "redacted_thinking";
129
+ readonly cache_control?: {
130
+ readonly type: "ephemeral";
131
+ readonly ttl?: "1h" | "5m" | undefined;
132
+ } | undefined;
133
+ })[];
134
+ } | {
135
+ readonly role: "system";
136
+ readonly content: readonly {
137
+ readonly type: "text";
138
+ readonly text: string;
139
+ readonly cache_control?: {
140
+ readonly type: "ephemeral";
141
+ readonly ttl?: "1h" | "5m" | undefined;
142
+ } | undefined;
143
+ }[];
144
+ })[];
145
+ readonly stream: true;
146
+ readonly system?: readonly {
147
+ readonly type: "text";
148
+ readonly text: string;
149
+ readonly cache_control?: {
150
+ readonly type: "ephemeral";
151
+ readonly ttl?: "1h" | "5m" | undefined;
152
+ } | undefined;
153
+ }[] | undefined;
154
+ readonly tools?: readonly {
155
+ readonly description: string;
156
+ readonly name: string;
157
+ readonly input_schema: {
158
+ readonly [x: string]: unknown;
159
+ };
160
+ readonly cache_control?: {
161
+ readonly type: "ephemeral";
162
+ readonly ttl?: "1h" | "5m" | undefined;
163
+ } | undefined;
164
+ }[] | undefined;
165
+ readonly temperature?: number | undefined;
166
+ readonly thinking?: {
167
+ readonly type: "enabled";
168
+ readonly budget_tokens: number;
169
+ } | {
170
+ readonly type: "adaptive";
171
+ readonly display?: "summarized" | "omitted" | undefined;
172
+ } | {
173
+ readonly type: "disabled";
174
+ } | undefined;
175
+ readonly tool_choice?: {
176
+ readonly type: "none" | "auto" | "any";
177
+ } | {
178
+ readonly type: "tool";
179
+ readonly name: string;
180
+ } | undefined;
181
+ readonly top_p?: number | undefined;
182
+ readonly top_k?: number | undefined;
183
+ readonly stop_sequences?: readonly string[] | undefined;
184
+ readonly output_config?: {
185
+ readonly effort?: string | undefined;
186
+ } | undefined;
187
+ }, import("../route/transport/http.js").HttpPrepared<string>>[];
188
+ export type Config = RouteDefaultsInput & ProviderAuthOption<"optional"> & {
189
+ readonly baseURL?: string;
190
+ readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
191
+ };
192
+ export type Settings = ProviderPackage.Settings & ({
193
+ readonly apiKey?: string;
194
+ readonly authToken?: never;
195
+ } | {
196
+ readonly apiKey?: never;
197
+ readonly authToken?: string;
198
+ }) & {
199
+ readonly baseURL?: string;
200
+ readonly providerOptions?: AnthropicMessages.ProviderOptionsInput;
201
+ };
202
+ export declare const configure: (input?: Config) => {
203
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
204
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.ProviderOptionsInput>;
205
+ configure: (input?: Config) => /*elided*/ any;
206
+ };
207
+ export declare const provider: {
208
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
209
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.ProviderOptionsInput>;
210
+ configure: (input?: Config) => {
211
+ id: string & import("effect/Brand").Brand<"AI.ProviderID">;
212
+ model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<AnthropicMessages.ProviderOptionsInput>;
213
+ configure: /*elided*/ any;
214
+ };
215
+ };
216
+ export declare const model: ProviderPackage.Definition<Settings, AnthropicMessages.ProviderOptionsInput>["model"];
@@ -0,0 +1,40 @@
1
+ import { Auth } from "../route/auth.js";
2
+ import { ProviderID } from "../schema/index.js";
3
+ import { AnthropicMessages } from "../protocols/anthropic-messages.js";
4
+ import { AnthropicCompatible } from "./anthropic-compatible.js";
5
+ export const id = ProviderID.make("anthropic");
6
+ export const routes = [AnthropicMessages.route];
7
+ const auth = (options) => {
8
+ if ("auth" in options && options.auth)
9
+ return options.auth;
10
+ return Auth.optional("apiKey" in options ? options.apiKey : undefined, "apiKey")
11
+ .orElse(Auth.config("ANTHROPIC_API_KEY"))
12
+ .pipe(Auth.header("x-api-key"));
13
+ };
14
+ export const configure = (input = {}) => {
15
+ const { apiKey: _, auth: _auth, baseURL, ...rest } = input;
16
+ const compatible = AnthropicCompatible.configure({
17
+ ...rest,
18
+ auth: auth(input),
19
+ baseURL: baseURL ?? AnthropicMessages.DEFAULT_BASE_URL,
20
+ provider: id,
21
+ });
22
+ return {
23
+ id,
24
+ model: (modelID) => compatible.model(modelID),
25
+ configure,
26
+ };
27
+ };
28
+ export const provider = configure();
29
+ export const model = (modelID, settings) => {
30
+ if (settings.apiKey !== undefined && settings.authToken !== undefined)
31
+ throw new Error("Anthropic apiKey cannot be combined with authToken");
32
+ return configure({
33
+ ...(settings.authToken === undefined ? { apiKey: settings.apiKey } : { auth: Auth.bearer(settings.authToken) }),
34
+ baseURL: settings.baseURL,
35
+ headers: settings.headers === undefined ? undefined : { ...settings.headers },
36
+ http: settings.body === undefined ? undefined : { body: { ...settings.body } },
37
+ limits: settings.limits,
38
+ providerOptions: settings.providerOptions,
39
+ }).model(modelID);
40
+ };
@@ -0,0 +1,2 @@
1
+ export { chatModel as model } from "../azure.js";
2
+ export type { Settings } from "../azure.js";
@@ -0,0 +1 @@
1
+ export { chatModel as model } from "../azure.js";
@@ -0,0 +1,2 @@
1
+ export { responsesModel as model } from "../azure.js";
2
+ export type { Settings } from "../azure.js";
@@ -0,0 +1 @@
1
+ export { responsesModel as model } from "../azure.js";