@effect/ai-anthropic 0.0.1

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 (51) hide show
  1. package/AnthropicClient/package.json +6 -0
  2. package/AnthropicCompletions/package.json +6 -0
  3. package/AnthropicConfig/package.json +6 -0
  4. package/AnthropicTokenizer/package.json +6 -0
  5. package/Generated/package.json +6 -0
  6. package/LICENSE +21 -0
  7. package/README.md +5 -0
  8. package/dist/cjs/AnthropicClient.js +213 -0
  9. package/dist/cjs/AnthropicClient.js.map +1 -0
  10. package/dist/cjs/AnthropicCompletions.js +290 -0
  11. package/dist/cjs/AnthropicCompletions.js.map +1 -0
  12. package/dist/cjs/AnthropicConfig.js +31 -0
  13. package/dist/cjs/AnthropicConfig.js.map +1 -0
  14. package/dist/cjs/AnthropicTokenizer.js +50 -0
  15. package/dist/cjs/AnthropicTokenizer.js.map +1 -0
  16. package/dist/cjs/Generated.js +1510 -0
  17. package/dist/cjs/Generated.js.map +1 -0
  18. package/dist/cjs/index.js +19 -0
  19. package/dist/cjs/index.js.map +1 -0
  20. package/dist/dts/AnthropicClient.d.ts +126 -0
  21. package/dist/dts/AnthropicClient.d.ts.map +1 -0
  22. package/dist/dts/AnthropicCompletions.d.ts +25 -0
  23. package/dist/dts/AnthropicCompletions.d.ts.map +1 -0
  24. package/dist/dts/AnthropicConfig.d.ts +39 -0
  25. package/dist/dts/AnthropicConfig.d.ts.map +1 -0
  26. package/dist/dts/AnthropicTokenizer.d.ts +8 -0
  27. package/dist/dts/AnthropicTokenizer.d.ts.map +1 -0
  28. package/dist/dts/Generated.d.ts +3937 -0
  29. package/dist/dts/Generated.d.ts.map +1 -0
  30. package/dist/dts/index.d.ts +21 -0
  31. package/dist/dts/index.d.ts.map +1 -0
  32. package/dist/esm/AnthropicClient.js +199 -0
  33. package/dist/esm/AnthropicClient.js.map +1 -0
  34. package/dist/esm/AnthropicCompletions.js +279 -0
  35. package/dist/esm/AnthropicCompletions.js.map +1 -0
  36. package/dist/esm/AnthropicConfig.js +22 -0
  37. package/dist/esm/AnthropicConfig.js.map +1 -0
  38. package/dist/esm/AnthropicTokenizer.js +41 -0
  39. package/dist/esm/AnthropicTokenizer.js.map +1 -0
  40. package/dist/esm/Generated.js +1273 -0
  41. package/dist/esm/Generated.js.map +1 -0
  42. package/dist/esm/index.js +21 -0
  43. package/dist/esm/index.js.map +1 -0
  44. package/dist/esm/package.json +4 -0
  45. package/package.json +79 -0
  46. package/src/AnthropicClient.ts +415 -0
  47. package/src/AnthropicCompletions.ts +352 -0
  48. package/src/AnthropicConfig.ts +76 -0
  49. package/src/AnthropicTokenizer.ts +52 -0
  50. package/src/Generated.ts +1811 -0
  51. package/src/index.ts +24 -0
@@ -0,0 +1,1811 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import type * as HttpClient from "@effect/platform/HttpClient"
5
+ import * as HttpClientError from "@effect/platform/HttpClientError"
6
+ import * as HttpClientRequest from "@effect/platform/HttpClientRequest"
7
+ import * as HttpClientResponse from "@effect/platform/HttpClientResponse"
8
+ import * as Effect from "effect/Effect"
9
+ import type { ParseError } from "effect/ParseResult"
10
+ import * as S from "effect/Schema"
11
+
12
+ export class MessagesPostParams extends S.Struct({
13
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
14
+ }) {}
15
+
16
+ export class ModelEnum extends S.Literal(
17
+ "claude-3-5-haiku-latest",
18
+ "claude-3-5-haiku-20241022",
19
+ "claude-3-5-sonnet-latest",
20
+ "claude-3-5-sonnet-20241022",
21
+ "claude-3-5-sonnet-20240620",
22
+ "claude-3-opus-latest",
23
+ "claude-3-opus-20240229",
24
+ "claude-3-sonnet-20240229",
25
+ "claude-3-haiku-20240307",
26
+ "claude-2.1",
27
+ "claude-2.0"
28
+ ) {}
29
+
30
+ export class Model extends S.Union(S.String, ModelEnum) {}
31
+
32
+ export class InputMessageRole extends S.Literal("user", "assistant") {}
33
+
34
+ export class CacheControlEphemeralType extends S.Literal("ephemeral") {}
35
+
36
+ export class CacheControlEphemeral extends S.Struct({
37
+ "type": CacheControlEphemeralType
38
+ }) {}
39
+
40
+ export class RequestCharLocationCitationType extends S.Literal("char_location") {}
41
+
42
+ export class RequestCharLocationCitation extends S.Struct({
43
+ "type": RequestCharLocationCitationType,
44
+ "cited_text": S.String,
45
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
46
+ "document_title": S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null),
47
+ "start_char_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
48
+ "end_char_index": S.Int
49
+ }) {}
50
+
51
+ export class RequestPageLocationCitationType extends S.Literal("page_location") {}
52
+
53
+ export class RequestPageLocationCitation extends S.Struct({
54
+ "type": RequestPageLocationCitationType,
55
+ "cited_text": S.String,
56
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
57
+ "document_title": S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null),
58
+ "start_page_number": S.Int.pipe(S.greaterThanOrEqualTo(1)),
59
+ "end_page_number": S.Int
60
+ }) {}
61
+
62
+ export class RequestContentBlockLocationCitationType extends S.Literal("content_block_location") {}
63
+
64
+ export class RequestContentBlockLocationCitation extends S.Struct({
65
+ "type": RequestContentBlockLocationCitationType,
66
+ "cited_text": S.String,
67
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
68
+ "document_title": S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null),
69
+ "start_block_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
70
+ "end_block_index": S.Int
71
+ }) {}
72
+
73
+ export class RequestTextBlockType extends S.Literal("text") {}
74
+
75
+ export class RequestTextBlock extends S.Struct({
76
+ "cache_control": S.optionalWith(S.Union(CacheControlEphemeral, S.Null), { nullable: true }),
77
+ "citations": S.optionalWith(
78
+ S.Union(
79
+ S.Array(S.Union(RequestCharLocationCitation, RequestPageLocationCitation, RequestContentBlockLocationCitation)),
80
+ S.Null
81
+ ),
82
+ { nullable: true }
83
+ ),
84
+ "text": S.String.pipe(S.minLength(1)),
85
+ "type": RequestTextBlockType
86
+ }) {}
87
+
88
+ export class RequestImageBlockType extends S.Literal("image") {}
89
+
90
+ export class Base64ImageSourceType extends S.Literal("base64") {}
91
+
92
+ export class Base64ImageSourceMediaType extends S.Literal("image/jpeg", "image/png", "image/gif", "image/webp") {}
93
+
94
+ export class Base64ImageSource extends S.Struct({
95
+ "type": Base64ImageSourceType,
96
+ "media_type": Base64ImageSourceMediaType,
97
+ "data": S.String
98
+ }) {}
99
+
100
+ export class RequestImageBlock extends S.Struct({
101
+ "cache_control": S.optionalWith(S.Union(CacheControlEphemeral, S.Null), { nullable: true }),
102
+ "type": RequestImageBlockType,
103
+ "source": Base64ImageSource
104
+ }) {}
105
+
106
+ export class RequestToolUseBlockType extends S.Literal("tool_use") {}
107
+
108
+ export class RequestToolUseBlock extends S.Struct({
109
+ "cache_control": S.optionalWith(S.Union(CacheControlEphemeral, S.Null), { nullable: true }),
110
+ "type": RequestToolUseBlockType,
111
+ "id": S.String.pipe(S.pattern(new RegExp("^[a-zA-Z0-9_-]+$"))),
112
+ "name": S.String.pipe(S.minLength(1), S.maxLength(64), S.pattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$"))),
113
+ "input": S.Record({ key: S.String, value: S.Unknown })
114
+ }) {}
115
+
116
+ export class RequestToolResultBlockType extends S.Literal("tool_result") {}
117
+
118
+ export class RequestToolResultBlock extends S.Struct({
119
+ "cache_control": S.optionalWith(S.Union(CacheControlEphemeral, S.Null), { nullable: true }),
120
+ "type": RequestToolResultBlockType,
121
+ "tool_use_id": S.String.pipe(S.pattern(new RegExp("^[a-zA-Z0-9_-]+$"))),
122
+ "is_error": S.optionalWith(S.Boolean, { nullable: true }),
123
+ "content": S.optionalWith(S.Union(S.String, S.Array(S.Union(RequestTextBlock, RequestImageBlock))), {
124
+ nullable: true
125
+ })
126
+ }) {}
127
+
128
+ export class RequestDocumentBlockType extends S.Literal("document") {}
129
+
130
+ export class Base64PDFSourceType extends S.Literal("base64") {}
131
+
132
+ export class Base64PDFSourceMediaType extends S.Literal("application/pdf") {}
133
+
134
+ export class Base64PDFSource extends S.Struct({
135
+ "type": Base64PDFSourceType,
136
+ "media_type": Base64PDFSourceMediaType,
137
+ "data": S.String
138
+ }) {}
139
+
140
+ export class PlainTextSourceType extends S.Literal("text") {}
141
+
142
+ export class PlainTextSourceMediaType extends S.Literal("text/plain") {}
143
+
144
+ export class PlainTextSource extends S.Struct({
145
+ "type": PlainTextSourceType,
146
+ "media_type": PlainTextSourceMediaType,
147
+ "data": S.String
148
+ }) {}
149
+
150
+ export class ContentBlockSourceType extends S.Literal("content") {}
151
+
152
+ export class ContentBlockSource extends S.Struct({
153
+ "type": ContentBlockSourceType,
154
+ "content": S.Union(S.String, S.Array(S.Union(RequestTextBlock, RequestImageBlock)))
155
+ }) {}
156
+
157
+ export class RequestCitationsConfig extends S.Struct({
158
+ "enabled": S.optionalWith(S.Boolean, { nullable: true })
159
+ }) {}
160
+
161
+ export class RequestDocumentBlock extends S.Struct({
162
+ "cache_control": S.optionalWith(S.Union(CacheControlEphemeral, S.Null), { nullable: true }),
163
+ "type": RequestDocumentBlockType,
164
+ "source": S.Union(Base64PDFSource, PlainTextSource, ContentBlockSource),
165
+ "title": S.optionalWith(S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null), { nullable: true }),
166
+ "context": S.optionalWith(S.Union(S.String.pipe(S.minLength(1)), S.Null), { nullable: true }),
167
+ "citations": S.optionalWith(RequestCitationsConfig, { nullable: true })
168
+ }) {}
169
+
170
+ export class InputContentBlock extends S.Union(
171
+ RequestTextBlock,
172
+ RequestImageBlock,
173
+ RequestToolUseBlock,
174
+ RequestToolResultBlock,
175
+ RequestDocumentBlock
176
+ ) {}
177
+
178
+ export class InputMessage extends S.Struct({
179
+ "role": InputMessageRole,
180
+ "content": S.Union(S.String, S.Array(InputContentBlock))
181
+ }) {}
182
+
183
+ export class Metadata extends S.Struct({
184
+ "user_id": S.optionalWith(S.Union(S.String.pipe(S.maxLength(256)), S.Null), { nullable: true })
185
+ }) {}
186
+
187
+ export class ToolChoiceAutoType extends S.Literal("auto") {}
188
+
189
+ export class ToolChoiceAuto extends S.Struct({
190
+ "type": ToolChoiceAutoType,
191
+ "disable_parallel_tool_use": S.optionalWith(S.Boolean, { nullable: true })
192
+ }) {}
193
+
194
+ export class ToolChoiceAnyType extends S.Literal("any") {}
195
+
196
+ export class ToolChoiceAny extends S.Struct({
197
+ "type": ToolChoiceAnyType,
198
+ "disable_parallel_tool_use": S.optionalWith(S.Boolean, { nullable: true })
199
+ }) {}
200
+
201
+ export class ToolChoiceToolType extends S.Literal("tool") {}
202
+
203
+ export class ToolChoiceTool extends S.Struct({
204
+ "type": ToolChoiceToolType,
205
+ "name": S.String,
206
+ "disable_parallel_tool_use": S.optionalWith(S.Boolean, { nullable: true })
207
+ }) {}
208
+
209
+ export class ToolChoice extends S.Union(ToolChoiceAuto, ToolChoiceAny, ToolChoiceTool) {}
210
+
211
+ export class InputSchemaType extends S.Literal("object") {}
212
+
213
+ export class InputSchema extends S.Struct({
214
+ "type": InputSchemaType,
215
+ "properties": S.optionalWith(S.Union(S.Record({ key: S.String, value: S.Unknown }), S.Null), { nullable: true })
216
+ }) {}
217
+
218
+ export class Tool extends S.Struct({
219
+ "description": S.optionalWith(S.String, { nullable: true }),
220
+ "name": S.String.pipe(S.minLength(1), S.maxLength(64), S.pattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$"))),
221
+ "input_schema": InputSchema,
222
+ "cache_control": S.optionalWith(S.Union(CacheControlEphemeral, S.Null), { nullable: true })
223
+ }) {}
224
+
225
+ export class CreateMessageParams extends S.Class<CreateMessageParams>("CreateMessageParams")({
226
+ "model": Model,
227
+ "messages": S.Array(InputMessage),
228
+ "max_tokens": S.Int.pipe(S.greaterThanOrEqualTo(1)),
229
+ "metadata": S.optionalWith(Metadata, { nullable: true }),
230
+ "stop_sequences": S.optionalWith(S.Array(S.String), { nullable: true }),
231
+ "stream": S.optionalWith(S.Boolean, { nullable: true }),
232
+ "system": S.optionalWith(S.Union(S.String, S.Array(RequestTextBlock)), { nullable: true }),
233
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), { nullable: true }),
234
+ "tool_choice": S.optionalWith(ToolChoice, { nullable: true }),
235
+ "tools": S.optionalWith(S.Array(Tool), { nullable: true }),
236
+ "top_k": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0)), { nullable: true }),
237
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), { nullable: true })
238
+ }) {}
239
+
240
+ export class MessageType extends S.Literal("message") {}
241
+
242
+ export class MessageRole extends S.Literal("assistant") {}
243
+
244
+ export class ResponseTextBlockType extends S.Literal("text") {}
245
+
246
+ export class ResponseCharLocationCitationType extends S.Literal("char_location") {}
247
+
248
+ export class ResponseCharLocationCitation extends S.Struct({
249
+ "type": ResponseCharLocationCitationType.pipe(
250
+ S.propertySignature,
251
+ S.withConstructorDefault(() => "char_location" as const)
252
+ ),
253
+ "cited_text": S.String,
254
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
255
+ "document_title": S.Union(S.String, S.Null),
256
+ "start_char_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
257
+ "end_char_index": S.Int
258
+ }) {}
259
+
260
+ export class ResponsePageLocationCitationType extends S.Literal("page_location") {}
261
+
262
+ export class ResponsePageLocationCitation extends S.Struct({
263
+ "type": ResponsePageLocationCitationType.pipe(
264
+ S.propertySignature,
265
+ S.withConstructorDefault(() => "page_location" as const)
266
+ ),
267
+ "cited_text": S.String,
268
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
269
+ "document_title": S.Union(S.String, S.Null),
270
+ "start_page_number": S.Int.pipe(S.greaterThanOrEqualTo(1)),
271
+ "end_page_number": S.Int
272
+ }) {}
273
+
274
+ export class ResponseContentBlockLocationCitationType extends S.Literal("content_block_location") {}
275
+
276
+ export class ResponseContentBlockLocationCitation extends S.Struct({
277
+ "type": ResponseContentBlockLocationCitationType.pipe(
278
+ S.propertySignature,
279
+ S.withConstructorDefault(() => "content_block_location" as const)
280
+ ),
281
+ "cited_text": S.String,
282
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
283
+ "document_title": S.Union(S.String, S.Null),
284
+ "start_block_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
285
+ "end_block_index": S.Int
286
+ }) {}
287
+
288
+ export class ResponseTextBlock extends S.Struct({
289
+ "type": ResponseTextBlockType.pipe(S.propertySignature, S.withConstructorDefault(() => "text" as const)),
290
+ "text": S.String.pipe(S.minLength(0), S.maxLength(5000000)),
291
+ "citations": S.optionalWith(
292
+ S.NullOr(
293
+ S.Union(
294
+ S.Array(
295
+ S.Union(ResponseCharLocationCitation, ResponsePageLocationCitation, ResponseContentBlockLocationCitation)
296
+ ),
297
+ S.Null
298
+ )
299
+ ),
300
+ { default: () => null }
301
+ )
302
+ }) {}
303
+
304
+ export class ResponseToolUseBlockType extends S.Literal("tool_use") {}
305
+
306
+ export class ResponseToolUseBlock extends S.Struct({
307
+ "type": ResponseToolUseBlockType.pipe(S.propertySignature, S.withConstructorDefault(() => "tool_use" as const)),
308
+ "id": S.String.pipe(S.pattern(new RegExp("^[a-zA-Z0-9_-]+$"))),
309
+ "name": S.String.pipe(S.minLength(1)),
310
+ "input": S.Record({ key: S.String, value: S.Unknown })
311
+ }) {}
312
+
313
+ export class ContentBlock extends S.Union(ResponseTextBlock, ResponseToolUseBlock) {}
314
+
315
+ export class MessageStopReasonEnum extends S.Literal("end_turn", "max_tokens", "stop_sequence", "tool_use") {}
316
+
317
+ export class Usage extends S.Struct({
318
+ "input_tokens": S.Int.pipe(S.greaterThanOrEqualTo(0)),
319
+ "cache_creation_input_tokens": S.optionalWith(S.NullOr(S.Union(S.Int.pipe(S.greaterThanOrEqualTo(0)), S.Null)), {
320
+ default: () => null
321
+ }),
322
+ "cache_read_input_tokens": S.optionalWith(S.NullOr(S.Union(S.Int.pipe(S.greaterThanOrEqualTo(0)), S.Null)), {
323
+ default: () => null
324
+ }),
325
+ "output_tokens": S.Int.pipe(S.greaterThanOrEqualTo(0))
326
+ }) {}
327
+
328
+ export class Message extends S.Class<Message>("Message")({
329
+ "id": S.String,
330
+ "type": MessageType.pipe(S.propertySignature, S.withConstructorDefault(() => "message" as const)),
331
+ "role": MessageRole.pipe(S.propertySignature, S.withConstructorDefault(() => "assistant" as const)),
332
+ "content": S.Array(ContentBlock),
333
+ "model": Model,
334
+ "stop_reason": S.Union(MessageStopReasonEnum, S.Null),
335
+ "stop_sequence": S.optionalWith(S.NullOr(S.Union(S.String, S.Null)), { default: () => null }),
336
+ "usage": Usage
337
+ }) {}
338
+
339
+ export class ErrorResponseType extends S.Literal("error") {}
340
+
341
+ export class InvalidRequestErrorType extends S.Literal("invalid_request_error") {}
342
+
343
+ export class InvalidRequestError extends S.Struct({
344
+ "type": InvalidRequestErrorType.pipe(
345
+ S.propertySignature,
346
+ S.withConstructorDefault(() => "invalid_request_error" as const)
347
+ ),
348
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Invalid request" as const))
349
+ }) {}
350
+
351
+ export class AuthenticationErrorType extends S.Literal("authentication_error") {}
352
+
353
+ export class AuthenticationError extends S.Struct({
354
+ "type": AuthenticationErrorType.pipe(
355
+ S.propertySignature,
356
+ S.withConstructorDefault(() => "authentication_error" as const)
357
+ ),
358
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Authentication error" as const))
359
+ }) {}
360
+
361
+ export class BillingErrorType extends S.Literal("billing_error") {}
362
+
363
+ export class BillingError extends S.Struct({
364
+ "type": BillingErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "billing_error" as const)),
365
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Billing error" as const))
366
+ }) {}
367
+
368
+ export class PermissionErrorType extends S.Literal("permission_error") {}
369
+
370
+ export class PermissionError extends S.Struct({
371
+ "type": PermissionErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "permission_error" as const)),
372
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Permission denied" as const))
373
+ }) {}
374
+
375
+ export class NotFoundErrorType extends S.Literal("not_found_error") {}
376
+
377
+ export class NotFoundError extends S.Struct({
378
+ "type": NotFoundErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "not_found_error" as const)),
379
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Not found" as const))
380
+ }) {}
381
+
382
+ export class RateLimitErrorType extends S.Literal("rate_limit_error") {}
383
+
384
+ export class RateLimitError extends S.Struct({
385
+ "type": RateLimitErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "rate_limit_error" as const)),
386
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Rate limited" as const))
387
+ }) {}
388
+
389
+ export class GatewayTimeoutErrorType extends S.Literal("timeout_error") {}
390
+
391
+ export class GatewayTimeoutError extends S.Struct({
392
+ "type": GatewayTimeoutErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "timeout_error" as const)),
393
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Request timeout" as const))
394
+ }) {}
395
+
396
+ export class APIErrorType extends S.Literal("api_error") {}
397
+
398
+ export class APIError extends S.Struct({
399
+ "type": APIErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "api_error" as const)),
400
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Internal server error" as const))
401
+ }) {}
402
+
403
+ export class OverloadedErrorType extends S.Literal("overloaded_error") {}
404
+
405
+ export class OverloadedError extends S.Struct({
406
+ "type": OverloadedErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "overloaded_error" as const)),
407
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Overloaded" as const))
408
+ }) {}
409
+
410
+ export class ErrorResponse extends S.Class<ErrorResponse>("ErrorResponse")({
411
+ "type": ErrorResponseType.pipe(S.propertySignature, S.withConstructorDefault(() => "error" as const)),
412
+ "error": S.Union(
413
+ InvalidRequestError,
414
+ AuthenticationError,
415
+ BillingError,
416
+ PermissionError,
417
+ NotFoundError,
418
+ RateLimitError,
419
+ GatewayTimeoutError,
420
+ APIError,
421
+ OverloadedError
422
+ )
423
+ }) {}
424
+
425
+ export class CompletePostParams extends S.Struct({
426
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
427
+ }) {}
428
+
429
+ export class CompletionRequest extends S.Class<CompletionRequest>("CompletionRequest")({
430
+ "model": Model,
431
+ "prompt": S.String.pipe(S.minLength(1)),
432
+ "max_tokens_to_sample": S.Int.pipe(S.greaterThanOrEqualTo(1)),
433
+ "stop_sequences": S.optionalWith(S.Array(S.String), { nullable: true }),
434
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), { nullable: true }),
435
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), { nullable: true }),
436
+ "top_k": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0)), { nullable: true }),
437
+ "metadata": S.optionalWith(Metadata, { nullable: true }),
438
+ "stream": S.optionalWith(S.Boolean, { nullable: true })
439
+ }) {}
440
+
441
+ export class CompletionResponseType extends S.Literal("completion") {}
442
+
443
+ export class CompletionResponse extends S.Class<CompletionResponse>("CompletionResponse")({
444
+ "type": CompletionResponseType.pipe(S.propertySignature, S.withConstructorDefault(() => "completion" as const)),
445
+ "id": S.String,
446
+ "completion": S.String,
447
+ "stop_reason": S.Union(S.String, S.Null),
448
+ "model": Model
449
+ }) {}
450
+
451
+ export class ModelsListParams extends S.Struct({
452
+ "before_id": S.optionalWith(S.String, { nullable: true }),
453
+ "after_id": S.optionalWith(S.String, { nullable: true }),
454
+ "limit": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(1000)), {
455
+ nullable: true,
456
+ default: () => 20 as const
457
+ }),
458
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
459
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
460
+ }) {}
461
+
462
+ export class ModelInfoType extends S.Literal("model") {}
463
+
464
+ export class ModelInfo extends S.Struct({
465
+ "type": ModelInfoType.pipe(S.propertySignature, S.withConstructorDefault(() => "model" as const)),
466
+ "id": S.String,
467
+ "display_name": S.String,
468
+ "created_at": S.String
469
+ }) {}
470
+
471
+ export class ListResponseModelInfo extends S.Class<ListResponseModelInfo>("ListResponseModelInfo")({
472
+ "data": S.Array(ModelInfo),
473
+ "has_more": S.Boolean,
474
+ "first_id": S.Union(S.String, S.Null),
475
+ "last_id": S.Union(S.String, S.Null)
476
+ }) {}
477
+
478
+ export class ModelsGetParams extends S.Struct({
479
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
480
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
481
+ }) {}
482
+
483
+ export class MessageBatchesListParams extends S.Struct({
484
+ "before_id": S.optionalWith(S.String, { nullable: true }),
485
+ "after_id": S.optionalWith(S.String, { nullable: true }),
486
+ "limit": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(1000)), {
487
+ nullable: true,
488
+ default: () => 20 as const
489
+ }),
490
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
491
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
492
+ }) {}
493
+
494
+ export class MessageBatchType extends S.Literal("message_batch") {}
495
+
496
+ export class MessageBatchProcessingStatus extends S.Literal("in_progress", "canceling", "ended") {}
497
+
498
+ export class RequestCounts extends S.Struct({
499
+ "processing": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
500
+ "succeeded": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
501
+ "errored": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
502
+ "canceled": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
503
+ "expired": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const))
504
+ }) {}
505
+
506
+ export class MessageBatch extends S.Struct({
507
+ "id": S.String,
508
+ "type": MessageBatchType.pipe(S.propertySignature, S.withConstructorDefault(() => "message_batch" as const)),
509
+ "processing_status": MessageBatchProcessingStatus,
510
+ "request_counts": RequestCounts,
511
+ "ended_at": S.Union(S.String, S.Null),
512
+ "created_at": S.String,
513
+ "expires_at": S.String,
514
+ "archived_at": S.Union(S.String, S.Null),
515
+ "cancel_initiated_at": S.Union(S.String, S.Null),
516
+ "results_url": S.Union(S.String, S.Null)
517
+ }) {}
518
+
519
+ export class ListResponseMessageBatch extends S.Class<ListResponseMessageBatch>("ListResponseMessageBatch")({
520
+ "data": S.Array(MessageBatch),
521
+ "has_more": S.Boolean,
522
+ "first_id": S.Union(S.String, S.Null),
523
+ "last_id": S.Union(S.String, S.Null)
524
+ }) {}
525
+
526
+ export class MessageBatchesPostParams extends S.Struct({
527
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
528
+ }) {}
529
+
530
+ export class MessageBatchIndividualRequestParams extends S.Struct({
531
+ "custom_id": S.String.pipe(S.minLength(1), S.maxLength(64), S.pattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$"))),
532
+ "params": CreateMessageParams
533
+ }) {}
534
+
535
+ export class CreateMessageBatchParams extends S.Class<CreateMessageBatchParams>("CreateMessageBatchParams")({
536
+ "requests": S.Array(MessageBatchIndividualRequestParams).pipe(S.minItems(1), S.maxItems(10000))
537
+ }) {}
538
+
539
+ export class MessageBatchesRetrieveParams extends S.Struct({
540
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
541
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
542
+ }) {}
543
+
544
+ export class MessageBatchesDeleteParams extends S.Struct({
545
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
546
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
547
+ }) {}
548
+
549
+ export class DeleteMessageBatchResponseType extends S.Literal("message_batch_deleted") {}
550
+
551
+ export class DeleteMessageBatchResponse extends S.Class<DeleteMessageBatchResponse>("DeleteMessageBatchResponse")({
552
+ "id": S.String,
553
+ "type": DeleteMessageBatchResponseType.pipe(
554
+ S.propertySignature,
555
+ S.withConstructorDefault(() => "message_batch_deleted" as const)
556
+ )
557
+ }) {}
558
+
559
+ export class MessageBatchesCancelParams extends S.Struct({
560
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
561
+ }) {}
562
+
563
+ export class MessageBatchesResultsParams extends S.Struct({
564
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
565
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
566
+ }) {}
567
+
568
+ export class MessagesCountTokensPostParams extends S.Struct({
569
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
570
+ }) {}
571
+
572
+ export class CountMessageTokensParams extends S.Class<CountMessageTokensParams>("CountMessageTokensParams")({
573
+ "tool_choice": S.optionalWith(ToolChoice, { nullable: true }),
574
+ "tools": S.optionalWith(S.Array(Tool), { nullable: true }),
575
+ "messages": S.Array(InputMessage),
576
+ "system": S.optionalWith(S.Union(S.String, S.Array(RequestTextBlock)), { nullable: true }),
577
+ "model": Model
578
+ }) {}
579
+
580
+ export class CountMessageTokensResponse extends S.Class<CountMessageTokensResponse>("CountMessageTokensResponse")({
581
+ "input_tokens": S.Int
582
+ }) {}
583
+
584
+ export class BetaMessagesPostParams extends S.Struct({
585
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
586
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
587
+ }) {}
588
+
589
+ export class BetaInputMessageRole extends S.Literal("user", "assistant") {}
590
+
591
+ export class BetaCacheControlEphemeralType extends S.Literal("ephemeral") {}
592
+
593
+ export class BetaCacheControlEphemeral extends S.Struct({
594
+ "type": BetaCacheControlEphemeralType
595
+ }) {}
596
+
597
+ export class BetaRequestCharLocationCitationType extends S.Literal("char_location") {}
598
+
599
+ export class BetaRequestCharLocationCitation extends S.Struct({
600
+ "type": BetaRequestCharLocationCitationType,
601
+ "cited_text": S.String,
602
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
603
+ "document_title": S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null),
604
+ "start_char_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
605
+ "end_char_index": S.Int
606
+ }) {}
607
+
608
+ export class BetaRequestPageLocationCitationType extends S.Literal("page_location") {}
609
+
610
+ export class BetaRequestPageLocationCitation extends S.Struct({
611
+ "type": BetaRequestPageLocationCitationType,
612
+ "cited_text": S.String,
613
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
614
+ "document_title": S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null),
615
+ "start_page_number": S.Int.pipe(S.greaterThanOrEqualTo(1)),
616
+ "end_page_number": S.Int
617
+ }) {}
618
+
619
+ export class BetaRequestContentBlockLocationCitationType extends S.Literal("content_block_location") {}
620
+
621
+ export class BetaRequestContentBlockLocationCitation extends S.Struct({
622
+ "type": BetaRequestContentBlockLocationCitationType,
623
+ "cited_text": S.String,
624
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
625
+ "document_title": S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null),
626
+ "start_block_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
627
+ "end_block_index": S.Int
628
+ }) {}
629
+
630
+ export class BetaRequestTextBlockType extends S.Literal("text") {}
631
+
632
+ export class BetaRequestTextBlock extends S.Struct({
633
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
634
+ "citations": S.optionalWith(
635
+ S.Union(
636
+ S.Array(
637
+ S.Union(
638
+ BetaRequestCharLocationCitation,
639
+ BetaRequestPageLocationCitation,
640
+ BetaRequestContentBlockLocationCitation
641
+ )
642
+ ),
643
+ S.Null
644
+ ),
645
+ { nullable: true }
646
+ ),
647
+ "text": S.String.pipe(S.minLength(1)),
648
+ "type": BetaRequestTextBlockType
649
+ }) {}
650
+
651
+ export class BetaRequestImageBlockType extends S.Literal("image") {}
652
+
653
+ export class BetaBase64ImageSourceType extends S.Literal("base64") {}
654
+
655
+ export class BetaBase64ImageSourceMediaType extends S.Literal("image/jpeg", "image/png", "image/gif", "image/webp") {}
656
+
657
+ export class BetaBase64ImageSource extends S.Struct({
658
+ "type": BetaBase64ImageSourceType,
659
+ "media_type": BetaBase64ImageSourceMediaType,
660
+ "data": S.String
661
+ }) {}
662
+
663
+ export class BetaRequestImageBlock extends S.Struct({
664
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
665
+ "type": BetaRequestImageBlockType,
666
+ "source": BetaBase64ImageSource
667
+ }) {}
668
+
669
+ export class BetaRequestToolUseBlockType extends S.Literal("tool_use") {}
670
+
671
+ export class BetaRequestToolUseBlock extends S.Struct({
672
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
673
+ "type": BetaRequestToolUseBlockType,
674
+ "id": S.String.pipe(S.pattern(new RegExp("^[a-zA-Z0-9_-]+$"))),
675
+ "name": S.String.pipe(S.minLength(1), S.maxLength(64), S.pattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$"))),
676
+ "input": S.Record({ key: S.String, value: S.Unknown })
677
+ }) {}
678
+
679
+ export class BetaRequestToolResultBlockType extends S.Literal("tool_result") {}
680
+
681
+ export class BetaRequestToolResultBlock extends S.Struct({
682
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
683
+ "type": BetaRequestToolResultBlockType,
684
+ "tool_use_id": S.String.pipe(S.pattern(new RegExp("^[a-zA-Z0-9_-]+$"))),
685
+ "is_error": S.optionalWith(S.Boolean, { nullable: true }),
686
+ "content": S.optionalWith(S.Union(S.String, S.Array(S.Union(BetaRequestTextBlock, BetaRequestImageBlock))), {
687
+ nullable: true
688
+ })
689
+ }) {}
690
+
691
+ export class BetaRequestDocumentBlockType extends S.Literal("document") {}
692
+
693
+ export class BetaBase64PDFSourceType extends S.Literal("base64") {}
694
+
695
+ export class BetaBase64PDFSourceMediaType extends S.Literal("application/pdf") {}
696
+
697
+ export class BetaBase64PDFSource extends S.Struct({
698
+ "type": BetaBase64PDFSourceType,
699
+ "media_type": BetaBase64PDFSourceMediaType,
700
+ "data": S.String
701
+ }) {}
702
+
703
+ export class BetaPlainTextSourceType extends S.Literal("text") {}
704
+
705
+ export class BetaPlainTextSourceMediaType extends S.Literal("text/plain") {}
706
+
707
+ export class BetaPlainTextSource extends S.Struct({
708
+ "type": BetaPlainTextSourceType,
709
+ "media_type": BetaPlainTextSourceMediaType,
710
+ "data": S.String
711
+ }) {}
712
+
713
+ export class BetaContentBlockSourceType extends S.Literal("content") {}
714
+
715
+ export class BetaContentBlockSource extends S.Struct({
716
+ "type": BetaContentBlockSourceType,
717
+ "content": S.Union(S.String, S.Array(S.Union(BetaRequestTextBlock, BetaRequestImageBlock)))
718
+ }) {}
719
+
720
+ export class BetaRequestCitationsConfig extends S.Struct({
721
+ "enabled": S.optionalWith(S.Boolean, { nullable: true })
722
+ }) {}
723
+
724
+ export class BetaRequestDocumentBlock extends S.Struct({
725
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
726
+ "type": BetaRequestDocumentBlockType,
727
+ "source": S.Union(BetaBase64PDFSource, BetaPlainTextSource, BetaContentBlockSource),
728
+ "title": S.optionalWith(S.Union(S.String.pipe(S.minLength(1), S.maxLength(255)), S.Null), { nullable: true }),
729
+ "context": S.optionalWith(S.Union(S.String.pipe(S.minLength(1)), S.Null), { nullable: true }),
730
+ "citations": S.optionalWith(BetaRequestCitationsConfig, { nullable: true })
731
+ }) {}
732
+
733
+ export class BetaInputContentBlock extends S.Union(
734
+ BetaRequestTextBlock,
735
+ BetaRequestImageBlock,
736
+ BetaRequestToolUseBlock,
737
+ BetaRequestToolResultBlock,
738
+ BetaRequestDocumentBlock
739
+ ) {}
740
+
741
+ export class BetaInputMessage extends S.Struct({
742
+ "role": BetaInputMessageRole,
743
+ "content": S.Union(S.String, S.Array(BetaInputContentBlock))
744
+ }) {}
745
+
746
+ export class BetaMetadata extends S.Struct({
747
+ "user_id": S.optionalWith(S.Union(S.String.pipe(S.maxLength(256)), S.Null), { nullable: true })
748
+ }) {}
749
+
750
+ export class BetaToolChoiceAutoType extends S.Literal("auto") {}
751
+
752
+ export class BetaToolChoiceAuto extends S.Struct({
753
+ "type": BetaToolChoiceAutoType,
754
+ "disable_parallel_tool_use": S.optionalWith(S.Boolean, { nullable: true })
755
+ }) {}
756
+
757
+ export class BetaToolChoiceAnyType extends S.Literal("any") {}
758
+
759
+ export class BetaToolChoiceAny extends S.Struct({
760
+ "type": BetaToolChoiceAnyType,
761
+ "disable_parallel_tool_use": S.optionalWith(S.Boolean, { nullable: true })
762
+ }) {}
763
+
764
+ export class BetaToolChoiceToolType extends S.Literal("tool") {}
765
+
766
+ export class BetaToolChoiceTool extends S.Struct({
767
+ "type": BetaToolChoiceToolType,
768
+ "name": S.String,
769
+ "disable_parallel_tool_use": S.optionalWith(S.Boolean, { nullable: true })
770
+ }) {}
771
+
772
+ export class BetaToolChoice extends S.Union(BetaToolChoiceAuto, BetaToolChoiceAny, BetaToolChoiceTool) {}
773
+
774
+ export class BetaToolTypeEnum extends S.Literal("custom") {}
775
+
776
+ export class BetaInputSchemaType extends S.Literal("object") {}
777
+
778
+ export class BetaInputSchema extends S.Struct({
779
+ "type": BetaInputSchemaType,
780
+ "properties": S.optionalWith(S.Union(S.Record({ key: S.String, value: S.Unknown }), S.Null), { nullable: true })
781
+ }) {}
782
+
783
+ export class BetaTool extends S.Struct({
784
+ "type": S.optionalWith(S.Union(S.Null, BetaToolTypeEnum), { nullable: true }),
785
+ "description": S.optionalWith(S.String, { nullable: true }),
786
+ "name": S.String.pipe(S.minLength(1), S.maxLength(64), S.pattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$"))),
787
+ "input_schema": BetaInputSchema,
788
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true })
789
+ }) {}
790
+
791
+ export class BetaComputerUseTool20241022Type extends S.Literal("computer_20241022") {}
792
+
793
+ export class BetaComputerUseTool20241022Name extends S.Literal("computer") {}
794
+
795
+ export class BetaComputerUseTool20241022 extends S.Struct({
796
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
797
+ "type": BetaComputerUseTool20241022Type,
798
+ "name": BetaComputerUseTool20241022Name,
799
+ "display_height_px": S.Int.pipe(S.greaterThanOrEqualTo(1)),
800
+ "display_width_px": S.Int.pipe(S.greaterThanOrEqualTo(1)),
801
+ "display_number": S.optionalWith(S.Union(S.Int.pipe(S.greaterThanOrEqualTo(0)), S.Null), { nullable: true })
802
+ }) {}
803
+
804
+ export class BetaBashTool20241022Type extends S.Literal("bash_20241022") {}
805
+
806
+ export class BetaBashTool20241022Name extends S.Literal("bash") {}
807
+
808
+ export class BetaBashTool20241022 extends S.Struct({
809
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
810
+ "type": BetaBashTool20241022Type,
811
+ "name": BetaBashTool20241022Name
812
+ }) {}
813
+
814
+ export class BetaTextEditor20241022Type extends S.Literal("text_editor_20241022") {}
815
+
816
+ export class BetaTextEditor20241022Name extends S.Literal("str_replace_editor") {}
817
+
818
+ export class BetaTextEditor20241022 extends S.Struct({
819
+ "cache_control": S.optionalWith(S.Union(BetaCacheControlEphemeral, S.Null), { nullable: true }),
820
+ "type": BetaTextEditor20241022Type,
821
+ "name": BetaTextEditor20241022Name
822
+ }) {}
823
+
824
+ export class BetaCreateMessageParams extends S.Class<BetaCreateMessageParams>("BetaCreateMessageParams")({
825
+ "model": Model,
826
+ "messages": S.Array(BetaInputMessage),
827
+ "max_tokens": S.Int.pipe(S.greaterThanOrEqualTo(1)),
828
+ "metadata": S.optionalWith(BetaMetadata, { nullable: true }),
829
+ "stop_sequences": S.optionalWith(S.Array(S.String), { nullable: true }),
830
+ "stream": S.optionalWith(S.Boolean, { nullable: true }),
831
+ "system": S.optionalWith(S.Union(S.String, S.Array(BetaRequestTextBlock)), { nullable: true }),
832
+ "temperature": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), { nullable: true }),
833
+ "tool_choice": S.optionalWith(BetaToolChoice, { nullable: true }),
834
+ "tools": S.optionalWith(
835
+ S.Array(S.Union(BetaTool, BetaComputerUseTool20241022, BetaBashTool20241022, BetaTextEditor20241022)),
836
+ { nullable: true }
837
+ ),
838
+ "top_k": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(0)), { nullable: true }),
839
+ "top_p": S.optionalWith(S.Number.pipe(S.greaterThanOrEqualTo(0), S.lessThanOrEqualTo(1)), { nullable: true })
840
+ }) {}
841
+
842
+ export class BetaMessageType extends S.Literal("message") {}
843
+
844
+ export class BetaMessageRole extends S.Literal("assistant") {}
845
+
846
+ export class BetaResponseTextBlockType extends S.Literal("text") {}
847
+
848
+ export class BetaResponseCharLocationCitationType extends S.Literal("char_location") {}
849
+
850
+ export class BetaResponseCharLocationCitation extends S.Struct({
851
+ "type": BetaResponseCharLocationCitationType.pipe(
852
+ S.propertySignature,
853
+ S.withConstructorDefault(() => "char_location" as const)
854
+ ),
855
+ "cited_text": S.String,
856
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
857
+ "document_title": S.Union(S.String, S.Null),
858
+ "start_char_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
859
+ "end_char_index": S.Int
860
+ }) {}
861
+
862
+ export class BetaResponsePageLocationCitationType extends S.Literal("page_location") {}
863
+
864
+ export class BetaResponsePageLocationCitation extends S.Struct({
865
+ "type": BetaResponsePageLocationCitationType.pipe(
866
+ S.propertySignature,
867
+ S.withConstructorDefault(() => "page_location" as const)
868
+ ),
869
+ "cited_text": S.String,
870
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
871
+ "document_title": S.Union(S.String, S.Null),
872
+ "start_page_number": S.Int.pipe(S.greaterThanOrEqualTo(1)),
873
+ "end_page_number": S.Int
874
+ }) {}
875
+
876
+ export class BetaResponseContentBlockLocationCitationType extends S.Literal("content_block_location") {}
877
+
878
+ export class BetaResponseContentBlockLocationCitation extends S.Struct({
879
+ "type": BetaResponseContentBlockLocationCitationType.pipe(
880
+ S.propertySignature,
881
+ S.withConstructorDefault(() => "content_block_location" as const)
882
+ ),
883
+ "cited_text": S.String,
884
+ "document_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
885
+ "document_title": S.Union(S.String, S.Null),
886
+ "start_block_index": S.Int.pipe(S.greaterThanOrEqualTo(0)),
887
+ "end_block_index": S.Int
888
+ }) {}
889
+
890
+ export class BetaResponseTextBlock extends S.Struct({
891
+ "type": BetaResponseTextBlockType.pipe(S.propertySignature, S.withConstructorDefault(() => "text" as const)),
892
+ "text": S.String.pipe(S.minLength(0), S.maxLength(5000000)),
893
+ "citations": S.optionalWith(
894
+ S.NullOr(
895
+ S.Union(
896
+ S.Array(
897
+ S.Union(
898
+ BetaResponseCharLocationCitation,
899
+ BetaResponsePageLocationCitation,
900
+ BetaResponseContentBlockLocationCitation
901
+ )
902
+ ),
903
+ S.Null
904
+ )
905
+ ),
906
+ { default: () => null }
907
+ )
908
+ }) {}
909
+
910
+ export class BetaResponseToolUseBlockType extends S.Literal("tool_use") {}
911
+
912
+ export class BetaResponseToolUseBlock extends S.Struct({
913
+ "type": BetaResponseToolUseBlockType.pipe(S.propertySignature, S.withConstructorDefault(() => "tool_use" as const)),
914
+ "id": S.String.pipe(S.pattern(new RegExp("^[a-zA-Z0-9_-]+$"))),
915
+ "name": S.String.pipe(S.minLength(1)),
916
+ "input": S.Record({ key: S.String, value: S.Unknown })
917
+ }) {}
918
+
919
+ export class BetaContentBlock extends S.Union(BetaResponseTextBlock, BetaResponseToolUseBlock) {}
920
+
921
+ export class BetaMessageStopReasonEnum extends S.Literal("end_turn", "max_tokens", "stop_sequence", "tool_use") {}
922
+
923
+ export class BetaUsage extends S.Struct({
924
+ "input_tokens": S.Int.pipe(S.greaterThanOrEqualTo(0)),
925
+ "cache_creation_input_tokens": S.optionalWith(S.NullOr(S.Union(S.Int.pipe(S.greaterThanOrEqualTo(0)), S.Null)), {
926
+ default: () => null
927
+ }),
928
+ "cache_read_input_tokens": S.optionalWith(S.NullOr(S.Union(S.Int.pipe(S.greaterThanOrEqualTo(0)), S.Null)), {
929
+ default: () => null
930
+ }),
931
+ "output_tokens": S.Int.pipe(S.greaterThanOrEqualTo(0))
932
+ }) {}
933
+
934
+ export class BetaMessage extends S.Class<BetaMessage>("BetaMessage")({
935
+ "id": S.String,
936
+ "type": BetaMessageType.pipe(S.propertySignature, S.withConstructorDefault(() => "message" as const)),
937
+ "role": BetaMessageRole.pipe(S.propertySignature, S.withConstructorDefault(() => "assistant" as const)),
938
+ "content": S.Array(BetaContentBlock),
939
+ "model": Model,
940
+ "stop_reason": S.Union(BetaMessageStopReasonEnum, S.Null),
941
+ "stop_sequence": S.optionalWith(S.NullOr(S.Union(S.String, S.Null)), { default: () => null }),
942
+ "usage": BetaUsage
943
+ }) {}
944
+
945
+ export class BetaErrorResponseType extends S.Literal("error") {}
946
+
947
+ export class BetaInvalidRequestErrorType extends S.Literal("invalid_request_error") {}
948
+
949
+ export class BetaInvalidRequestError extends S.Struct({
950
+ "type": BetaInvalidRequestErrorType.pipe(
951
+ S.propertySignature,
952
+ S.withConstructorDefault(() => "invalid_request_error" as const)
953
+ ),
954
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Invalid request" as const))
955
+ }) {}
956
+
957
+ export class BetaAuthenticationErrorType extends S.Literal("authentication_error") {}
958
+
959
+ export class BetaAuthenticationError extends S.Struct({
960
+ "type": BetaAuthenticationErrorType.pipe(
961
+ S.propertySignature,
962
+ S.withConstructorDefault(() => "authentication_error" as const)
963
+ ),
964
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Authentication error" as const))
965
+ }) {}
966
+
967
+ export class BetaBillingErrorType extends S.Literal("billing_error") {}
968
+
969
+ export class BetaBillingError extends S.Struct({
970
+ "type": BetaBillingErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "billing_error" as const)),
971
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Billing error" as const))
972
+ }) {}
973
+
974
+ export class BetaPermissionErrorType extends S.Literal("permission_error") {}
975
+
976
+ export class BetaPermissionError extends S.Struct({
977
+ "type": BetaPermissionErrorType.pipe(
978
+ S.propertySignature,
979
+ S.withConstructorDefault(() => "permission_error" as const)
980
+ ),
981
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Permission denied" as const))
982
+ }) {}
983
+
984
+ export class BetaNotFoundErrorType extends S.Literal("not_found_error") {}
985
+
986
+ export class BetaNotFoundError extends S.Struct({
987
+ "type": BetaNotFoundErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "not_found_error" as const)),
988
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Not found" as const))
989
+ }) {}
990
+
991
+ export class BetaRateLimitErrorType extends S.Literal("rate_limit_error") {}
992
+
993
+ export class BetaRateLimitError extends S.Struct({
994
+ "type": BetaRateLimitErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "rate_limit_error" as const)),
995
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Rate limited" as const))
996
+ }) {}
997
+
998
+ export class BetaGatewayTimeoutErrorType extends S.Literal("timeout_error") {}
999
+
1000
+ export class BetaGatewayTimeoutError extends S.Struct({
1001
+ "type": BetaGatewayTimeoutErrorType.pipe(
1002
+ S.propertySignature,
1003
+ S.withConstructorDefault(() => "timeout_error" as const)
1004
+ ),
1005
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Request timeout" as const))
1006
+ }) {}
1007
+
1008
+ export class BetaAPIErrorType extends S.Literal("api_error") {}
1009
+
1010
+ export class BetaAPIError extends S.Struct({
1011
+ "type": BetaAPIErrorType.pipe(S.propertySignature, S.withConstructorDefault(() => "api_error" as const)),
1012
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Internal server error" as const))
1013
+ }) {}
1014
+
1015
+ export class BetaOverloadedErrorType extends S.Literal("overloaded_error") {}
1016
+
1017
+ export class BetaOverloadedError extends S.Struct({
1018
+ "type": BetaOverloadedErrorType.pipe(
1019
+ S.propertySignature,
1020
+ S.withConstructorDefault(() => "overloaded_error" as const)
1021
+ ),
1022
+ "message": S.String.pipe(S.propertySignature, S.withConstructorDefault(() => "Overloaded" as const))
1023
+ }) {}
1024
+
1025
+ export class BetaErrorResponse extends S.Class<BetaErrorResponse>("BetaErrorResponse")({
1026
+ "type": BetaErrorResponseType.pipe(S.propertySignature, S.withConstructorDefault(() => "error" as const)),
1027
+ "error": S.Union(
1028
+ BetaInvalidRequestError,
1029
+ BetaAuthenticationError,
1030
+ BetaBillingError,
1031
+ BetaPermissionError,
1032
+ BetaNotFoundError,
1033
+ BetaRateLimitError,
1034
+ BetaGatewayTimeoutError,
1035
+ BetaAPIError,
1036
+ BetaOverloadedError
1037
+ )
1038
+ }) {}
1039
+
1040
+ export class BetaModelsListParams extends S.Struct({
1041
+ "before_id": S.optionalWith(S.String, { nullable: true }),
1042
+ "after_id": S.optionalWith(S.String, { nullable: true }),
1043
+ "limit": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(1000)), {
1044
+ nullable: true,
1045
+ default: () => 20 as const
1046
+ }),
1047
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
1048
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
1049
+ }) {}
1050
+
1051
+ export class BetaModelInfoType extends S.Literal("model") {}
1052
+
1053
+ export class BetaModelInfo extends S.Struct({
1054
+ "type": BetaModelInfoType.pipe(S.propertySignature, S.withConstructorDefault(() => "model" as const)),
1055
+ "id": S.String,
1056
+ "display_name": S.String,
1057
+ "created_at": S.String
1058
+ }) {}
1059
+
1060
+ export class BetaListResponseModelInfo extends S.Class<BetaListResponseModelInfo>("BetaListResponseModelInfo")({
1061
+ "data": S.Array(BetaModelInfo),
1062
+ "has_more": S.Boolean,
1063
+ "first_id": S.Union(S.String, S.Null),
1064
+ "last_id": S.Union(S.String, S.Null)
1065
+ }) {}
1066
+
1067
+ export class BetaModelsGetParams extends S.Struct({
1068
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
1069
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
1070
+ }) {}
1071
+
1072
+ export class BetaMessageBatchesListParams extends S.Struct({
1073
+ "before_id": S.optionalWith(S.String, { nullable: true }),
1074
+ "after_id": S.optionalWith(S.String, { nullable: true }),
1075
+ "limit": S.optionalWith(S.Int.pipe(S.greaterThanOrEqualTo(1), S.lessThanOrEqualTo(1000)), {
1076
+ nullable: true,
1077
+ default: () => 20 as const
1078
+ }),
1079
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
1080
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
1081
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
1082
+ }) {}
1083
+
1084
+ export class BetaMessageBatchType extends S.Literal("message_batch") {}
1085
+
1086
+ export class BetaMessageBatchProcessingStatus extends S.Literal("in_progress", "canceling", "ended") {}
1087
+
1088
+ export class BetaRequestCounts extends S.Struct({
1089
+ "processing": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
1090
+ "succeeded": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
1091
+ "errored": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
1092
+ "canceled": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const)),
1093
+ "expired": S.Int.pipe(S.propertySignature, S.withConstructorDefault(() => 0 as const))
1094
+ }) {}
1095
+
1096
+ export class BetaMessageBatch extends S.Struct({
1097
+ "id": S.String,
1098
+ "type": BetaMessageBatchType.pipe(S.propertySignature, S.withConstructorDefault(() => "message_batch" as const)),
1099
+ "processing_status": BetaMessageBatchProcessingStatus,
1100
+ "request_counts": BetaRequestCounts,
1101
+ "ended_at": S.Union(S.String, S.Null),
1102
+ "created_at": S.String,
1103
+ "expires_at": S.String,
1104
+ "archived_at": S.Union(S.String, S.Null),
1105
+ "cancel_initiated_at": S.Union(S.String, S.Null),
1106
+ "results_url": S.Union(S.String, S.Null)
1107
+ }) {}
1108
+
1109
+ export class BetaListResponseMessageBatch
1110
+ extends S.Class<BetaListResponseMessageBatch>("BetaListResponseMessageBatch")({
1111
+ "data": S.Array(BetaMessageBatch),
1112
+ "has_more": S.Boolean,
1113
+ "first_id": S.Union(S.String, S.Null),
1114
+ "last_id": S.Union(S.String, S.Null)
1115
+ })
1116
+ {}
1117
+
1118
+ export class BetaMessageBatchesPostParams extends S.Struct({
1119
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
1120
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
1121
+ }) {}
1122
+
1123
+ export class BetaMessageBatchIndividualRequestParams extends S.Struct({
1124
+ "custom_id": S.String.pipe(S.minLength(1), S.maxLength(64), S.pattern(new RegExp("^[a-zA-Z0-9_-]{1,64}$"))),
1125
+ "params": BetaCreateMessageParams
1126
+ }) {}
1127
+
1128
+ export class BetaCreateMessageBatchParams
1129
+ extends S.Class<BetaCreateMessageBatchParams>("BetaCreateMessageBatchParams")({
1130
+ "requests": S.Array(BetaMessageBatchIndividualRequestParams).pipe(S.minItems(1), S.maxItems(10000))
1131
+ })
1132
+ {}
1133
+
1134
+ export class BetaMessageBatchesRetrieveParams extends S.Struct({
1135
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
1136
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
1137
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
1138
+ }) {}
1139
+
1140
+ export class BetaMessageBatchesDeleteParams extends S.Struct({
1141
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
1142
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
1143
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
1144
+ }) {}
1145
+
1146
+ export class BetaDeleteMessageBatchResponseType extends S.Literal("message_batch_deleted") {}
1147
+
1148
+ export class BetaDeleteMessageBatchResponse
1149
+ extends S.Class<BetaDeleteMessageBatchResponse>("BetaDeleteMessageBatchResponse")({
1150
+ "id": S.String,
1151
+ "type": BetaDeleteMessageBatchResponseType.pipe(
1152
+ S.propertySignature,
1153
+ S.withConstructorDefault(() => "message_batch_deleted" as const)
1154
+ )
1155
+ })
1156
+ {}
1157
+
1158
+ export class BetaMessageBatchesCancelParams extends S.Struct({
1159
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
1160
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
1161
+ }) {}
1162
+
1163
+ export class BetaMessageBatchesResultsParams extends S.Struct({
1164
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
1165
+ "anthropic-version": S.optionalWith(S.String, { nullable: true }),
1166
+ "x-api-key": S.optionalWith(S.String, { nullable: true })
1167
+ }) {}
1168
+
1169
+ export class BetaMessagesCountTokensPostParams extends S.Struct({
1170
+ "anthropic-beta": S.optionalWith(S.String, { nullable: true }),
1171
+ "anthropic-version": S.optionalWith(S.String, { nullable: true })
1172
+ }) {}
1173
+
1174
+ export class BetaCountMessageTokensParams
1175
+ extends S.Class<BetaCountMessageTokensParams>("BetaCountMessageTokensParams")({
1176
+ "tool_choice": S.optionalWith(BetaToolChoice, { nullable: true }),
1177
+ "tools": S.optionalWith(
1178
+ S.Array(S.Union(BetaTool, BetaComputerUseTool20241022, BetaBashTool20241022, BetaTextEditor20241022)),
1179
+ { nullable: true }
1180
+ ),
1181
+ "messages": S.Array(BetaInputMessage),
1182
+ "system": S.optionalWith(S.Union(S.String, S.Array(BetaRequestTextBlock)), { nullable: true }),
1183
+ "model": Model
1184
+ })
1185
+ {}
1186
+
1187
+ export class BetaCountMessageTokensResponse
1188
+ extends S.Class<BetaCountMessageTokensResponse>("BetaCountMessageTokensResponse")({
1189
+ "input_tokens": S.Int
1190
+ })
1191
+ {}
1192
+
1193
+ export const make = (
1194
+ httpClient: HttpClient.HttpClient,
1195
+ options: {
1196
+ readonly transformClient?: ((client: HttpClient.HttpClient) => Effect.Effect<HttpClient.HttpClient>) | undefined
1197
+ } = {}
1198
+ ): Client => {
1199
+ const unexpectedStatus = (
1200
+ request: HttpClientRequest.HttpClientRequest,
1201
+ response: HttpClientResponse.HttpClientResponse
1202
+ ) =>
1203
+ Effect.flatMap(
1204
+ Effect.orElseSucceed(response.text, () => "Unexpected status code"),
1205
+ (description) =>
1206
+ Effect.fail(
1207
+ new HttpClientError.ResponseError({
1208
+ request,
1209
+ response,
1210
+ reason: "StatusCode",
1211
+ description
1212
+ })
1213
+ )
1214
+ )
1215
+ const applyClientTransform = (client: HttpClient.HttpClient): Effect.Effect<HttpClient.HttpClient> =>
1216
+ options.transformClient ? options.transformClient(client) : Effect.succeed(client)
1217
+ const decodeError = <A, I, R>(response: HttpClientResponse.HttpClientResponse, schema: S.Schema<A, I, R>) =>
1218
+ Effect.flatMap(HttpClientResponse.schemaBodyJson(schema)(response), Effect.fail)
1219
+ return {
1220
+ "messagesPost": (options) =>
1221
+ HttpClientRequest.make("POST")(`/v1/messages`).pipe(
1222
+ HttpClientRequest.setHeaders({ "anthropic-version": options.params["anthropic-version"] ?? undefined }),
1223
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
1224
+ Effect.flatMap((request) =>
1225
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1226
+ Effect.flatMap(
1227
+ httpClient.execute(request),
1228
+ HttpClientResponse.matchStatus({
1229
+ "200": (r) => HttpClientResponse.schemaBodyJson(Message)(r),
1230
+ "NaN": (r) => decodeError(r, ErrorResponse),
1231
+ orElse: (response) => unexpectedStatus(request, response)
1232
+ })
1233
+ ))
1234
+ ),
1235
+ Effect.scoped
1236
+ ),
1237
+ "completePost": (options) =>
1238
+ HttpClientRequest.make("POST")(`/v1/complete`).pipe(
1239
+ HttpClientRequest.setHeaders({ "anthropic-version": options.params["anthropic-version"] ?? undefined }),
1240
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
1241
+ Effect.flatMap((request) =>
1242
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1243
+ Effect.flatMap(
1244
+ httpClient.execute(request),
1245
+ HttpClientResponse.matchStatus({
1246
+ "200": (r) => HttpClientResponse.schemaBodyJson(CompletionResponse)(r),
1247
+ "NaN": (r) => decodeError(r, ErrorResponse),
1248
+ orElse: (response) => unexpectedStatus(request, response)
1249
+ })
1250
+ ))
1251
+ ),
1252
+ Effect.scoped
1253
+ ),
1254
+ "modelsList": (options) =>
1255
+ HttpClientRequest.make("GET")(`/v1/models`).pipe(
1256
+ HttpClientRequest.setUrlParams({
1257
+ "before_id": options["before_id"],
1258
+ "after_id": options["after_id"],
1259
+ "limit": options["limit"]
1260
+ }),
1261
+ HttpClientRequest.setHeaders({
1262
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1263
+ "x-api-key": options["x-api-key"] ?? undefined
1264
+ }),
1265
+ Effect.succeed,
1266
+ Effect.flatMap((request) =>
1267
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1268
+ Effect.flatMap(
1269
+ httpClient.execute(request),
1270
+ HttpClientResponse.matchStatus({
1271
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListResponseModelInfo)(r),
1272
+ "NaN": (r) => decodeError(r, ErrorResponse),
1273
+ orElse: (response) => unexpectedStatus(request, response)
1274
+ })
1275
+ ))
1276
+ ),
1277
+ Effect.scoped
1278
+ ),
1279
+ "modelsGet": (modelId, options) =>
1280
+ HttpClientRequest.make("GET")(`/v1/models/${modelId}`).pipe(
1281
+ HttpClientRequest.setHeaders({
1282
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1283
+ "x-api-key": options["x-api-key"] ?? undefined
1284
+ }),
1285
+ Effect.succeed,
1286
+ Effect.flatMap((request) =>
1287
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1288
+ Effect.flatMap(
1289
+ httpClient.execute(request),
1290
+ HttpClientResponse.matchStatus({
1291
+ "200": (r) => HttpClientResponse.schemaBodyJson(ModelInfo)(r),
1292
+ "NaN": (r) => decodeError(r, ErrorResponse),
1293
+ orElse: (response) => unexpectedStatus(request, response)
1294
+ })
1295
+ ))
1296
+ ),
1297
+ Effect.scoped
1298
+ ),
1299
+ "messageBatchesList": (options) =>
1300
+ HttpClientRequest.make("GET")(`/v1/messages/batches`).pipe(
1301
+ HttpClientRequest.setUrlParams({
1302
+ "before_id": options["before_id"],
1303
+ "after_id": options["after_id"],
1304
+ "limit": options["limit"]
1305
+ }),
1306
+ HttpClientRequest.setHeaders({
1307
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1308
+ "x-api-key": options["x-api-key"] ?? undefined
1309
+ }),
1310
+ Effect.succeed,
1311
+ Effect.flatMap((request) =>
1312
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1313
+ Effect.flatMap(
1314
+ httpClient.execute(request),
1315
+ HttpClientResponse.matchStatus({
1316
+ "200": (r) => HttpClientResponse.schemaBodyJson(ListResponseMessageBatch)(r),
1317
+ "NaN": (r) => decodeError(r, ErrorResponse),
1318
+ orElse: (response) => unexpectedStatus(request, response)
1319
+ })
1320
+ ))
1321
+ ),
1322
+ Effect.scoped
1323
+ ),
1324
+ "messageBatchesPost": (options) =>
1325
+ HttpClientRequest.make("POST")(`/v1/messages/batches`).pipe(
1326
+ HttpClientRequest.setHeaders({ "anthropic-version": options.params["anthropic-version"] ?? undefined }),
1327
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
1328
+ Effect.flatMap((request) =>
1329
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1330
+ Effect.flatMap(
1331
+ httpClient.execute(request),
1332
+ HttpClientResponse.matchStatus({
1333
+ "200": (r) => HttpClientResponse.schemaBodyJson(MessageBatch)(r),
1334
+ "NaN": (r) => decodeError(r, ErrorResponse),
1335
+ orElse: (response) => unexpectedStatus(request, response)
1336
+ })
1337
+ ))
1338
+ ),
1339
+ Effect.scoped
1340
+ ),
1341
+ "messageBatchesRetrieve": (messageBatchId, options) =>
1342
+ HttpClientRequest.make("GET")(`/v1/messages/batches/${messageBatchId}`).pipe(
1343
+ HttpClientRequest.setHeaders({
1344
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1345
+ "x-api-key": options["x-api-key"] ?? undefined
1346
+ }),
1347
+ Effect.succeed,
1348
+ Effect.flatMap((request) =>
1349
+ Effect.flatMap(
1350
+ applyClientTransform(httpClient),
1351
+ (httpClient) =>
1352
+ Effect.flatMap(
1353
+ httpClient.execute(request),
1354
+ HttpClientResponse.matchStatus({
1355
+ "200": (r) => HttpClientResponse.schemaBodyJson(MessageBatch)(r),
1356
+ "NaN": (r) => decodeError(r, ErrorResponse),
1357
+ orElse: (response) => unexpectedStatus(request, response)
1358
+ })
1359
+ )
1360
+ )
1361
+ ),
1362
+ Effect.scoped
1363
+ ),
1364
+ "messageBatchesDelete": (messageBatchId, options) =>
1365
+ HttpClientRequest.make("DELETE")(`/v1/messages/batches/${messageBatchId}`).pipe(
1366
+ HttpClientRequest.setHeaders({
1367
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1368
+ "x-api-key": options["x-api-key"] ?? undefined
1369
+ }),
1370
+ Effect.succeed,
1371
+ Effect.flatMap((request) =>
1372
+ Effect.flatMap(
1373
+ applyClientTransform(httpClient),
1374
+ (httpClient) =>
1375
+ Effect.flatMap(
1376
+ httpClient.execute(request),
1377
+ HttpClientResponse.matchStatus({
1378
+ "200": (r) => HttpClientResponse.schemaBodyJson(DeleteMessageBatchResponse)(r),
1379
+ "NaN": (r) => decodeError(r, ErrorResponse),
1380
+ orElse: (response) => unexpectedStatus(request, response)
1381
+ })
1382
+ )
1383
+ )
1384
+ ),
1385
+ Effect.scoped
1386
+ ),
1387
+ "messageBatchesCancel": (messageBatchId, options) =>
1388
+ HttpClientRequest.make("POST")(`/v1/messages/batches/${messageBatchId}/cancel`).pipe(
1389
+ HttpClientRequest.setHeaders({ "anthropic-version": options["anthropic-version"] ?? undefined }),
1390
+ Effect.succeed,
1391
+ Effect.flatMap((request) =>
1392
+ Effect.flatMap(
1393
+ applyClientTransform(httpClient),
1394
+ (httpClient) =>
1395
+ Effect.flatMap(
1396
+ httpClient.execute(request),
1397
+ HttpClientResponse.matchStatus({
1398
+ "200": (r) => HttpClientResponse.schemaBodyJson(MessageBatch)(r),
1399
+ "NaN": (r) => decodeError(r, ErrorResponse),
1400
+ orElse: (response) => unexpectedStatus(request, response)
1401
+ })
1402
+ )
1403
+ )
1404
+ ),
1405
+ Effect.scoped
1406
+ ),
1407
+ "messageBatchesResults": (messageBatchId, options) =>
1408
+ HttpClientRequest.make("GET")(`/v1/messages/batches/${messageBatchId}/results`).pipe(
1409
+ HttpClientRequest.setHeaders({
1410
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1411
+ "x-api-key": options["x-api-key"] ?? undefined
1412
+ }),
1413
+ Effect.succeed,
1414
+ Effect.flatMap((request) =>
1415
+ Effect.flatMap(
1416
+ applyClientTransform(httpClient),
1417
+ (httpClient) =>
1418
+ Effect.flatMap(
1419
+ httpClient.execute(request),
1420
+ HttpClientResponse.matchStatus({
1421
+ "NaN": (r) => decodeError(r, ErrorResponse),
1422
+ orElse: (response) => unexpectedStatus(request, response)
1423
+ })
1424
+ )
1425
+ )
1426
+ ),
1427
+ Effect.scoped
1428
+ ),
1429
+ "messagesCountTokensPost": (options) =>
1430
+ HttpClientRequest.make("POST")(`/v1/messages/count_tokens`).pipe(
1431
+ HttpClientRequest.setHeaders({ "anthropic-version": options.params["anthropic-version"] ?? undefined }),
1432
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
1433
+ Effect.flatMap((request) =>
1434
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1435
+ Effect.flatMap(
1436
+ httpClient.execute(request),
1437
+ HttpClientResponse.matchStatus({
1438
+ "200": (r) => HttpClientResponse.schemaBodyJson(CountMessageTokensResponse)(r),
1439
+ "NaN": (r) => decodeError(r, ErrorResponse),
1440
+ orElse: (response) => unexpectedStatus(request, response)
1441
+ })
1442
+ ))
1443
+ ),
1444
+ Effect.scoped
1445
+ ),
1446
+ "betaMessagesPost": (options) =>
1447
+ HttpClientRequest.make("POST")(`/v1/messages?beta=true`).pipe(
1448
+ HttpClientRequest.setHeaders({
1449
+ "anthropic-beta": options.params["anthropic-beta"] ?? undefined,
1450
+ "anthropic-version": options.params["anthropic-version"] ?? undefined
1451
+ }),
1452
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
1453
+ Effect.flatMap((request) =>
1454
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1455
+ Effect.flatMap(
1456
+ httpClient.execute(request),
1457
+ HttpClientResponse.matchStatus({
1458
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaMessage)(r),
1459
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1460
+ orElse: (response) => unexpectedStatus(request, response)
1461
+ })
1462
+ ))
1463
+ ),
1464
+ Effect.scoped
1465
+ ),
1466
+ "betaModelsList": (options) =>
1467
+ HttpClientRequest.make("GET")(`/v1/models?beta=true`).pipe(
1468
+ HttpClientRequest.setUrlParams({
1469
+ "before_id": options["before_id"],
1470
+ "after_id": options["after_id"],
1471
+ "limit": options["limit"]
1472
+ }),
1473
+ HttpClientRequest.setHeaders({
1474
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1475
+ "x-api-key": options["x-api-key"] ?? undefined
1476
+ }),
1477
+ Effect.succeed,
1478
+ Effect.flatMap((request) =>
1479
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1480
+ Effect.flatMap(
1481
+ httpClient.execute(request),
1482
+ HttpClientResponse.matchStatus({
1483
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaListResponseModelInfo)(r),
1484
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1485
+ orElse: (response) => unexpectedStatus(request, response)
1486
+ })
1487
+ ))
1488
+ ),
1489
+ Effect.scoped
1490
+ ),
1491
+ "betaModelsGet": (modelId, options) =>
1492
+ HttpClientRequest.make("GET")(`/v1/models/${modelId}?beta=true`).pipe(
1493
+ HttpClientRequest.setHeaders({
1494
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1495
+ "x-api-key": options["x-api-key"] ?? undefined
1496
+ }),
1497
+ Effect.succeed,
1498
+ Effect.flatMap((request) =>
1499
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1500
+ Effect.flatMap(
1501
+ httpClient.execute(request),
1502
+ HttpClientResponse.matchStatus({
1503
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaModelInfo)(r),
1504
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1505
+ orElse: (response) => unexpectedStatus(request, response)
1506
+ })
1507
+ ))
1508
+ ),
1509
+ Effect.scoped
1510
+ ),
1511
+ "betaMessageBatchesList": (options) =>
1512
+ HttpClientRequest.make("GET")(`/v1/messages/batches?beta=true`).pipe(
1513
+ HttpClientRequest.setUrlParams({
1514
+ "before_id": options["before_id"],
1515
+ "after_id": options["after_id"],
1516
+ "limit": options["limit"]
1517
+ }),
1518
+ HttpClientRequest.setHeaders({
1519
+ "anthropic-beta": options["anthropic-beta"] ?? undefined,
1520
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1521
+ "x-api-key": options["x-api-key"] ?? undefined
1522
+ }),
1523
+ Effect.succeed,
1524
+ Effect.flatMap((request) =>
1525
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1526
+ Effect.flatMap(
1527
+ httpClient.execute(request),
1528
+ HttpClientResponse.matchStatus({
1529
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaListResponseMessageBatch)(r),
1530
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1531
+ orElse: (response) => unexpectedStatus(request, response)
1532
+ })
1533
+ ))
1534
+ ),
1535
+ Effect.scoped
1536
+ ),
1537
+ "betaMessageBatchesPost": (options) =>
1538
+ HttpClientRequest.make("POST")(`/v1/messages/batches?beta=true`).pipe(
1539
+ HttpClientRequest.setHeaders({
1540
+ "anthropic-beta": options.params["anthropic-beta"] ?? undefined,
1541
+ "anthropic-version": options.params["anthropic-version"] ?? undefined
1542
+ }),
1543
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
1544
+ Effect.flatMap((request) =>
1545
+ Effect.flatMap(applyClientTransform(httpClient), (httpClient) =>
1546
+ Effect.flatMap(
1547
+ httpClient.execute(request),
1548
+ HttpClientResponse.matchStatus({
1549
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaMessageBatch)(r),
1550
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1551
+ orElse: (response) => unexpectedStatus(request, response)
1552
+ })
1553
+ ))
1554
+ ),
1555
+ Effect.scoped
1556
+ ),
1557
+ "betaMessageBatchesRetrieve": (messageBatchId, options) =>
1558
+ HttpClientRequest.make("GET")(`/v1/messages/batches/${messageBatchId}?beta=true`).pipe(
1559
+ HttpClientRequest.setHeaders({
1560
+ "anthropic-beta": options["anthropic-beta"] ?? undefined,
1561
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1562
+ "x-api-key": options["x-api-key"] ?? undefined
1563
+ }),
1564
+ Effect.succeed,
1565
+ Effect.flatMap((request) =>
1566
+ Effect.flatMap(
1567
+ applyClientTransform(httpClient),
1568
+ (httpClient) =>
1569
+ Effect.flatMap(
1570
+ httpClient.execute(request),
1571
+ HttpClientResponse.matchStatus({
1572
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaMessageBatch)(r),
1573
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1574
+ orElse: (response) => unexpectedStatus(request, response)
1575
+ })
1576
+ )
1577
+ )
1578
+ ),
1579
+ Effect.scoped
1580
+ ),
1581
+ "betaMessageBatchesDelete": (messageBatchId, options) =>
1582
+ HttpClientRequest.make("DELETE")(`/v1/messages/batches/${messageBatchId}?beta=true`).pipe(
1583
+ HttpClientRequest.setHeaders({
1584
+ "anthropic-beta": options["anthropic-beta"] ?? undefined,
1585
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1586
+ "x-api-key": options["x-api-key"] ?? undefined
1587
+ }),
1588
+ Effect.succeed,
1589
+ Effect.flatMap((request) =>
1590
+ Effect.flatMap(
1591
+ applyClientTransform(httpClient),
1592
+ (httpClient) =>
1593
+ Effect.flatMap(
1594
+ httpClient.execute(request),
1595
+ HttpClientResponse.matchStatus({
1596
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaDeleteMessageBatchResponse)(r),
1597
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1598
+ orElse: (response) => unexpectedStatus(request, response)
1599
+ })
1600
+ )
1601
+ )
1602
+ ),
1603
+ Effect.scoped
1604
+ ),
1605
+ "betaMessageBatchesCancel": (messageBatchId, options) =>
1606
+ HttpClientRequest.make("POST")(`/v1/messages/batches/${messageBatchId}/cancel?beta=true`).pipe(
1607
+ HttpClientRequest.setHeaders({
1608
+ "anthropic-beta": options["anthropic-beta"] ?? undefined,
1609
+ "anthropic-version": options["anthropic-version"] ?? undefined
1610
+ }),
1611
+ Effect.succeed,
1612
+ Effect.flatMap((request) =>
1613
+ Effect.flatMap(
1614
+ applyClientTransform(httpClient),
1615
+ (httpClient) =>
1616
+ Effect.flatMap(
1617
+ httpClient.execute(request),
1618
+ HttpClientResponse.matchStatus({
1619
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaMessageBatch)(r),
1620
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1621
+ orElse: (response) => unexpectedStatus(request, response)
1622
+ })
1623
+ )
1624
+ )
1625
+ ),
1626
+ Effect.scoped
1627
+ ),
1628
+ "betaMessageBatchesResults": (messageBatchId, options) =>
1629
+ HttpClientRequest.make("GET")(`/v1/messages/batches/${messageBatchId}/results?beta=true`).pipe(
1630
+ HttpClientRequest.setHeaders({
1631
+ "anthropic-beta": options["anthropic-beta"] ?? undefined,
1632
+ "anthropic-version": options["anthropic-version"] ?? undefined,
1633
+ "x-api-key": options["x-api-key"] ?? undefined
1634
+ }),
1635
+ Effect.succeed,
1636
+ Effect.flatMap((request) =>
1637
+ Effect.flatMap(
1638
+ applyClientTransform(httpClient),
1639
+ (httpClient) =>
1640
+ Effect.flatMap(
1641
+ httpClient.execute(request),
1642
+ HttpClientResponse.matchStatus({
1643
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1644
+ orElse: (response) => unexpectedStatus(request, response)
1645
+ })
1646
+ )
1647
+ )
1648
+ ),
1649
+ Effect.scoped
1650
+ ),
1651
+ "betaMessagesCountTokensPost": (options) =>
1652
+ HttpClientRequest.make("POST")(`/v1/messages/count_tokens?beta=true`).pipe(
1653
+ HttpClientRequest.setHeaders({
1654
+ "anthropic-beta": options.params["anthropic-beta"] ?? undefined,
1655
+ "anthropic-version": options.params["anthropic-version"] ?? undefined
1656
+ }),
1657
+ (req) => Effect.orDie(HttpClientRequest.bodyJson(req, options.payload)),
1658
+ Effect.flatMap((request) =>
1659
+ Effect.flatMap(
1660
+ applyClientTransform(httpClient),
1661
+ (httpClient) =>
1662
+ Effect.flatMap(
1663
+ httpClient.execute(request),
1664
+ HttpClientResponse.matchStatus({
1665
+ "200": (r) => HttpClientResponse.schemaBodyJson(BetaCountMessageTokensResponse)(r),
1666
+ "NaN": (r) => decodeError(r, BetaErrorResponse),
1667
+ orElse: (response) => unexpectedStatus(request, response)
1668
+ })
1669
+ )
1670
+ )
1671
+ ),
1672
+ Effect.scoped
1673
+ )
1674
+ }
1675
+ }
1676
+
1677
+ export interface Client {
1678
+ readonly "messagesPost": (
1679
+ options: {
1680
+ readonly params: typeof MessagesPostParams.Encoded
1681
+ readonly payload: typeof CreateMessageParams.Encoded
1682
+ }
1683
+ ) => Effect.Effect<typeof Message.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
1684
+ readonly "completePost": (
1685
+ options: { readonly params: typeof CompletePostParams.Encoded; readonly payload: typeof CompletionRequest.Encoded }
1686
+ ) => Effect.Effect<
1687
+ typeof CompletionResponse.Type,
1688
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
1689
+ >
1690
+ readonly "modelsList": (
1691
+ options: typeof ModelsListParams.Encoded
1692
+ ) => Effect.Effect<
1693
+ typeof ListResponseModelInfo.Type,
1694
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
1695
+ >
1696
+ readonly "modelsGet": (
1697
+ modelId: string,
1698
+ options: typeof ModelsGetParams.Encoded
1699
+ ) => Effect.Effect<typeof ModelInfo.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
1700
+ readonly "messageBatchesList": (
1701
+ options: typeof MessageBatchesListParams.Encoded
1702
+ ) => Effect.Effect<
1703
+ typeof ListResponseMessageBatch.Type,
1704
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
1705
+ >
1706
+ readonly "messageBatchesPost": (
1707
+ options: {
1708
+ readonly params: typeof MessageBatchesPostParams.Encoded
1709
+ readonly payload: typeof CreateMessageBatchParams.Encoded
1710
+ }
1711
+ ) => Effect.Effect<typeof MessageBatch.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
1712
+ readonly "messageBatchesRetrieve": (
1713
+ messageBatchId: string,
1714
+ options: typeof MessageBatchesRetrieveParams.Encoded
1715
+ ) => Effect.Effect<typeof MessageBatch.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
1716
+ readonly "messageBatchesDelete": (
1717
+ messageBatchId: string,
1718
+ options: typeof MessageBatchesDeleteParams.Encoded
1719
+ ) => Effect.Effect<
1720
+ typeof DeleteMessageBatchResponse.Type,
1721
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
1722
+ >
1723
+ readonly "messageBatchesCancel": (
1724
+ messageBatchId: string,
1725
+ options: typeof MessageBatchesCancelParams.Encoded
1726
+ ) => Effect.Effect<typeof MessageBatch.Type, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
1727
+ readonly "messageBatchesResults": (
1728
+ messageBatchId: string,
1729
+ options: typeof MessageBatchesResultsParams.Encoded
1730
+ ) => Effect.Effect<void, HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type>
1731
+ readonly "messagesCountTokensPost": (
1732
+ options: {
1733
+ readonly params: typeof MessagesCountTokensPostParams.Encoded
1734
+ readonly payload: typeof CountMessageTokensParams.Encoded
1735
+ }
1736
+ ) => Effect.Effect<
1737
+ typeof CountMessageTokensResponse.Type,
1738
+ HttpClientError.HttpClientError | ParseError | typeof ErrorResponse.Type
1739
+ >
1740
+ readonly "betaMessagesPost": (
1741
+ options: {
1742
+ readonly params: typeof BetaMessagesPostParams.Encoded
1743
+ readonly payload: typeof BetaCreateMessageParams.Encoded
1744
+ }
1745
+ ) => Effect.Effect<
1746
+ typeof BetaMessage.Type,
1747
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1748
+ >
1749
+ readonly "betaModelsList": (
1750
+ options: typeof BetaModelsListParams.Encoded
1751
+ ) => Effect.Effect<
1752
+ typeof BetaListResponseModelInfo.Type,
1753
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1754
+ >
1755
+ readonly "betaModelsGet": (
1756
+ modelId: string,
1757
+ options: typeof BetaModelsGetParams.Encoded
1758
+ ) => Effect.Effect<
1759
+ typeof BetaModelInfo.Type,
1760
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1761
+ >
1762
+ readonly "betaMessageBatchesList": (
1763
+ options: typeof BetaMessageBatchesListParams.Encoded
1764
+ ) => Effect.Effect<
1765
+ typeof BetaListResponseMessageBatch.Type,
1766
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1767
+ >
1768
+ readonly "betaMessageBatchesPost": (
1769
+ options: {
1770
+ readonly params: typeof BetaMessageBatchesPostParams.Encoded
1771
+ readonly payload: typeof BetaCreateMessageBatchParams.Encoded
1772
+ }
1773
+ ) => Effect.Effect<
1774
+ typeof BetaMessageBatch.Type,
1775
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1776
+ >
1777
+ readonly "betaMessageBatchesRetrieve": (
1778
+ messageBatchId: string,
1779
+ options: typeof BetaMessageBatchesRetrieveParams.Encoded
1780
+ ) => Effect.Effect<
1781
+ typeof BetaMessageBatch.Type,
1782
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1783
+ >
1784
+ readonly "betaMessageBatchesDelete": (
1785
+ messageBatchId: string,
1786
+ options: typeof BetaMessageBatchesDeleteParams.Encoded
1787
+ ) => Effect.Effect<
1788
+ typeof BetaDeleteMessageBatchResponse.Type,
1789
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1790
+ >
1791
+ readonly "betaMessageBatchesCancel": (
1792
+ messageBatchId: string,
1793
+ options: typeof BetaMessageBatchesCancelParams.Encoded
1794
+ ) => Effect.Effect<
1795
+ typeof BetaMessageBatch.Type,
1796
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1797
+ >
1798
+ readonly "betaMessageBatchesResults": (
1799
+ messageBatchId: string,
1800
+ options: typeof BetaMessageBatchesResultsParams.Encoded
1801
+ ) => Effect.Effect<void, HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type>
1802
+ readonly "betaMessagesCountTokensPost": (
1803
+ options: {
1804
+ readonly params: typeof BetaMessagesCountTokensPostParams.Encoded
1805
+ readonly payload: typeof BetaCountMessageTokensParams.Encoded
1806
+ }
1807
+ ) => Effect.Effect<
1808
+ typeof BetaCountMessageTokensResponse.Type,
1809
+ HttpClientError.HttpClientError | ParseError | typeof BetaErrorResponse.Type
1810
+ >
1811
+ }