@anthropic-ai/sdk 0.30.1 → 0.32.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 (101) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +3 -3
  3. package/core.d.ts +3 -3
  4. package/core.d.ts.map +1 -1
  5. package/core.js.map +1 -1
  6. package/core.mjs.map +1 -1
  7. package/error.d.ts.map +1 -1
  8. package/index.d.mts +12 -61
  9. package/index.d.ts +12 -61
  10. package/index.d.ts.map +1 -1
  11. package/index.js +22 -9
  12. package/index.js.map +1 -1
  13. package/index.mjs +9 -9
  14. package/index.mjs.map +1 -1
  15. package/package.json +2 -2
  16. package/resources/beta/beta.d.ts +6 -49
  17. package/resources/beta/beta.d.ts.map +1 -1
  18. package/resources/beta/beta.js +4 -4
  19. package/resources/beta/beta.js.map +1 -1
  20. package/resources/beta/beta.mjs +4 -4
  21. package/resources/beta/beta.mjs.map +1 -1
  22. package/resources/beta/index.d.ts +2 -2
  23. package/resources/beta/index.d.ts.map +1 -1
  24. package/resources/beta/index.js.map +1 -1
  25. package/resources/beta/index.mjs.map +1 -1
  26. package/resources/beta/messages/batches.d.ts +1 -15
  27. package/resources/beta/messages/batches.d.ts.map +1 -1
  28. package/resources/beta/messages/batches.js +1 -27
  29. package/resources/beta/messages/batches.js.map +1 -1
  30. package/resources/beta/messages/batches.mjs +1 -4
  31. package/resources/beta/messages/batches.mjs.map +1 -1
  32. package/resources/beta/messages/index.d.ts +2 -2
  33. package/resources/beta/messages/index.d.ts.map +1 -1
  34. package/resources/beta/messages/index.js +3 -3
  35. package/resources/beta/messages/index.js.map +1 -1
  36. package/resources/beta/messages/index.mjs +1 -1
  37. package/resources/beta/messages/index.mjs.map +1 -1
  38. package/resources/beta/messages/messages.d.ts +242 -51
  39. package/resources/beta/messages/messages.d.ts.map +1 -1
  40. package/resources/beta/messages/messages.js +20 -4
  41. package/resources/beta/messages/messages.js.map +1 -1
  42. package/resources/beta/messages/messages.mjs +20 -4
  43. package/resources/beta/messages/messages.mjs.map +1 -1
  44. package/resources/beta/prompt-caching/index.d.ts +1 -1
  45. package/resources/beta/prompt-caching/index.d.ts.map +1 -1
  46. package/resources/beta/prompt-caching/index.js +3 -3
  47. package/resources/beta/prompt-caching/index.js.map +1 -1
  48. package/resources/beta/prompt-caching/index.mjs +1 -1
  49. package/resources/beta/prompt-caching/index.mjs.map +1 -1
  50. package/resources/beta/prompt-caching/messages.d.ts +6 -14
  51. package/resources/beta/prompt-caching/messages.d.ts.map +1 -1
  52. package/resources/beta/prompt-caching/messages.js +0 -2
  53. package/resources/beta/prompt-caching/messages.js.map +1 -1
  54. package/resources/beta/prompt-caching/messages.mjs +0 -2
  55. package/resources/beta/prompt-caching/messages.mjs.map +1 -1
  56. package/resources/beta/prompt-caching/prompt-caching.d.ts +2 -15
  57. package/resources/beta/prompt-caching/prompt-caching.d.ts.map +1 -1
  58. package/resources/beta/prompt-caching/prompt-caching.js +2 -3
  59. package/resources/beta/prompt-caching/prompt-caching.js.map +1 -1
  60. package/resources/beta/prompt-caching/prompt-caching.mjs +2 -3
  61. package/resources/beta/prompt-caching/prompt-caching.mjs.map +1 -1
  62. package/resources/completions.d.ts +1 -4
  63. package/resources/completions.d.ts.map +1 -1
  64. package/resources/completions.js +0 -2
  65. package/resources/completions.js.map +1 -1
  66. package/resources/completions.mjs +0 -2
  67. package/resources/completions.mjs.map +1 -1
  68. package/resources/index.d.ts +3 -3
  69. package/resources/index.d.ts.map +1 -1
  70. package/resources/index.js.map +1 -1
  71. package/resources/index.mjs.map +1 -1
  72. package/resources/messages.d.ts +7 -40
  73. package/resources/messages.d.ts.map +1 -1
  74. package/resources/messages.js +0 -2
  75. package/resources/messages.js.map +1 -1
  76. package/resources/messages.mjs +0 -2
  77. package/resources/messages.mjs.map +1 -1
  78. package/src/core.ts +5 -5
  79. package/src/error.ts +1 -1
  80. package/src/index.ts +137 -66
  81. package/src/resources/beta/beta.ts +107 -50
  82. package/src/resources/beta/index.ts +49 -45
  83. package/src/resources/beta/messages/batches.ts +19 -16
  84. package/src/resources/beta/messages/index.ts +55 -51
  85. package/src/resources/beta/messages/messages.ts +347 -52
  86. package/src/resources/beta/prompt-caching/index.ts +15 -15
  87. package/src/resources/beta/prompt-caching/messages.ts +22 -15
  88. package/src/resources/beta/prompt-caching/prompt-caching.ts +37 -16
  89. package/src/resources/completions.ts +7 -5
  90. package/src/resources/index.ts +53 -53
  91. package/src/resources/messages.ts +49 -40
  92. package/src/streaming.ts +2 -2
  93. package/src/version.ts +1 -1
  94. package/streaming.d.ts.map +1 -1
  95. package/streaming.js +2 -2
  96. package/streaming.js.map +1 -1
  97. package/streaming.mjs +2 -2
  98. package/streaming.mjs.map +1 -1
  99. package/version.d.ts +1 -1
  100. package/version.js +1 -1
  101. package/version.mjs +1 -1
@@ -1,57 +1,61 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  export {
4
- BetaCacheControlEphemeral,
5
- BetaContentBlock,
6
- BetaContentBlockParam,
7
- BetaImageBlockParam,
8
- BetaInputJSONDelta,
9
- BetaMessage,
10
- BetaMessageDeltaUsage,
11
- BetaMessageParam,
12
- BetaMetadata,
13
- BetaRawContentBlockDeltaEvent,
14
- BetaRawContentBlockStartEvent,
15
- BetaRawContentBlockStopEvent,
16
- BetaRawMessageDeltaEvent,
17
- BetaRawMessageStartEvent,
18
- BetaRawMessageStopEvent,
19
- BetaRawMessageStreamEvent,
20
- BetaTextBlock,
21
- BetaTextBlockParam,
22
- BetaTextDelta,
23
- BetaTool,
24
- BetaToolBash20241022,
25
- BetaToolChoice,
26
- BetaToolChoiceAny,
27
- BetaToolChoiceAuto,
28
- BetaToolChoiceTool,
29
- BetaToolComputerUse20241022,
30
- BetaToolResultBlockParam,
31
- BetaToolTextEditor20241022,
32
- BetaToolUnion,
33
- BetaToolUseBlock,
34
- BetaToolUseBlockParam,
35
- BetaUsage,
36
- MessageCreateParams,
37
- MessageCreateParamsNonStreaming,
38
- MessageCreateParamsStreaming,
39
- Messages,
40
- } from "./messages.js";
41
- export {
42
- BetaMessageBatch,
43
- BetaMessageBatchCanceledResult,
44
- BetaMessageBatchErroredResult,
45
- BetaMessageBatchExpiredResult,
46
- BetaMessageBatchIndividualResponse,
47
- BetaMessageBatchRequestCounts,
48
- BetaMessageBatchResult,
49
- BetaMessageBatchSucceededResult,
50
- BatchCreateParams,
51
- BatchRetrieveParams,
52
- BatchListParams,
53
- BatchCancelParams,
54
- BatchResultsParams,
55
4
  BetaMessageBatchesPage,
56
5
  Batches,
6
+ type BetaMessageBatch,
7
+ type BetaMessageBatchCanceledResult,
8
+ type BetaMessageBatchErroredResult,
9
+ type BetaMessageBatchExpiredResult,
10
+ type BetaMessageBatchIndividualResponse,
11
+ type BetaMessageBatchRequestCounts,
12
+ type BetaMessageBatchResult,
13
+ type BetaMessageBatchSucceededResult,
14
+ type BatchCreateParams,
15
+ type BatchRetrieveParams,
16
+ type BatchListParams,
17
+ type BatchCancelParams,
18
+ type BatchResultsParams,
57
19
  } from "./batches.js";
20
+ export {
21
+ Messages,
22
+ type BetaBase64PDFBlock,
23
+ type BetaBase64PDFSource,
24
+ type BetaCacheControlEphemeral,
25
+ type BetaContentBlock,
26
+ type BetaContentBlockParam,
27
+ type BetaImageBlockParam,
28
+ type BetaInputJSONDelta,
29
+ type BetaMessage,
30
+ type BetaMessageDeltaUsage,
31
+ type BetaMessageParam,
32
+ type BetaMessageTokensCount,
33
+ type BetaMetadata,
34
+ type BetaRawContentBlockDeltaEvent,
35
+ type BetaRawContentBlockStartEvent,
36
+ type BetaRawContentBlockStopEvent,
37
+ type BetaRawMessageDeltaEvent,
38
+ type BetaRawMessageStartEvent,
39
+ type BetaRawMessageStopEvent,
40
+ type BetaRawMessageStreamEvent,
41
+ type BetaTextBlock,
42
+ type BetaTextBlockParam,
43
+ type BetaTextDelta,
44
+ type BetaTool,
45
+ type BetaToolBash20241022,
46
+ type BetaToolChoice,
47
+ type BetaToolChoiceAny,
48
+ type BetaToolChoiceAuto,
49
+ type BetaToolChoiceTool,
50
+ type BetaToolComputerUse20241022,
51
+ type BetaToolResultBlockParam,
52
+ type BetaToolTextEditor20241022,
53
+ type BetaToolUnion,
54
+ type BetaToolUseBlock,
55
+ type BetaToolUseBlockParam,
56
+ type BetaUsage,
57
+ type MessageCreateParams,
58
+ type MessageCreateParamsNonStreaming,
59
+ type MessageCreateParamsStreaming,
60
+ type MessageCountTokensParams,
61
+ } from "./messages.js";
@@ -7,6 +7,23 @@ import * as MessagesMessagesAPI from "./messages.js";
7
7
  import * as MessagesAPI from "../../messages.js";
8
8
  import * as BetaAPI from "../beta.js";
9
9
  import * as BatchesAPI from "./batches.js";
10
+ import {
11
+ BatchCancelParams,
12
+ BatchCreateParams,
13
+ BatchListParams,
14
+ BatchResultsParams,
15
+ BatchRetrieveParams,
16
+ Batches,
17
+ BetaMessageBatch,
18
+ BetaMessageBatchCanceledResult,
19
+ BetaMessageBatchErroredResult,
20
+ BetaMessageBatchExpiredResult,
21
+ BetaMessageBatchIndividualResponse,
22
+ BetaMessageBatchRequestCounts,
23
+ BetaMessageBatchResult,
24
+ BetaMessageBatchSucceededResult,
25
+ BetaMessageBatchesPage,
26
+ } from "./batches.js";
10
27
  import { Stream } from "../../../streaming.js";
11
28
 
12
29
  export class Messages extends APIResource {
@@ -44,6 +61,43 @@ export class Messages extends APIResource {
44
61
  stream: params.stream ?? false,
45
62
  }) as APIPromise<BetaMessage> | APIPromise<Stream<BetaRawMessageStreamEvent>>;
46
63
  }
64
+
65
+ /**
66
+ * Count the number of tokens in a Message.
67
+ *
68
+ * The Token Count API can be used to count the number of tokens in a Message,
69
+ * including tools, images, and documents, without creating it.
70
+ */
71
+ countTokens(
72
+ params: MessageCountTokensParams,
73
+ options?: Core.RequestOptions,
74
+ ): Core.APIPromise<BetaMessageTokensCount> {
75
+ const { betas, ...body } = params;
76
+ return this._client.post('/v1/messages/count_tokens?beta=true', {
77
+ body,
78
+ ...options,
79
+ headers: {
80
+ 'anthropic-beta': [...(betas ?? []), 'token-counting-2024-11-01'].toString(),
81
+ ...options?.headers,
82
+ },
83
+ });
84
+ }
85
+ }
86
+
87
+ export interface BetaBase64PDFBlock {
88
+ source: BetaBase64PDFSource;
89
+
90
+ type: 'document';
91
+
92
+ cache_control?: BetaCacheControlEphemeral | null;
93
+ }
94
+
95
+ export interface BetaBase64PDFSource {
96
+ data: string;
97
+
98
+ media_type: 'application/pdf';
99
+
100
+ type: 'base64';
47
101
  }
48
102
 
49
103
  export interface BetaCacheControlEphemeral {
@@ -56,7 +110,8 @@ export type BetaContentBlockParam =
56
110
  | BetaTextBlockParam
57
111
  | BetaImageBlockParam
58
112
  | BetaToolUseBlockParam
59
- | BetaToolResultBlockParam;
113
+ | BetaToolResultBlockParam
114
+ | BetaBase64PDFBlock;
60
115
 
61
116
  export interface BetaImageBlockParam {
62
117
  source: BetaImageBlockParam.Source;
@@ -200,6 +255,14 @@ export interface BetaMessageParam {
200
255
  role: 'user' | 'assistant';
201
256
  }
202
257
 
258
+ export interface BetaMessageTokensCount {
259
+ /**
260
+ * The total number of tokens across the provided list of messages, system prompt,
261
+ * and tools.
262
+ */
263
+ input_tokens: number;
264
+ }
265
+
203
266
  export interface BetaMetadata {
204
267
  /**
205
268
  * An external identifier for the user who is associated with the request.
@@ -310,6 +373,11 @@ export interface BetaTool {
310
373
  */
311
374
  input_schema: BetaTool.InputSchema;
312
375
 
376
+ /**
377
+ * Name of the tool.
378
+ *
379
+ * This is how the tool will be called by the model and in tool_use blocks.
380
+ */
313
381
  name: string;
314
382
 
315
383
  cache_control?: BetaCacheControlEphemeral | null;
@@ -343,6 +411,11 @@ export namespace BetaTool {
343
411
  }
344
412
 
345
413
  export interface BetaToolBash20241022 {
414
+ /**
415
+ * Name of the tool.
416
+ *
417
+ * This is how the tool will be called by the model and in tool_use blocks.
418
+ */
346
419
  name: 'bash';
347
420
 
348
421
  type: 'bash_20241022';
@@ -407,16 +480,30 @@ export interface BetaToolChoiceTool {
407
480
  }
408
481
 
409
482
  export interface BetaToolComputerUse20241022 {
483
+ /**
484
+ * The height of the display in pixels.
485
+ */
410
486
  display_height_px: number;
411
487
 
488
+ /**
489
+ * The width of the display in pixels.
490
+ */
412
491
  display_width_px: number;
413
492
 
493
+ /**
494
+ * Name of the tool.
495
+ *
496
+ * This is how the tool will be called by the model and in tool_use blocks.
497
+ */
414
498
  name: 'computer';
415
499
 
416
500
  type: 'computer_20241022';
417
501
 
418
502
  cache_control?: BetaCacheControlEphemeral | null;
419
503
 
504
+ /**
505
+ * The X11 display number (e.g. 0, 1) for the display.
506
+ */
420
507
  display_number?: number | null;
421
508
  }
422
509
 
@@ -433,6 +520,11 @@ export interface BetaToolResultBlockParam {
433
520
  }
434
521
 
435
522
  export interface BetaToolTextEditor20241022 {
523
+ /**
524
+ * Name of the tool.
525
+ *
526
+ * This is how the tool will be called by the model and in tool_use blocks.
527
+ */
436
528
  name: 'str_replace_editor';
437
529
 
438
530
  type: 'text_editor_20241022';
@@ -784,55 +876,258 @@ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
784
876
  stream: true;
785
877
  }
786
878
 
787
- export namespace Messages {
788
- export import BetaCacheControlEphemeral = MessagesMessagesAPI.BetaCacheControlEphemeral;
789
- export import BetaContentBlock = MessagesMessagesAPI.BetaContentBlock;
790
- export import BetaContentBlockParam = MessagesMessagesAPI.BetaContentBlockParam;
791
- export import BetaImageBlockParam = MessagesMessagesAPI.BetaImageBlockParam;
792
- export import BetaInputJSONDelta = MessagesMessagesAPI.BetaInputJSONDelta;
793
- export import BetaMessage = MessagesMessagesAPI.BetaMessage;
794
- export import BetaMessageDeltaUsage = MessagesMessagesAPI.BetaMessageDeltaUsage;
795
- export import BetaMessageParam = MessagesMessagesAPI.BetaMessageParam;
796
- export import BetaMetadata = MessagesMessagesAPI.BetaMetadata;
797
- export import BetaRawContentBlockDeltaEvent = MessagesMessagesAPI.BetaRawContentBlockDeltaEvent;
798
- export import BetaRawContentBlockStartEvent = MessagesMessagesAPI.BetaRawContentBlockStartEvent;
799
- export import BetaRawContentBlockStopEvent = MessagesMessagesAPI.BetaRawContentBlockStopEvent;
800
- export import BetaRawMessageDeltaEvent = MessagesMessagesAPI.BetaRawMessageDeltaEvent;
801
- export import BetaRawMessageStartEvent = MessagesMessagesAPI.BetaRawMessageStartEvent;
802
- export import BetaRawMessageStopEvent = MessagesMessagesAPI.BetaRawMessageStopEvent;
803
- export import BetaRawMessageStreamEvent = MessagesMessagesAPI.BetaRawMessageStreamEvent;
804
- export import BetaTextBlock = MessagesMessagesAPI.BetaTextBlock;
805
- export import BetaTextBlockParam = MessagesMessagesAPI.BetaTextBlockParam;
806
- export import BetaTextDelta = MessagesMessagesAPI.BetaTextDelta;
807
- export import BetaTool = MessagesMessagesAPI.BetaTool;
808
- export import BetaToolBash20241022 = MessagesMessagesAPI.BetaToolBash20241022;
809
- export import BetaToolChoice = MessagesMessagesAPI.BetaToolChoice;
810
- export import BetaToolChoiceAny = MessagesMessagesAPI.BetaToolChoiceAny;
811
- export import BetaToolChoiceAuto = MessagesMessagesAPI.BetaToolChoiceAuto;
812
- export import BetaToolChoiceTool = MessagesMessagesAPI.BetaToolChoiceTool;
813
- export import BetaToolComputerUse20241022 = MessagesMessagesAPI.BetaToolComputerUse20241022;
814
- export import BetaToolResultBlockParam = MessagesMessagesAPI.BetaToolResultBlockParam;
815
- export import BetaToolTextEditor20241022 = MessagesMessagesAPI.BetaToolTextEditor20241022;
816
- export import BetaToolUnion = MessagesMessagesAPI.BetaToolUnion;
817
- export import BetaToolUseBlock = MessagesMessagesAPI.BetaToolUseBlock;
818
- export import BetaToolUseBlockParam = MessagesMessagesAPI.BetaToolUseBlockParam;
819
- export import BetaUsage = MessagesMessagesAPI.BetaUsage;
820
- export import MessageCreateParams = MessagesMessagesAPI.MessageCreateParams;
821
- export import MessageCreateParamsNonStreaming = MessagesMessagesAPI.MessageCreateParamsNonStreaming;
822
- export import MessageCreateParamsStreaming = MessagesMessagesAPI.MessageCreateParamsStreaming;
823
- export import Batches = BatchesAPI.Batches;
824
- export import BetaMessageBatch = BatchesAPI.BetaMessageBatch;
825
- export import BetaMessageBatchCanceledResult = BatchesAPI.BetaMessageBatchCanceledResult;
826
- export import BetaMessageBatchErroredResult = BatchesAPI.BetaMessageBatchErroredResult;
827
- export import BetaMessageBatchExpiredResult = BatchesAPI.BetaMessageBatchExpiredResult;
828
- export import BetaMessageBatchIndividualResponse = BatchesAPI.BetaMessageBatchIndividualResponse;
829
- export import BetaMessageBatchRequestCounts = BatchesAPI.BetaMessageBatchRequestCounts;
830
- export import BetaMessageBatchResult = BatchesAPI.BetaMessageBatchResult;
831
- export import BetaMessageBatchSucceededResult = BatchesAPI.BetaMessageBatchSucceededResult;
832
- export import BetaMessageBatchesPage = BatchesAPI.BetaMessageBatchesPage;
833
- export import BatchCreateParams = BatchesAPI.BatchCreateParams;
834
- export import BatchRetrieveParams = BatchesAPI.BatchRetrieveParams;
835
- export import BatchListParams = BatchesAPI.BatchListParams;
836
- export import BatchCancelParams = BatchesAPI.BatchCancelParams;
837
- export import BatchResultsParams = BatchesAPI.BatchResultsParams;
879
+ export interface MessageCountTokensParams {
880
+ /**
881
+ * Body param: Input messages.
882
+ *
883
+ * Our models are trained to operate on alternating `user` and `assistant`
884
+ * conversational turns. When creating a new `Message`, you specify the prior
885
+ * conversational turns with the `messages` parameter, and the model then generates
886
+ * the next `Message` in the conversation. Consecutive `user` or `assistant` turns
887
+ * in your request will be combined into a single turn.
888
+ *
889
+ * Each input message must be an object with a `role` and `content`. You can
890
+ * specify a single `user`-role message, or you can include multiple `user` and
891
+ * `assistant` messages.
892
+ *
893
+ * If the final message uses the `assistant` role, the response content will
894
+ * continue immediately from the content in that message. This can be used to
895
+ * constrain part of the model's response.
896
+ *
897
+ * Example with a single `user` message:
898
+ *
899
+ * ```json
900
+ * [{ "role": "user", "content": "Hello, Claude" }]
901
+ * ```
902
+ *
903
+ * Example with multiple conversational turns:
904
+ *
905
+ * ```json
906
+ * [
907
+ * { "role": "user", "content": "Hello there." },
908
+ * { "role": "assistant", "content": "Hi, I'm Claude. How can I help you?" },
909
+ * { "role": "user", "content": "Can you explain LLMs in plain English?" }
910
+ * ]
911
+ * ```
912
+ *
913
+ * Example with a partially-filled response from Claude:
914
+ *
915
+ * ```json
916
+ * [
917
+ * {
918
+ * "role": "user",
919
+ * "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"
920
+ * },
921
+ * { "role": "assistant", "content": "The best answer is (" }
922
+ * ]
923
+ * ```
924
+ *
925
+ * Each input message `content` may be either a single `string` or an array of
926
+ * content blocks, where each block has a specific `type`. Using a `string` for
927
+ * `content` is shorthand for an array of one content block of type `"text"`. The
928
+ * following input messages are equivalent:
929
+ *
930
+ * ```json
931
+ * { "role": "user", "content": "Hello, Claude" }
932
+ * ```
933
+ *
934
+ * ```json
935
+ * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
936
+ * ```
937
+ *
938
+ * Starting with Claude 3 models, you can also send image content blocks:
939
+ *
940
+ * ```json
941
+ * {
942
+ * "role": "user",
943
+ * "content": [
944
+ * {
945
+ * "type": "image",
946
+ * "source": {
947
+ * "type": "base64",
948
+ * "media_type": "image/jpeg",
949
+ * "data": "/9j/4AAQSkZJRg..."
950
+ * }
951
+ * },
952
+ * { "type": "text", "text": "What is in this image?" }
953
+ * ]
954
+ * }
955
+ * ```
956
+ *
957
+ * We currently support the `base64` source type for images, and the `image/jpeg`,
958
+ * `image/png`, `image/gif`, and `image/webp` media types.
959
+ *
960
+ * See [examples](https://docs.anthropic.com/en/api/messages-examples#vision) for
961
+ * more input examples.
962
+ *
963
+ * Note that if you want to include a
964
+ * [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
965
+ * the top-level `system` parameter — there is no `"system"` role for input
966
+ * messages in the Messages API.
967
+ */
968
+ messages: Array<BetaMessageParam>;
969
+
970
+ /**
971
+ * Body param: The model that will complete your prompt.\n\nSee
972
+ * [models](https://docs.anthropic.com/en/docs/models-overview) for additional
973
+ * details and options.
974
+ */
975
+ model: MessagesAPI.Model;
976
+
977
+ /**
978
+ * Body param: System prompt.
979
+ *
980
+ * A system prompt is a way of providing context and instructions to Claude, such
981
+ * as specifying a particular goal or role. See our
982
+ * [guide to system prompts](https://docs.anthropic.com/en/docs/system-prompts).
983
+ */
984
+ system?: string | Array<BetaTextBlockParam>;
985
+
986
+ /**
987
+ * Body param: How the model should use the provided tools. The model can use a
988
+ * specific tool, any available tool, or decide by itself.
989
+ */
990
+ tool_choice?: BetaToolChoice;
991
+
992
+ /**
993
+ * Body param: Definitions of tools that the model may use.
994
+ *
995
+ * If you include `tools` in your API request, the model may return `tool_use`
996
+ * content blocks that represent the model's use of those tools. You can then run
997
+ * those tools using the tool input generated by the model and then optionally
998
+ * return results back to the model using `tool_result` content blocks.
999
+ *
1000
+ * Each tool definition includes:
1001
+ *
1002
+ * - `name`: Name of the tool.
1003
+ * - `description`: Optional, but strongly-recommended description of the tool.
1004
+ * - `input_schema`: [JSON schema](https://json-schema.org/) for the tool `input`
1005
+ * shape that the model will produce in `tool_use` output content blocks.
1006
+ *
1007
+ * For example, if you defined `tools` as:
1008
+ *
1009
+ * ```json
1010
+ * [
1011
+ * {
1012
+ * "name": "get_stock_price",
1013
+ * "description": "Get the current stock price for a given ticker symbol.",
1014
+ * "input_schema": {
1015
+ * "type": "object",
1016
+ * "properties": {
1017
+ * "ticker": {
1018
+ * "type": "string",
1019
+ * "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
1020
+ * }
1021
+ * },
1022
+ * "required": ["ticker"]
1023
+ * }
1024
+ * }
1025
+ * ]
1026
+ * ```
1027
+ *
1028
+ * And then asked the model "What's the S&P 500 at today?", the model might produce
1029
+ * `tool_use` content blocks in the response like this:
1030
+ *
1031
+ * ```json
1032
+ * [
1033
+ * {
1034
+ * "type": "tool_use",
1035
+ * "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
1036
+ * "name": "get_stock_price",
1037
+ * "input": { "ticker": "^GSPC" }
1038
+ * }
1039
+ * ]
1040
+ * ```
1041
+ *
1042
+ * You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an
1043
+ * input, and return the following back to the model in a subsequent `user`
1044
+ * message:
1045
+ *
1046
+ * ```json
1047
+ * [
1048
+ * {
1049
+ * "type": "tool_result",
1050
+ * "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
1051
+ * "content": "259.75 USD"
1052
+ * }
1053
+ * ]
1054
+ * ```
1055
+ *
1056
+ * Tools can be used for workflows that include running client-side tools and
1057
+ * functions, or more generally whenever you want the model to produce a particular
1058
+ * JSON structure of output.
1059
+ *
1060
+ * See our [guide](https://docs.anthropic.com/en/docs/tool-use) for more details.
1061
+ */
1062
+ tools?: Array<BetaTool | BetaToolComputerUse20241022 | BetaToolBash20241022 | BetaToolTextEditor20241022>;
1063
+
1064
+ /**
1065
+ * Header param: Optional header to specify the beta version(s) you want to use.
1066
+ */
1067
+ betas?: Array<BetaAPI.AnthropicBeta>;
1068
+ }
1069
+
1070
+ Messages.Batches = Batches;
1071
+ Messages.BetaMessageBatchesPage = BetaMessageBatchesPage;
1072
+
1073
+ export declare namespace Messages {
1074
+ export {
1075
+ type BetaBase64PDFBlock as BetaBase64PDFBlock,
1076
+ type BetaBase64PDFSource as BetaBase64PDFSource,
1077
+ type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
1078
+ type BetaContentBlock as BetaContentBlock,
1079
+ type BetaContentBlockParam as BetaContentBlockParam,
1080
+ type BetaImageBlockParam as BetaImageBlockParam,
1081
+ type BetaInputJSONDelta as BetaInputJSONDelta,
1082
+ type BetaMessage as BetaMessage,
1083
+ type BetaMessageDeltaUsage as BetaMessageDeltaUsage,
1084
+ type BetaMessageParam as BetaMessageParam,
1085
+ type BetaMessageTokensCount as BetaMessageTokensCount,
1086
+ type BetaMetadata as BetaMetadata,
1087
+ type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
1088
+ type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
1089
+ type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
1090
+ type BetaRawMessageDeltaEvent as BetaRawMessageDeltaEvent,
1091
+ type BetaRawMessageStartEvent as BetaRawMessageStartEvent,
1092
+ type BetaRawMessageStopEvent as BetaRawMessageStopEvent,
1093
+ type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
1094
+ type BetaTextBlock as BetaTextBlock,
1095
+ type BetaTextBlockParam as BetaTextBlockParam,
1096
+ type BetaTextDelta as BetaTextDelta,
1097
+ type BetaTool as BetaTool,
1098
+ type BetaToolBash20241022 as BetaToolBash20241022,
1099
+ type BetaToolChoice as BetaToolChoice,
1100
+ type BetaToolChoiceAny as BetaToolChoiceAny,
1101
+ type BetaToolChoiceAuto as BetaToolChoiceAuto,
1102
+ type BetaToolChoiceTool as BetaToolChoiceTool,
1103
+ type BetaToolComputerUse20241022 as BetaToolComputerUse20241022,
1104
+ type BetaToolResultBlockParam as BetaToolResultBlockParam,
1105
+ type BetaToolTextEditor20241022 as BetaToolTextEditor20241022,
1106
+ type BetaToolUnion as BetaToolUnion,
1107
+ type BetaToolUseBlock as BetaToolUseBlock,
1108
+ type BetaToolUseBlockParam as BetaToolUseBlockParam,
1109
+ type BetaUsage as BetaUsage,
1110
+ type MessageCreateParams as MessageCreateParams,
1111
+ type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
1112
+ type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
1113
+ type MessageCountTokensParams as MessageCountTokensParams,
1114
+ };
1115
+
1116
+ export {
1117
+ Batches as Batches,
1118
+ type BetaMessageBatch as BetaMessageBatch,
1119
+ type BetaMessageBatchCanceledResult as BetaMessageBatchCanceledResult,
1120
+ type BetaMessageBatchErroredResult as BetaMessageBatchErroredResult,
1121
+ type BetaMessageBatchExpiredResult as BetaMessageBatchExpiredResult,
1122
+ type BetaMessageBatchIndividualResponse as BetaMessageBatchIndividualResponse,
1123
+ type BetaMessageBatchRequestCounts as BetaMessageBatchRequestCounts,
1124
+ type BetaMessageBatchResult as BetaMessageBatchResult,
1125
+ type BetaMessageBatchSucceededResult as BetaMessageBatchSucceededResult,
1126
+ BetaMessageBatchesPage as BetaMessageBatchesPage,
1127
+ type BatchCreateParams as BatchCreateParams,
1128
+ type BatchRetrieveParams as BatchRetrieveParams,
1129
+ type BatchListParams as BatchListParams,
1130
+ type BatchCancelParams as BatchCancelParams,
1131
+ type BatchResultsParams as BatchResultsParams,
1132
+ };
838
1133
  }
@@ -1,20 +1,20 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { PromptCaching } from "./prompt-caching.js";
4
3
  export {
5
- PromptCachingBetaCacheControlEphemeral,
6
- PromptCachingBetaImageBlockParam,
7
- PromptCachingBetaMessage,
8
- PromptCachingBetaMessageParam,
9
- PromptCachingBetaTextBlockParam,
10
- PromptCachingBetaTool,
11
- PromptCachingBetaToolResultBlockParam,
12
- PromptCachingBetaToolUseBlockParam,
13
- PromptCachingBetaUsage,
14
- RawPromptCachingBetaMessageStartEvent,
15
- RawPromptCachingBetaMessageStreamEvent,
16
- MessageCreateParams,
17
- MessageCreateParamsNonStreaming,
18
- MessageCreateParamsStreaming,
19
4
  Messages,
5
+ type PromptCachingBetaCacheControlEphemeral,
6
+ type PromptCachingBetaImageBlockParam,
7
+ type PromptCachingBetaMessage,
8
+ type PromptCachingBetaMessageParam,
9
+ type PromptCachingBetaTextBlockParam,
10
+ type PromptCachingBetaTool,
11
+ type PromptCachingBetaToolResultBlockParam,
12
+ type PromptCachingBetaToolUseBlockParam,
13
+ type PromptCachingBetaUsage,
14
+ type RawPromptCachingBetaMessageStartEvent,
15
+ type RawPromptCachingBetaMessageStreamEvent,
16
+ type MessageCreateParams,
17
+ type MessageCreateParamsNonStreaming,
18
+ type MessageCreateParamsStreaming,
20
19
  } from "./messages.js";
20
+ export { PromptCaching } from "./prompt-caching.js";
@@ -213,6 +213,11 @@ export interface PromptCachingBetaTool {
213
213
  */
214
214
  input_schema: PromptCachingBetaTool.InputSchema;
215
215
 
216
+ /**
217
+ * Name of the tool.
218
+ *
219
+ * This is how the tool will be called by the model and in tool_use blocks.
220
+ */
216
221
  name: string;
217
222
 
218
223
  cache_control?: PromptCachingBetaCacheControlEphemeral | null;
@@ -617,19 +622,21 @@ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
617
622
  stream: true;
618
623
  }
619
624
 
620
- export namespace Messages {
621
- export import PromptCachingBetaCacheControlEphemeral = PromptCachingMessagesAPI.PromptCachingBetaCacheControlEphemeral;
622
- export import PromptCachingBetaImageBlockParam = PromptCachingMessagesAPI.PromptCachingBetaImageBlockParam;
623
- export import PromptCachingBetaMessage = PromptCachingMessagesAPI.PromptCachingBetaMessage;
624
- export import PromptCachingBetaMessageParam = PromptCachingMessagesAPI.PromptCachingBetaMessageParam;
625
- export import PromptCachingBetaTextBlockParam = PromptCachingMessagesAPI.PromptCachingBetaTextBlockParam;
626
- export import PromptCachingBetaTool = PromptCachingMessagesAPI.PromptCachingBetaTool;
627
- export import PromptCachingBetaToolResultBlockParam = PromptCachingMessagesAPI.PromptCachingBetaToolResultBlockParam;
628
- export import PromptCachingBetaToolUseBlockParam = PromptCachingMessagesAPI.PromptCachingBetaToolUseBlockParam;
629
- export import PromptCachingBetaUsage = PromptCachingMessagesAPI.PromptCachingBetaUsage;
630
- export import RawPromptCachingBetaMessageStartEvent = PromptCachingMessagesAPI.RawPromptCachingBetaMessageStartEvent;
631
- export import RawPromptCachingBetaMessageStreamEvent = PromptCachingMessagesAPI.RawPromptCachingBetaMessageStreamEvent;
632
- export import MessageCreateParams = PromptCachingMessagesAPI.MessageCreateParams;
633
- export import MessageCreateParamsNonStreaming = PromptCachingMessagesAPI.MessageCreateParamsNonStreaming;
634
- export import MessageCreateParamsStreaming = PromptCachingMessagesAPI.MessageCreateParamsStreaming;
625
+ export declare namespace Messages {
626
+ export {
627
+ type PromptCachingBetaCacheControlEphemeral as PromptCachingBetaCacheControlEphemeral,
628
+ type PromptCachingBetaImageBlockParam as PromptCachingBetaImageBlockParam,
629
+ type PromptCachingBetaMessage as PromptCachingBetaMessage,
630
+ type PromptCachingBetaMessageParam as PromptCachingBetaMessageParam,
631
+ type PromptCachingBetaTextBlockParam as PromptCachingBetaTextBlockParam,
632
+ type PromptCachingBetaTool as PromptCachingBetaTool,
633
+ type PromptCachingBetaToolResultBlockParam as PromptCachingBetaToolResultBlockParam,
634
+ type PromptCachingBetaToolUseBlockParam as PromptCachingBetaToolUseBlockParam,
635
+ type PromptCachingBetaUsage as PromptCachingBetaUsage,
636
+ type RawPromptCachingBetaMessageStartEvent as RawPromptCachingBetaMessageStartEvent,
637
+ type RawPromptCachingBetaMessageStreamEvent as RawPromptCachingBetaMessageStreamEvent,
638
+ type MessageCreateParams as MessageCreateParams,
639
+ type MessageCreateParamsNonStreaming as MessageCreateParamsNonStreaming,
640
+ type MessageCreateParamsStreaming as MessageCreateParamsStreaming,
641
+ };
635
642
  }