@anthropic-ai/sdk 0.10.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +9 -9
  3. package/error.d.ts.map +1 -1
  4. package/error.js +2 -1
  5. package/error.js.map +1 -1
  6. package/error.mjs +2 -1
  7. package/error.mjs.map +1 -1
  8. package/index.d.mts +9 -5
  9. package/index.d.ts +9 -5
  10. package/index.d.ts.map +1 -1
  11. package/index.js +7 -5
  12. package/index.js.map +1 -1
  13. package/index.mjs +7 -5
  14. package/index.mjs.map +1 -1
  15. package/lib/MessageStream.d.ts +94 -0
  16. package/lib/MessageStream.d.ts.map +1 -0
  17. package/lib/MessageStream.js +421 -0
  18. package/lib/MessageStream.js.map +1 -0
  19. package/lib/MessageStream.mjs +417 -0
  20. package/lib/MessageStream.mjs.map +1 -0
  21. package/package.json +3 -2
  22. package/resources/beta/beta.d.ts +25 -0
  23. package/resources/beta/beta.d.ts.map +1 -0
  24. package/resources/beta/beta.js +40 -0
  25. package/resources/beta/beta.js.map +1 -0
  26. package/resources/beta/beta.mjs +13 -0
  27. package/resources/beta/beta.mjs.map +1 -0
  28. package/resources/beta/index.d.ts +3 -0
  29. package/resources/beta/index.d.ts.map +1 -0
  30. package/resources/beta/index.js +9 -0
  31. package/resources/beta/index.js.map +1 -0
  32. package/resources/beta/index.mjs +4 -0
  33. package/resources/beta/index.mjs.map +1 -0
  34. package/resources/beta/messages.d.ts +511 -0
  35. package/resources/beta/messages.d.ts.map +1 -0
  36. package/resources/beta/messages.js +35 -0
  37. package/resources/beta/messages.js.map +1 -0
  38. package/resources/beta/messages.mjs +30 -0
  39. package/resources/beta/messages.mjs.map +1 -0
  40. package/resources/completions.d.ts +55 -40
  41. package/resources/completions.d.ts.map +1 -1
  42. package/resources/completions.js +4 -2
  43. package/resources/completions.js.map +1 -1
  44. package/resources/completions.mjs +4 -2
  45. package/resources/completions.mjs.map +1 -1
  46. package/resources/index.d.ts +1 -0
  47. package/resources/index.d.ts.map +1 -1
  48. package/resources/index.js +3 -1
  49. package/resources/index.js.map +1 -1
  50. package/resources/index.mjs +1 -0
  51. package/resources/index.mjs.map +1 -1
  52. package/src/error.ts +2 -1
  53. package/src/index.ts +11 -5
  54. package/src/lib/MessageStream.ts +515 -0
  55. package/src/resources/beta/beta.ts +28 -0
  56. package/src/resources/beta/index.ts +22 -0
  57. package/src/resources/beta/messages.ts +605 -0
  58. package/src/resources/completions.ts +62 -42
  59. package/src/resources/index.ts +1 -0
  60. package/src/streaming.ts +21 -1
  61. package/src/uploads.ts +2 -3
  62. package/src/version.ts +1 -1
  63. package/streaming.d.ts.map +1 -1
  64. package/streaming.js +15 -0
  65. package/streaming.js.map +1 -1
  66. package/streaming.mjs +15 -0
  67. package/streaming.mjs.map +1 -1
  68. package/uploads.d.ts.map +1 -1
  69. package/uploads.js +2 -1
  70. package/uploads.js.map +1 -1
  71. package/uploads.mjs +2 -1
  72. package/uploads.mjs.map +1 -1
  73. package/version.d.ts +1 -1
  74. package/version.js +1 -1
  75. package/version.mjs +1 -1
@@ -0,0 +1,511 @@
1
+ import * as Core from '@anthropic-ai/sdk/core';
2
+ import { APIPromise } from '@anthropic-ai/sdk/core';
3
+ import { APIResource } from '@anthropic-ai/sdk/resource';
4
+ import { MessageStream } from '@anthropic-ai/sdk/lib/MessageStream';
5
+ export { MessageStream } from '@anthropic-ai/sdk/lib/MessageStream';
6
+ import * as MessagesAPI from '@anthropic-ai/sdk/resources/beta/messages';
7
+ import { Stream } from '@anthropic-ai/sdk/streaming';
8
+ export declare class Messages extends APIResource {
9
+ /**
10
+ * Create a Message.
11
+ *
12
+ * The Messages API is currently in beta.
13
+ */
14
+ create(params: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Message>;
15
+ create(params: MessageCreateParamsStreaming, options?: Core.RequestOptions): APIPromise<Stream<MessageStreamEvent>>;
16
+ create(params: MessageCreateParamsBase, options?: Core.RequestOptions): APIPromise<Stream<MessageStreamEvent> | Message>;
17
+ /**
18
+ * Create a Message stream
19
+ */
20
+ stream(body: MessageStreamParams, options?: Core.RequestOptions): MessageStream;
21
+ }
22
+ export interface ContentBlock {
23
+ text: string;
24
+ type: 'text';
25
+ }
26
+ export interface ContentBlockDeltaEvent {
27
+ delta: TextDelta;
28
+ index: number;
29
+ type: 'content_block_delta';
30
+ }
31
+ export interface ContentBlockStartEvent {
32
+ content_block: ContentBlock;
33
+ index: number;
34
+ type: 'content_block_start';
35
+ }
36
+ export interface ContentBlockStopEvent {
37
+ index: number;
38
+ type: 'content_block_stop';
39
+ }
40
+ export interface Message {
41
+ /**
42
+ * Unique object identifier.
43
+ *
44
+ * The format and length of IDs may change over time.
45
+ */
46
+ id: string;
47
+ /**
48
+ * Content generated by the model.
49
+ *
50
+ * This is an array of content blocks, each of which has a `type` that determines
51
+ * its shape. Currently, the only `type` available is `"text"`.
52
+ *
53
+ * Example:
54
+ *
55
+ * ```json
56
+ * [{ "type": "text", "text": "Hi, I'm Claude." }]
57
+ * ```
58
+ *
59
+ * If the request input `messages` ended with an `assistant` turn, then the
60
+ * response `content` will continue directly from that last turn. You can use this
61
+ * to constrain the model's output.
62
+ *
63
+ * For example, if the input `messages` were:
64
+ *
65
+ * ```json
66
+ * [
67
+ * {
68
+ * "role": "user",
69
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
70
+ * },
71
+ * {
72
+ * "role": "assistant",
73
+ * "content": "The best answer is ("
74
+ * }
75
+ * ]
76
+ * ```
77
+ *
78
+ * Then the response `content` might be:
79
+ *
80
+ * ```json
81
+ * [{ "type": "text", "text": "B)" }]
82
+ * ```
83
+ */
84
+ content: Array<ContentBlock>;
85
+ /**
86
+ * The model that handled the request.
87
+ */
88
+ model: string;
89
+ /**
90
+ * Conversational role of the generated message.
91
+ *
92
+ * This will always be `"assistant"`.
93
+ */
94
+ role: 'assistant';
95
+ /**
96
+ * The reason that we stopped.
97
+ *
98
+ * This may be one the following values:
99
+ *
100
+ * - `"end_turn"`: the model reached a natural stopping point
101
+ * - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
102
+ * - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
103
+ *
104
+ * Note that these values are different than those in `/v1/complete`, where
105
+ * `end_turn` and `stop_sequence` were not differentiated.
106
+ *
107
+ * In non-streaming mode this value is always non-null. In streaming mode, it is
108
+ * null in the `message_start` event and non-null otherwise.
109
+ */
110
+ stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | null;
111
+ /**
112
+ * Which custom stop sequence was generated.
113
+ *
114
+ * This value will be non-null if one of your custom stop sequences was generated.
115
+ */
116
+ stop_sequence: string | null;
117
+ type: 'message';
118
+ }
119
+ export interface MessageDeltaEvent {
120
+ delta: MessageDeltaEvent.Delta;
121
+ type: 'message_delta';
122
+ }
123
+ export declare namespace MessageDeltaEvent {
124
+ interface Delta {
125
+ stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | null;
126
+ stop_sequence: string | null;
127
+ }
128
+ }
129
+ export interface MessageParam {
130
+ content: string | Array<TextBlock>;
131
+ role: 'user' | 'assistant';
132
+ }
133
+ export interface MessageStartEvent {
134
+ message: Message;
135
+ type: 'message_start';
136
+ }
137
+ export interface MessageStopEvent {
138
+ type: 'message_stop';
139
+ }
140
+ export type MessageStreamEvent = MessageStartEvent | MessageDeltaEvent | MessageStopEvent | ContentBlockStartEvent | ContentBlockDeltaEvent | ContentBlockStopEvent;
141
+ export interface TextBlock {
142
+ text: string;
143
+ type?: 'text';
144
+ }
145
+ export interface TextDelta {
146
+ text: string;
147
+ type: 'text_delta';
148
+ }
149
+ export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
150
+ export interface MessageCreateParamsBase {
151
+ /**
152
+ * Body param: The maximum number of tokens to generate before stopping.
153
+ *
154
+ * Note that our models may stop _before_ reaching this maximum. This parameter
155
+ * only specifies the absolute maximum number of tokens to generate.
156
+ *
157
+ * Different models have different maximum values for this parameter. See
158
+ * [input and output sizes](https://docs.anthropic.com/claude/reference/input-and-output-sizes)
159
+ * for details.
160
+ */
161
+ max_tokens: number;
162
+ /**
163
+ * Body param: Input messages.
164
+ *
165
+ * Our models are trained to operate on alternating `user` and `assistant`
166
+ * conversational turns. When creating a new `Message`, you specify the prior
167
+ * conversational turns with the `messages` parameter, and the model then generates
168
+ * the next `Message` in the conversation.
169
+ *
170
+ * Each input message must be an object with a `role` and `content`. You can
171
+ * specify a single `user`-role message, or you can include multiple `user` and
172
+ * `assistant` messages. The first message must always use the `user` role.
173
+ *
174
+ * If the final message uses the `assistant` role, the response content will
175
+ * continue immediately from the content in that message. This can be used to
176
+ * constrain part of the model's response.
177
+ *
178
+ * Example with a single `user` message:
179
+ *
180
+ * ```json
181
+ * [{ "role": "user", "content": "Hello, Claude" }]
182
+ * ```
183
+ *
184
+ * Example with multiple conversational turns:
185
+ *
186
+ * ```json
187
+ * [
188
+ * { "role": "user", "content": "Hello there." },
189
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
190
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
191
+ * ]
192
+ * ```
193
+ *
194
+ * Example with a partially-filled response from Claude:
195
+ *
196
+ * ```json
197
+ * [
198
+ * { "role": "user", "content": "Please describe yourself using only JSON" },
199
+ * { "role": "assistant", "content": "Here is my JSON description:\n{" }
200
+ * ]
201
+ * ```
202
+ *
203
+ * Each input message `content` may be either a single `string` or an array of
204
+ * content blocks, where each block has a specific `type`. Using a `string` is
205
+ * shorthand for an array of one content block of type `"text"`. The following
206
+ * input messages are equivalent:
207
+ *
208
+ * ```json
209
+ * { "role": "user", "content": "Hello, Claude" }
210
+ * ```
211
+ *
212
+ * ```json
213
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
214
+ * ```
215
+ *
216
+ * During beta, the Messages API only accepts content blocks of type `"text"`, and
217
+ * at most one block per message.
218
+ *
219
+ * See our
220
+ * [guide to prompt design](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
221
+ * for more details on how to best construct prompts.
222
+ */
223
+ messages: Array<MessageParam>;
224
+ /**
225
+ * Body param: The model that will complete your prompt.
226
+ *
227
+ * As we improve Claude, we develop new versions of it that you can query. The
228
+ * `model` parameter controls which version of Claude responds to your request.
229
+ * Right now we offer two model families: Claude, and Claude Instant. You can use
230
+ * them by setting `model` to `"claude-2.1"` or `"claude-instant-1.2"`,
231
+ * respectively.
232
+ *
233
+ * See [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
234
+ * additional details and options.
235
+ */
236
+ model: string;
237
+ /**
238
+ * Header param: Beta version header.
239
+ *
240
+ * During the beta, the Messages API requires sending the
241
+ * `anthropic-beta: messages-2023-12-15` header. This is a beta-specific header
242
+ * that is required in addition to the normal `anthropic-version` header. If you
243
+ * are using our SDKs, both of these headers will be sent automatically.
244
+ */
245
+ 'anthropic-beta': string;
246
+ /**
247
+ * Body param: An object describing metadata about the request.
248
+ */
249
+ metadata?: MessageCreateParams.Metadata;
250
+ /**
251
+ * Body param: Custom text sequences that will cause the model to stop generating.
252
+ *
253
+ * Our models will normally stop when they have naturally completed their turn,
254
+ * which will result in a response `stop_reason` of `"end_turn"`.
255
+ *
256
+ * If you want the model to stop generating when it encounters custom strings of
257
+ * text, you can use the `stop_sequences` parameter. If the model encounters one of
258
+ * the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
259
+ * and the response `stop_sequence` value will contain the matched stop sequence.
260
+ */
261
+ stop_sequences?: Array<string>;
262
+ /**
263
+ * Body param: Whether to incrementally stream the response using server-sent
264
+ * events.
265
+ *
266
+ * See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
267
+ * details.
268
+ */
269
+ stream?: boolean;
270
+ /**
271
+ * Body param: System prompt.
272
+ *
273
+ * A system prompt is a way of providing context and instructions to Claude, such
274
+ * as specifying a particular goal or role. See our
275
+ * [guide to system prompts](https://docs.anthropic.com/claude/docs/how-to-use-system-prompts).
276
+ */
277
+ system?: string;
278
+ /**
279
+ * Body param: Amount of randomness injected into the response.
280
+ *
281
+ * Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
282
+ * multiple choice, and closer to 1 for creative and generative tasks.
283
+ */
284
+ temperature?: number;
285
+ /**
286
+ * Body param: Only sample from the top K options for each subsequent token.
287
+ *
288
+ * Used to remove "long tail" low probability responses.
289
+ * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
290
+ */
291
+ top_k?: number;
292
+ /**
293
+ * Body param: Use nucleus sampling.
294
+ *
295
+ * In nucleus sampling, we compute the cumulative distribution over all the options
296
+ * for each subsequent token in decreasing probability order and cut it off once it
297
+ * reaches a particular probability specified by `top_p`. You should either alter
298
+ * `temperature` or `top_p`, but not both.
299
+ */
300
+ top_p?: number;
301
+ /**
302
+ * Header param:
303
+ */
304
+ 'x-api-key'?: string;
305
+ }
306
+ export declare namespace MessageCreateParams {
307
+ /**
308
+ * An object describing metadata about the request.
309
+ */
310
+ interface Metadata {
311
+ /**
312
+ * An external identifier for the user who is associated with the request.
313
+ *
314
+ * This should be a uuid, hash value, or other opaque identifier. Anthropic may use
315
+ * this id to help detect abuse. Do not include any identifying information such as
316
+ * name, email address, or phone number.
317
+ */
318
+ user_id?: string;
319
+ }
320
+ type MessageCreateParamsNonStreaming = MessagesAPI.MessageCreateParamsNonStreaming;
321
+ type MessageCreateParamsStreaming = MessagesAPI.MessageCreateParamsStreaming;
322
+ }
323
+ export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase {
324
+ /**
325
+ * Body param: Whether to incrementally stream the response using server-sent
326
+ * events.
327
+ *
328
+ * See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
329
+ * details.
330
+ */
331
+ stream?: false;
332
+ }
333
+ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
334
+ /**
335
+ * Body param: Whether to incrementally stream the response using server-sent
336
+ * events.
337
+ *
338
+ * See [streaming](https://docs.anthropic.com/claude/reference/streaming) for
339
+ * details.
340
+ */
341
+ stream: true;
342
+ }
343
+ export interface MessageStreamParams {
344
+ /**
345
+ * The maximum number of tokens to generate before stopping.
346
+ *
347
+ * Note that our models may stop _before_ reaching this maximum. This parameter
348
+ * only specifies the absolute maximum number of tokens to generate.
349
+ *
350
+ * Different models have different maximum values for this parameter. See
351
+ * [input and output sizes](https://docs.anthropic.com/claude/reference/input-and-output-sizes)
352
+ * for details.
353
+ */
354
+ max_tokens: number;
355
+ /**
356
+ * Input messages.
357
+ *
358
+ * Our models are trained to operate on alternating `user` and `assistant`
359
+ * conversational turns. When creating a new `Message`, you specify the prior
360
+ * conversational turns with the `messages` parameter, and the model then generates
361
+ * the next `Message` in the conversation.
362
+ *
363
+ * Each input message must be an object with a `role` and `content`. You can
364
+ * specify a single `user`-role message, or you can include multiple `user` and
365
+ * `assistant` messages. The first message must always use the `user` role.
366
+ *
367
+ * If the final message uses the `assistant` role, the response content will
368
+ * continue immediately from the content in that message. This can be used to
369
+ * constrain part of the model's response.
370
+ *
371
+ * Example with a single `user` message:
372
+ *
373
+ * ```json
374
+ * [{ "role": "user", "content": "Hello, Claude" }]
375
+ * ```
376
+ *
377
+ * Example with multiple conversational turns:
378
+ *
379
+ * ```json
380
+ * [
381
+ * { "role": "user", "content": "Hello there." },
382
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
383
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
384
+ * ]
385
+ * ```
386
+ *
387
+ * Example with a partially-filled response from Claude:
388
+ *
389
+ * ```json
390
+ * [
391
+ * { "role": "user", "content": "Please describe yourself using only JSON" },
392
+ * { "role": "assistant", "content": "Here is my JSON description:\n{" }
393
+ * ]
394
+ * ```
395
+ *
396
+ * Each input message `content` may be either a single `string` or an array of
397
+ * content blocks, where each block has a specific `type`. Using a `string` is
398
+ * shorthand for an array of one content block of type `"text"`. The following
399
+ * input messages are equivalent:
400
+ *
401
+ * ```json
402
+ * { "role": "user", "content": "Hello, Claude" }
403
+ * ```
404
+ *
405
+ * ```json
406
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
407
+ * ```
408
+ *
409
+ * During beta, the Messages API only accepts content blocks of type `"text"`, and
410
+ * at most one block per message.
411
+ *
412
+ * See our
413
+ * [guide to prompt design](https://docs.anthropic.com/claude/docs/introduction-to-prompt-design)
414
+ * for more details on how to best construct prompts.
415
+ */
416
+ messages: Array<MessageParam>;
417
+ /**
418
+ * The model that will complete your prompt.
419
+ *
420
+ * As we improve Claude, we develop new versions of it that you can query. The
421
+ * `model` parameter controls which version of Claude responds to your request.
422
+ * Right now we offer two model families: Claude, and Claude Instant. You can use
423
+ * them by setting `model` to `"claude-2.1"` or `"claude-instant-1.2"`,
424
+ * respectively.
425
+ *
426
+ * See [models](https://docs.anthropic.com/claude/reference/selecting-a-model) for
427
+ * additional details and options.
428
+ */
429
+ model: string;
430
+ /**
431
+ * An object describing metadata about the request.
432
+ */
433
+ metadata?: MessageStreamParams.Metadata;
434
+ /**
435
+ * Custom text sequences that will cause the model to stop generating.
436
+ *
437
+ * Our models will normally stop when they have naturally completed their turn,
438
+ * which will result in a response `stop_reason` of `"end_turn"`.
439
+ *
440
+ * If you want the model to stop generating when it encounters custom strings of
441
+ * text, you can use the `stop_sequences` parameter. If the model encounters one of
442
+ * the custom sequences, the response `stop_reason` value will be `"stop_sequence"`
443
+ * and the response `stop_sequence` value will contain the matched stop sequence.
444
+ */
445
+ stop_sequences?: Array<string>;
446
+ /**
447
+ * System prompt.
448
+ *
449
+ * A system prompt is a way of providing context and instructions to Claude, such
450
+ * as specifying a particular goal or role. See our
451
+ * [guide to system prompts](https://docs.anthropic.com/claude/docs/how-to-use-system-prompts).
452
+ */
453
+ system?: string;
454
+ /**
455
+ * Amount of randomness injected into the response.
456
+ *
457
+ * Defaults to 1. Ranges from 0 to 1. Use temp closer to 0 for analytical /
458
+ * multiple choice, and closer to 1 for creative and generative tasks.
459
+ */
460
+ temperature?: number;
461
+ /**
462
+ * Only sample from the top K options for each subsequent token.
463
+ *
464
+ * Used to remove "long tail" low probability responses.
465
+ * [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).
466
+ */
467
+ top_k?: number;
468
+ /**
469
+ * Use nucleus sampling.
470
+ *
471
+ * In nucleus sampling, we compute the cumulative distribution over all the options
472
+ * for each subsequent token in decreasing probability order and cut it off once it
473
+ * reaches a particular probability specified by `top_p`. You should either alter
474
+ * `temperature` or `top_p`, but not both.
475
+ */
476
+ top_p?: number;
477
+ }
478
+ export declare namespace MessageStreamParams {
479
+ /**
480
+ * An object describing metadata about the request.
481
+ */
482
+ interface Metadata {
483
+ /**
484
+ * An external identifier for the user who is associated with the request.
485
+ *
486
+ * This should be a uuid, hash value, or other opaque identifier. Anthropic may use
487
+ * this id to help detect abuse. Do not include any identifying information such as
488
+ * name, email address, or phone number.
489
+ */
490
+ user_id?: string;
491
+ }
492
+ }
493
+ export declare namespace Messages {
494
+ export import ContentBlock = MessagesAPI.ContentBlock;
495
+ export import ContentBlockDeltaEvent = MessagesAPI.ContentBlockDeltaEvent;
496
+ export import ContentBlockStartEvent = MessagesAPI.ContentBlockStartEvent;
497
+ export import ContentBlockStopEvent = MessagesAPI.ContentBlockStopEvent;
498
+ export import Message = MessagesAPI.Message;
499
+ export import MessageDeltaEvent = MessagesAPI.MessageDeltaEvent;
500
+ export import MessageParam = MessagesAPI.MessageParam;
501
+ export import MessageStartEvent = MessagesAPI.MessageStartEvent;
502
+ export import MessageStopEvent = MessagesAPI.MessageStopEvent;
503
+ export import MessageStreamEvent = MessagesAPI.MessageStreamEvent;
504
+ export import TextBlock = MessagesAPI.TextBlock;
505
+ export import TextDelta = MessagesAPI.TextDelta;
506
+ export import MessageCreateParams = MessagesAPI.MessageCreateParams;
507
+ export import MessageCreateParamsNonStreaming = MessagesAPI.MessageCreateParamsNonStreaming;
508
+ export import MessageCreateParamsStreaming = MessagesAPI.MessageCreateParamsStreaming;
509
+ export import MessageStreamParams = MessagesAPI.MessageStreamParams;
510
+ }
511
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/resources/beta/messages.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,WAAW,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,+BAA+B,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;IACnG,MAAM,CACJ,MAAM,EAAE,4BAA4B,EACpC,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;IACzC,MAAM,CACJ,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAC5B,UAAU,CAAC,MAAM,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC;IAoBnD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,cAAc,GAAG,aAAa;CAGhF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IAEb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,SAAS,CAAC;IAEjB,KAAK,EAAE,MAAM,C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AsB,GAAG,WAAW,CAAC,sBAAsB,CAAC;IAC1E,MAAM,QAAQ,sBAAsB,GAAG,WAAW,CAAC,sBAAsB,CAAC;IAC1E,MAAM,QAAQ,qBAAqB,GAAG,WAAW,CAAC,qBAAqB,CAAC;IACxE,MAAM,QAAQ,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAC5C,MAAM,QAAQ,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;IAChE,MAAM,QAAQ,YAAY,GAAG,WAAW,CAAC,YAAY,CAAC;IACtD,MAAM,QAAQ,iBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;IAChE,MAAM,QAAQ,gBAAgB,GAAG,WAAW,CAAC,gBAAgB,CAAC;IAC9D,MAAM,QAAQ,kBAAkB,GAAG,WAAW,CAAC,kBAAkB,CAAC;IAClE,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IAChD,MAAM,QAAQ,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IAChD,MAAM,QAAQ,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC;IACpE,MAAM,QAAQ,+BAA+B,GAAG,WAAW,CAAC,+BAA+B,CAAC;IAC5F,MAAM,QAAQ,4BAA4B,GAAG,WAAW,CAAC,4BAA4B,CAAC;IACtF,MAAM,QAAQ,mBAAmB,GAAG,WAAW,CAAC,mBAAmB,CAAC;CACrE"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Messages = exports.MessageStream = void 0;
5
+ const resource_1 = require("@anthropic-ai/sdk/resource");
6
+ const MessageStream_1 = require("@anthropic-ai/sdk/lib/MessageStream");
7
+ var MessageStream_2 = require("@anthropic-ai/sdk/lib/MessageStream");
8
+ Object.defineProperty(exports, "MessageStream", { enumerable: true, get: function () { return MessageStream_2.MessageStream; } });
9
+ class Messages extends resource_1.APIResource {
10
+ create(params, options) {
11
+ const { 'anthropic-beta': anthropicBeta, 'x-api-key': xAPIKey, ...body } = params;
12
+ return this._client.post('/v1/messages', {
13
+ body,
14
+ timeout: 600000,
15
+ ...options,
16
+ headers: {
17
+ 'Anthropic-Beta': 'messages-2023-12-15',
18
+ 'anthropic-beta': anthropicBeta,
19
+ 'x-api-key': xAPIKey || '',
20
+ ...options?.headers,
21
+ },
22
+ stream: params.stream ?? false,
23
+ });
24
+ }
25
+ /**
26
+ * Create a Message stream
27
+ */
28
+ stream(body, options) {
29
+ return MessageStream_1.MessageStream.createMessage(this._client.beta.messages, body, options);
30
+ }
31
+ }
32
+ exports.Messages = Messages;
33
+ (function (Messages) {
34
+ })(Messages = exports.Messages || (exports.Messages = {}));
35
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/beta/messages.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAIrD,yDAAyD;AACzD,uEAAoE;AACpE,qEAAoE;AAA3D,8GAAA,aAAa,OAAA;AAItB,MAAa,QAAS,SAAQ,sBAAW;IAevC,MAAM,CACJ,MAA2B,EAC3B,OAA6B;QAE7B,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAClF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,OAAO,EAAE;gBACP,gBAAgB,EAAE,qBAAqB;gBACvC,gBAAgB,EAAE,aAAa;gBAC/B,WAAW,EAAE,OAAO,IAAI,EAAE;gBAC1B,GAAG,OAAO,EAAE,OAAO;aACpB;YACD,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;SAC/B,CAAiE,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,6BAAa,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChF,CAAC;CACF;AAxCD,4BAwCC;AAyhBD,WAAiB,QAAQ;AAiBzB,CAAC,EAjBgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAiBxB"}
@@ -0,0 +1,30 @@
1
+ // File generated from our OpenAPI spec by Stainless.
2
+ import { APIResource } from '@anthropic-ai/sdk/resource';
3
+ import { MessageStream } from '@anthropic-ai/sdk/lib/MessageStream';
4
+ export { MessageStream } from '@anthropic-ai/sdk/lib/MessageStream';
5
+ export class Messages extends APIResource {
6
+ create(params, options) {
7
+ const { 'anthropic-beta': anthropicBeta, 'x-api-key': xAPIKey, ...body } = params;
8
+ return this._client.post('/v1/messages', {
9
+ body,
10
+ timeout: 600000,
11
+ ...options,
12
+ headers: {
13
+ 'Anthropic-Beta': 'messages-2023-12-15',
14
+ 'anthropic-beta': anthropicBeta,
15
+ 'x-api-key': xAPIKey || '',
16
+ ...options?.headers,
17
+ },
18
+ stream: params.stream ?? false,
19
+ });
20
+ }
21
+ /**
22
+ * Create a Message stream
23
+ */
24
+ stream(body, options) {
25
+ return MessageStream.createMessage(this._client.beta.messages, body, options);
26
+ }
27
+ }
28
+ (function (Messages) {
29
+ })(Messages || (Messages = {}));
30
+ //# sourceMappingURL=messages.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.mjs","sourceRoot":"","sources":["../../src/resources/beta/messages.ts"],"names":[],"mappings":"AAAA,qDAAqD;OAI9C,EAAE,WAAW,EAAE,MAAM,4BAA4B;OACjD,EAAE,aAAa,EAAE,MAAM,qCAAqC;OAC5D,EAAE,aAAa,EAAE,MAAM,qCAAqC;AAInE,MAAM,OAAO,QAAS,SAAQ,WAAW;IAevC,MAAM,CACJ,MAA2B,EAC3B,OAA6B;QAE7B,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;QAClF,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE;YACvC,IAAI;YACJ,OAAO,EAAE,MAAM;YACf,GAAG,OAAO;YACV,OAAO,EAAE;gBACP,gBAAgB,EAAE,qBAAqB;gBACvC,gBAAgB,EAAE,aAAa;gBAC/B,WAAW,EAAE,OAAO,IAAI,EAAE;gBAC1B,GAAG,OAAO,EAAE,OAAO;aACpB;YACD,MAAM,EAAE,MAAM,CAAC,MAAM,IAAI,KAAK;SAC/B,CAAiE,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAyB,EAAE,OAA6B;QAC7D,OAAO,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChF,CAAC;CACF;AAyhBD,WAAiB,QAAQ;AAiBzB,CAAC,EAjBgB,QAAQ,KAAR,QAAQ,QAiBxB"}