@anthropic-ai/sdk 0.40.0 → 0.41.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 +27 -0
  2. package/README.md +3 -3
  3. package/index.d.mts +4 -4
  4. package/index.d.ts +4 -4
  5. package/index.d.ts.map +1 -1
  6. package/index.js.map +1 -1
  7. package/index.mjs.map +1 -1
  8. package/lib/BetaMessageStream.d.ts.map +1 -1
  9. package/lib/BetaMessageStream.js +7 -0
  10. package/lib/BetaMessageStream.js.map +1 -1
  11. package/lib/BetaMessageStream.mjs +7 -0
  12. package/lib/BetaMessageStream.mjs.map +1 -1
  13. package/lib/MessageStream.d.ts.map +1 -1
  14. package/lib/MessageStream.js +7 -0
  15. package/lib/MessageStream.js.map +1 -1
  16. package/lib/MessageStream.mjs +7 -0
  17. package/lib/MessageStream.mjs.map +1 -1
  18. package/package.json +1 -1
  19. package/resources/beta/beta.d.ts +4 -4
  20. package/resources/beta/beta.d.ts.map +1 -1
  21. package/resources/beta/beta.js.map +1 -1
  22. package/resources/beta/beta.mjs.map +1 -1
  23. package/resources/beta/index.d.ts +2 -2
  24. package/resources/beta/index.d.ts.map +1 -1
  25. package/resources/beta/index.js.map +1 -1
  26. package/resources/beta/index.mjs +1 -1
  27. package/resources/beta/index.mjs.map +1 -1
  28. package/resources/beta/messages/batches.d.ts +59 -0
  29. package/resources/beta/messages/batches.d.ts.map +1 -1
  30. package/resources/beta/messages/batches.js +19 -0
  31. package/resources/beta/messages/batches.js.map +1 -1
  32. package/resources/beta/messages/batches.mjs +19 -0
  33. package/resources/beta/messages/batches.mjs.map +1 -1
  34. package/resources/beta/messages/index.d.ts +1 -1
  35. package/resources/beta/messages/index.d.ts.map +1 -1
  36. package/resources/beta/messages/index.js.map +1 -1
  37. package/resources/beta/messages/index.mjs.map +1 -1
  38. package/resources/beta/messages/messages.d.ts +228 -17
  39. package/resources/beta/messages/messages.d.ts.map +1 -1
  40. package/resources/beta/messages/messages.js +9 -0
  41. package/resources/beta/messages/messages.js.map +1 -1
  42. package/resources/beta/messages/messages.mjs +9 -0
  43. package/resources/beta/messages/messages.mjs.map +1 -1
  44. package/resources/beta/models.d.ts +29 -2
  45. package/resources/beta/models.d.ts.map +1 -1
  46. package/resources/beta/models.js +24 -12
  47. package/resources/beta/models.js.map +1 -1
  48. package/resources/beta/models.mjs +24 -12
  49. package/resources/beta/models.mjs.map +1 -1
  50. package/resources/completions.d.ts +31 -14
  51. package/resources/completions.d.ts.map +1 -1
  52. package/resources/completions.js +7 -2
  53. package/resources/completions.js.map +1 -1
  54. package/resources/completions.mjs +7 -2
  55. package/resources/completions.mjs.map +1 -1
  56. package/resources/index.d.ts +2 -2
  57. package/resources/index.d.ts.map +1 -1
  58. package/resources/index.js.map +1 -1
  59. package/resources/index.mjs +1 -1
  60. package/resources/index.mjs.map +1 -1
  61. package/resources/messages/batches.d.ts +52 -0
  62. package/resources/messages/batches.d.ts.map +1 -1
  63. package/resources/messages/batches.js +44 -0
  64. package/resources/messages/batches.js.map +1 -1
  65. package/resources/messages/batches.mjs +44 -0
  66. package/resources/messages/batches.mjs.map +1 -1
  67. package/resources/messages/index.d.ts +1 -1
  68. package/resources/messages/index.d.ts.map +1 -1
  69. package/resources/messages/index.js.map +1 -1
  70. package/resources/messages/index.mjs.map +1 -1
  71. package/resources/messages/messages.d.ts +213 -13
  72. package/resources/messages/messages.d.ts.map +1 -1
  73. package/resources/messages/messages.js +9 -0
  74. package/resources/messages/messages.js.map +1 -1
  75. package/resources/messages/messages.mjs +9 -0
  76. package/resources/messages/messages.mjs.map +1 -1
  77. package/resources/models.d.ts +14 -2
  78. package/resources/models.d.ts.map +1 -1
  79. package/resources/models.js +24 -12
  80. package/resources/models.js.map +1 -1
  81. package/resources/models.mjs +24 -12
  82. package/resources/models.mjs.map +1 -1
  83. package/src/index.ts +30 -1
  84. package/src/lib/BetaMessageStream.ts +9 -0
  85. package/src/lib/MessageStream.ts +9 -0
  86. package/src/resources/beta/beta.ts +30 -1
  87. package/src/resources/beta/index.ts +21 -1
  88. package/src/resources/beta/messages/batches.ts +59 -0
  89. package/src/resources/beta/messages/index.ts +14 -0
  90. package/src/resources/beta/messages/messages.ts +336 -13
  91. package/src/resources/beta/models.ts +65 -8
  92. package/src/resources/completions.ts +39 -16
  93. package/src/resources/index.ts +21 -1
  94. package/src/resources/messages/batches.ts +52 -0
  95. package/src/resources/messages/index.ts +14 -0
  96. package/src/resources/messages/messages.ts +321 -11
  97. package/src/resources/models.ts +50 -8
  98. package/src/version.ts +1 -1
  99. package/version.d.ts +1 -1
  100. package/version.js +1 -1
  101. package/version.mjs +1 -1
@@ -36,6 +36,15 @@ export class Messages extends APIResource {
36
36
  * conversations.
37
37
  *
38
38
  * Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const message = await client.messages.create({
43
+ * max_tokens: 1024,
44
+ * messages: [{ content: 'Hello, world', role: 'user' }],
45
+ * model: 'claude-3-7-sonnet-20250219',
46
+ * });
47
+ * ```
39
48
  */
40
49
  create(body: MessageCreateParamsNonStreaming, options?: Core.RequestOptions): APIPromise<Message>;
41
50
  create(
@@ -82,6 +91,15 @@ export class Messages extends APIResource {
82
91
  *
83
92
  * Learn more about token counting in our
84
93
  * [user guide](/en/docs/build-with-claude/token-counting)
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const messageTokensCount =
98
+ * await client.messages.countTokens({
99
+ * messages: [{ content: 'string', role: 'user' }],
100
+ * model: 'claude-3-7-sonnet-latest',
101
+ * });
102
+ * ```
85
103
  */
86
104
  countTokens(
87
105
  body: MessageCountTokensParams,
@@ -195,22 +213,58 @@ export interface CitationPageLocationParam {
195
213
  type: 'page_location';
196
214
  }
197
215
 
216
+ export interface CitationWebSearchResultLocationParam {
217
+ cited_text: string;
218
+
219
+ encrypted_index: string;
220
+
221
+ title: string | null;
222
+
223
+ type: 'web_search_result_location';
224
+
225
+ url: string;
226
+ }
227
+
198
228
  export interface CitationsConfigParam {
199
229
  enabled?: boolean;
200
230
  }
201
231
 
202
232
  export interface CitationsDelta {
203
- citation: CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
233
+ citation:
234
+ | CitationCharLocation
235
+ | CitationPageLocation
236
+ | CitationContentBlockLocation
237
+ | CitationsWebSearchResultLocation;
204
238
 
205
239
  type: 'citations_delta';
206
240
  }
207
241
 
208
- export type ContentBlock = TextBlock | ToolUseBlock | ThinkingBlock | RedactedThinkingBlock;
242
+ export interface CitationsWebSearchResultLocation {
243
+ cited_text: string;
244
+
245
+ encrypted_index: string;
246
+
247
+ title: string | null;
248
+
249
+ type: 'web_search_result_location';
250
+
251
+ url: string;
252
+ }
253
+
254
+ export type ContentBlock =
255
+ | TextBlock
256
+ | ToolUseBlock
257
+ | ServerToolUseBlock
258
+ | WebSearchToolResultBlock
259
+ | ThinkingBlock
260
+ | RedactedThinkingBlock;
209
261
 
210
262
  export type ContentBlockParam =
211
263
  | TextBlockParam
212
264
  | ImageBlockParam
213
265
  | ToolUseBlockParam
266
+ | ServerToolUseBlockParam
267
+ | WebSearchToolResultBlockParam
214
268
  | ToolResultBlockParam
215
269
  | DocumentBlockParam
216
270
  | ThinkingBlockParam
@@ -229,6 +283,9 @@ export interface DocumentBlockParam {
229
283
 
230
284
  type: 'document';
231
285
 
286
+ /**
287
+ * Create a cache control breakpoint at this content block.
288
+ */
232
289
  cache_control?: CacheControlEphemeral | null;
233
290
 
234
291
  citations?: CitationsConfigParam;
@@ -243,6 +300,9 @@ export interface ImageBlockParam {
243
300
 
244
301
  type: 'image';
245
302
 
303
+ /**
304
+ * Create a cache control breakpoint at this content block.
305
+ */
246
306
  cache_control?: CacheControlEphemeral | null;
247
307
  }
248
308
 
@@ -362,13 +422,33 @@ export interface Message {
362
422
  usage: Usage;
363
423
  }
364
424
 
365
- export type MessageCountTokensTool = Tool | ToolBash20250124 | ToolTextEditor20250124;
425
+ export type MessageCountTokensTool = Tool | ToolBash20250124 | ToolTextEditor20250124 | WebSearchTool20250305;
366
426
 
367
427
  export interface MessageDeltaUsage {
428
+ /**
429
+ * The cumulative number of input tokens used to create the cache entry.
430
+ */
431
+ cache_creation_input_tokens: number | null;
432
+
433
+ /**
434
+ * The cumulative number of input tokens read from the cache.
435
+ */
436
+ cache_read_input_tokens: number | null;
437
+
438
+ /**
439
+ * The cumulative number of input tokens which were used.
440
+ */
441
+ input_tokens: number | null;
442
+
368
443
  /**
369
444
  * The cumulative number of output tokens which were used.
370
445
  */
371
446
  output_tokens: number;
447
+
448
+ /**
449
+ * The number of server tool requests.
450
+ */
451
+ server_tool_use: ServerToolUsage | null;
372
452
  }
373
453
 
374
454
  export interface MessageParam {
@@ -454,7 +534,13 @@ export interface RawContentBlockDeltaEvent {
454
534
  }
455
535
 
456
536
  export interface RawContentBlockStartEvent {
457
- content_block: TextBlock | ToolUseBlock | ThinkingBlock | RedactedThinkingBlock;
537
+ content_block:
538
+ | TextBlock
539
+ | ToolUseBlock
540
+ | ServerToolUseBlock
541
+ | WebSearchToolResultBlock
542
+ | ThinkingBlock
543
+ | RedactedThinkingBlock;
458
544
 
459
545
  index: number;
460
546
 
@@ -530,13 +616,45 @@ export interface RedactedThinkingBlockParam {
530
616
  type: 'redacted_thinking';
531
617
  }
532
618
 
619
+ export interface ServerToolUsage {
620
+ /**
621
+ * The number of web search tool requests.
622
+ */
623
+ web_search_requests: number;
624
+ }
625
+
626
+ export interface ServerToolUseBlock {
627
+ id: string;
628
+
629
+ input: unknown;
630
+
631
+ name: 'web_search';
632
+
633
+ type: 'server_tool_use';
634
+ }
635
+
636
+ export interface ServerToolUseBlockParam {
637
+ id: string;
638
+
639
+ input: unknown;
640
+
641
+ name: 'web_search';
642
+
643
+ type: 'server_tool_use';
644
+
645
+ /**
646
+ * Create a cache control breakpoint at this content block.
647
+ */
648
+ cache_control?: CacheControlEphemeral | null;
649
+ }
650
+
533
651
  export interface SignatureDelta {
534
652
  signature: string;
535
653
 
536
654
  type: 'signature_delta';
537
655
  }
538
656
 
539
- export type StopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use';
657
+ export type StopReason = 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal';
540
658
 
541
659
  export interface TextBlock {
542
660
  /**
@@ -558,17 +676,25 @@ export interface TextBlockParam {
558
676
 
559
677
  type: 'text';
560
678
 
679
+ /**
680
+ * Create a cache control breakpoint at this content block.
681
+ */
561
682
  cache_control?: CacheControlEphemeral | null;
562
683
 
563
684
  citations?: Array<TextCitationParam> | null;
564
685
  }
565
686
 
566
- export type TextCitation = CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
687
+ export type TextCitation =
688
+ | CitationCharLocation
689
+ | CitationPageLocation
690
+ | CitationContentBlockLocation
691
+ | CitationsWebSearchResultLocation;
567
692
 
568
693
  export type TextCitationParam =
569
694
  | CitationCharLocationParam
570
695
  | CitationPageLocationParam
571
- | CitationContentBlockLocationParam;
696
+ | CitationContentBlockLocationParam
697
+ | CitationWebSearchResultLocationParam;
572
698
 
573
699
  export interface TextDelta {
574
700
  text: string;
@@ -644,10 +770,13 @@ export interface Tool {
644
770
  /**
645
771
  * Name of the tool.
646
772
  *
647
- * This is how the tool will be called by the model and in tool_use blocks.
773
+ * This is how the tool will be called by the model and in `tool_use` blocks.
648
774
  */
649
775
  name: string;
650
776
 
777
+ /**
778
+ * Create a cache control breakpoint at this content block.
779
+ */
651
780
  cache_control?: CacheControlEphemeral | null;
652
781
 
653
782
  /**
@@ -659,6 +788,8 @@ export interface Tool {
659
788
  * aspects of the tool input JSON schema.
660
789
  */
661
790
  description?: string;
791
+
792
+ type?: 'custom' | null;
662
793
  }
663
794
 
664
795
  export namespace Tool {
@@ -681,12 +812,15 @@ export interface ToolBash20250124 {
681
812
  /**
682
813
  * Name of the tool.
683
814
  *
684
- * This is how the tool will be called by the model and in tool_use blocks.
815
+ * This is how the tool will be called by the model and in `tool_use` blocks.
685
816
  */
686
817
  name: 'bash';
687
818
 
688
819
  type: 'bash_20250124';
689
820
 
821
+ /**
822
+ * Create a cache control breakpoint at this content block.
823
+ */
690
824
  cache_control?: CacheControlEphemeral | null;
691
825
  }
692
826
 
@@ -758,6 +892,9 @@ export interface ToolResultBlockParam {
758
892
 
759
893
  type: 'tool_result';
760
894
 
895
+ /**
896
+ * Create a cache control breakpoint at this content block.
897
+ */
761
898
  cache_control?: CacheControlEphemeral | null;
762
899
 
763
900
  content?: string | Array<TextBlockParam | ImageBlockParam>;
@@ -769,16 +906,19 @@ export interface ToolTextEditor20250124 {
769
906
  /**
770
907
  * Name of the tool.
771
908
  *
772
- * This is how the tool will be called by the model and in tool_use blocks.
909
+ * This is how the tool will be called by the model and in `tool_use` blocks.
773
910
  */
774
911
  name: 'str_replace_editor';
775
912
 
776
913
  type: 'text_editor_20250124';
777
914
 
915
+ /**
916
+ * Create a cache control breakpoint at this content block.
917
+ */
778
918
  cache_control?: CacheControlEphemeral | null;
779
919
  }
780
920
 
781
- export type ToolUnion = Tool | ToolBash20250124 | ToolTextEditor20250124;
921
+ export type ToolUnion = Tool | ToolBash20250124 | ToolTextEditor20250124 | WebSearchTool20250305;
782
922
 
783
923
  export interface ToolUseBlock {
784
924
  id: string;
@@ -799,6 +939,9 @@ export interface ToolUseBlockParam {
799
939
 
800
940
  type: 'tool_use';
801
941
 
942
+ /**
943
+ * Create a cache control breakpoint at this content block.
944
+ */
802
945
  cache_control?: CacheControlEphemeral | null;
803
946
  }
804
947
 
@@ -834,6 +977,155 @@ export interface Usage {
834
977
  * The number of output tokens which were used.
835
978
  */
836
979
  output_tokens: number;
980
+
981
+ /**
982
+ * The number of server tool requests.
983
+ */
984
+ server_tool_use: ServerToolUsage | null;
985
+ }
986
+
987
+ export interface WebSearchResultBlock {
988
+ encrypted_content: string;
989
+
990
+ page_age: string | null;
991
+
992
+ title: string;
993
+
994
+ type: 'web_search_result';
995
+
996
+ url: string;
997
+ }
998
+
999
+ export interface WebSearchResultBlockParam {
1000
+ encrypted_content: string;
1001
+
1002
+ title: string;
1003
+
1004
+ type: 'web_search_result';
1005
+
1006
+ url: string;
1007
+
1008
+ page_age?: string | null;
1009
+ }
1010
+
1011
+ export interface WebSearchTool20250305 {
1012
+ /**
1013
+ * Name of the tool.
1014
+ *
1015
+ * This is how the tool will be called by the model and in `tool_use` blocks.
1016
+ */
1017
+ name: 'web_search';
1018
+
1019
+ type: 'web_search_20250305';
1020
+
1021
+ /**
1022
+ * If provided, only these domains will be included in results. Cannot be used
1023
+ * alongside `blocked_domains`.
1024
+ */
1025
+ allowed_domains?: Array<string> | null;
1026
+
1027
+ /**
1028
+ * If provided, these domains will never appear in results. Cannot be used
1029
+ * alongside `allowed_domains`.
1030
+ */
1031
+ blocked_domains?: Array<string> | null;
1032
+
1033
+ /**
1034
+ * Create a cache control breakpoint at this content block.
1035
+ */
1036
+ cache_control?: CacheControlEphemeral | null;
1037
+
1038
+ /**
1039
+ * Maximum number of times the tool can be used in the API request.
1040
+ */
1041
+ max_uses?: number | null;
1042
+
1043
+ /**
1044
+ * Parameters for the user's location. Used to provide more relevant search
1045
+ * results.
1046
+ */
1047
+ user_location?: WebSearchTool20250305.UserLocation | null;
1048
+ }
1049
+
1050
+ export namespace WebSearchTool20250305 {
1051
+ /**
1052
+ * Parameters for the user's location. Used to provide more relevant search
1053
+ * results.
1054
+ */
1055
+ export interface UserLocation {
1056
+ type: 'approximate';
1057
+
1058
+ /**
1059
+ * The city of the user.
1060
+ */
1061
+ city?: string | null;
1062
+
1063
+ /**
1064
+ * The two letter
1065
+ * [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the
1066
+ * user.
1067
+ */
1068
+ country?: string | null;
1069
+
1070
+ /**
1071
+ * The region of the user.
1072
+ */
1073
+ region?: string | null;
1074
+
1075
+ /**
1076
+ * The [IANA timezone](https://nodatime.org/TimeZones) of the user.
1077
+ */
1078
+ timezone?: string | null;
1079
+ }
1080
+ }
1081
+
1082
+ export interface WebSearchToolRequestError {
1083
+ error_code:
1084
+ | 'invalid_tool_input'
1085
+ | 'unavailable'
1086
+ | 'max_uses_exceeded'
1087
+ | 'too_many_requests'
1088
+ | 'query_too_long';
1089
+
1090
+ type: 'web_search_tool_result_error';
1091
+ }
1092
+
1093
+ export interface WebSearchToolResultBlock {
1094
+ content: WebSearchToolResultBlockContent;
1095
+
1096
+ tool_use_id: string;
1097
+
1098
+ type: 'web_search_tool_result';
1099
+ }
1100
+
1101
+ export type WebSearchToolResultBlockContent = WebSearchToolResultError | Array<WebSearchResultBlock>;
1102
+
1103
+ export interface WebSearchToolResultBlockParam {
1104
+ content: WebSearchToolResultBlockParamContent;
1105
+
1106
+ tool_use_id: string;
1107
+
1108
+ type: 'web_search_tool_result';
1109
+
1110
+ /**
1111
+ * Create a cache control breakpoint at this content block.
1112
+ */
1113
+ cache_control?: CacheControlEphemeral | null;
1114
+ }
1115
+
1116
+ export type WebSearchToolResultBlockParamContent =
1117
+ | Array<WebSearchResultBlockParam>
1118
+ | WebSearchToolRequestError;
1119
+
1120
+ export interface WebSearchToolResultError {
1121
+ error_code:
1122
+ | 'invalid_tool_input'
1123
+ | 'unavailable'
1124
+ | 'max_uses_exceeded'
1125
+ | 'too_many_requests'
1126
+ | 'query_too_long';
1127
+
1128
+ type: 'web_search_tool_result_error';
837
1129
  }
838
1130
 
839
1131
  export type MessageStreamEvent = RawMessageStreamEvent;
@@ -951,6 +1243,8 @@ export interface MessageCreateParamsBase {
951
1243
  * [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
952
1244
  * the top-level `system` parameter — there is no `"system"` role for input
953
1245
  * messages in the Messages API.
1246
+ *
1247
+ * There is a limit of 100000 messages in a single request.
954
1248
  */
955
1249
  messages: Array<MessageParam>;
956
1250
 
@@ -1260,6 +1554,8 @@ export interface MessageCountTokensParams {
1260
1554
  * [system prompt](https://docs.anthropic.com/en/docs/system-prompts), you can use
1261
1555
  * the top-level `system` parameter — there is no `"system"` role for input
1262
1556
  * messages in the Messages API.
1557
+ *
1558
+ * There is a limit of 100000 messages in a single request.
1263
1559
  */
1264
1560
  messages: Array<MessageParam>;
1265
1561
 
@@ -1386,8 +1682,10 @@ export declare namespace Messages {
1386
1682
  type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
1387
1683
  type CitationPageLocation as CitationPageLocation,
1388
1684
  type CitationPageLocationParam as CitationPageLocationParam,
1685
+ type CitationWebSearchResultLocationParam as CitationWebSearchResultLocationParam,
1389
1686
  type CitationsConfigParam as CitationsConfigParam,
1390
1687
  type CitationsDelta as CitationsDelta,
1688
+ type CitationsWebSearchResultLocation as CitationsWebSearchResultLocation,
1391
1689
  type ContentBlock as ContentBlock,
1392
1690
  type ContentBlockParam as ContentBlockParam,
1393
1691
  type ContentBlockSource as ContentBlockSource,
@@ -1414,6 +1712,9 @@ export declare namespace Messages {
1414
1712
  type RawMessageStreamEvent as RawMessageStreamEvent,
1415
1713
  type RedactedThinkingBlock as RedactedThinkingBlock,
1416
1714
  type RedactedThinkingBlockParam as RedactedThinkingBlockParam,
1715
+ type ServerToolUsage as ServerToolUsage,
1716
+ type ServerToolUseBlock as ServerToolUseBlock,
1717
+ type ServerToolUseBlockParam as ServerToolUseBlockParam,
1417
1718
  type SignatureDelta as SignatureDelta,
1418
1719
  type StopReason as StopReason,
1419
1720
  type TextBlock as TextBlock,
@@ -1442,6 +1743,15 @@ export declare namespace Messages {
1442
1743
  type URLImageSource as URLImageSource,
1443
1744
  type URLPDFSource as URLPDFSource,
1444
1745
  type Usage as Usage,
1746
+ type WebSearchResultBlock as WebSearchResultBlock,
1747
+ type WebSearchResultBlockParam as WebSearchResultBlockParam,
1748
+ type WebSearchTool20250305 as WebSearchTool20250305,
1749
+ type WebSearchToolRequestError as WebSearchToolRequestError,
1750
+ type WebSearchToolResultBlock as WebSearchToolResultBlock,
1751
+ type WebSearchToolResultBlockContent as WebSearchToolResultBlockContent,
1752
+ type WebSearchToolResultBlockParam as WebSearchToolResultBlockParam,
1753
+ type WebSearchToolResultBlockParamContent as WebSearchToolResultBlockParamContent,
1754
+ type WebSearchToolResultError as WebSearchToolResultError,
1445
1755
  type MessageStreamEvent as MessageStreamEvent,
1446
1756
  type MessageStartEvent as MessageStartEvent,
1447
1757
  type MessageDeltaEvent as MessageDeltaEvent,
@@ -3,6 +3,7 @@
3
3
  import { APIResource } from "../resource.js";
4
4
  import { isRequestOptions } from "../core.js";
5
5
  import * as Core from "../core.js";
6
+ import * as BetaAPI from "./beta/beta.js";
6
7
  import { Page, type PageParams } from "../pagination.js";
7
8
 
8
9
  export class Models extends APIResource {
@@ -12,8 +13,28 @@ export class Models extends APIResource {
12
13
  * The Models API response can be used to determine information about a specific
13
14
  * model or resolve a model alias to a model ID.
14
15
  */
15
- retrieve(modelId: string, options?: Core.RequestOptions): Core.APIPromise<ModelInfo> {
16
- return this._client.get(`/v1/models/${modelId}`, options);
16
+ retrieve(
17
+ modelId: string,
18
+ params?: ModelRetrieveParams,
19
+ options?: Core.RequestOptions,
20
+ ): Core.APIPromise<ModelInfo>;
21
+ retrieve(modelId: string, options?: Core.RequestOptions): Core.APIPromise<ModelInfo>;
22
+ retrieve(
23
+ modelId: string,
24
+ params: ModelRetrieveParams | Core.RequestOptions = {},
25
+ options?: Core.RequestOptions,
26
+ ): Core.APIPromise<ModelInfo> {
27
+ if (isRequestOptions(params)) {
28
+ return this.retrieve(modelId, {}, params);
29
+ }
30
+ const { betas } = params;
31
+ return this._client.get(`/v1/models/${modelId}`, {
32
+ ...options,
33
+ headers: {
34
+ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
35
+ ...options?.headers,
36
+ },
37
+ });
17
38
  }
18
39
 
19
40
  /**
@@ -22,16 +43,24 @@ export class Models extends APIResource {
22
43
  * The Models API response can be used to determine which models are available for
23
44
  * use in the API. More recently released models are listed first.
24
45
  */
25
- list(query?: ModelListParams, options?: Core.RequestOptions): Core.PagePromise<ModelInfosPage, ModelInfo>;
46
+ list(params?: ModelListParams, options?: Core.RequestOptions): Core.PagePromise<ModelInfosPage, ModelInfo>;
26
47
  list(options?: Core.RequestOptions): Core.PagePromise<ModelInfosPage, ModelInfo>;
27
48
  list(
28
- query: ModelListParams | Core.RequestOptions = {},
49
+ params: ModelListParams | Core.RequestOptions = {},
29
50
  options?: Core.RequestOptions,
30
51
  ): Core.PagePromise<ModelInfosPage, ModelInfo> {
31
- if (isRequestOptions(query)) {
32
- return this.list({}, query);
52
+ if (isRequestOptions(params)) {
53
+ return this.list({}, params);
33
54
  }
34
- return this._client.getAPIList('/v1/models', ModelInfosPage, { query, ...options });
55
+ const { betas, ...query } = params;
56
+ return this._client.getAPIList('/v1/models', ModelInfosPage, {
57
+ query,
58
+ ...options,
59
+ headers: {
60
+ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
61
+ ...options?.headers,
62
+ },
63
+ });
35
64
  }
36
65
  }
37
66
 
@@ -62,7 +91,19 @@ export interface ModelInfo {
62
91
  type: 'model';
63
92
  }
64
93
 
65
- export interface ModelListParams extends PageParams {}
94
+ export interface ModelRetrieveParams {
95
+ /**
96
+ * Optional header to specify the beta version(s) you want to use.
97
+ */
98
+ betas?: Array<BetaAPI.AnthropicBeta>;
99
+ }
100
+
101
+ export interface ModelListParams extends PageParams {
102
+ /**
103
+ * Header param: Optional header to specify the beta version(s) you want to use.
104
+ */
105
+ betas?: Array<BetaAPI.AnthropicBeta>;
106
+ }
66
107
 
67
108
  Models.ModelInfosPage = ModelInfosPage;
68
109
 
@@ -70,6 +111,7 @@ export declare namespace Models {
70
111
  export {
71
112
  type ModelInfo as ModelInfo,
72
113
  ModelInfosPage as ModelInfosPage,
114
+ type ModelRetrieveParams as ModelRetrieveParams,
73
115
  type ModelListParams as ModelListParams,
74
116
  };
75
117
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.40.0'; // x-release-please-version
1
+ export const VERSION = '0.41.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.40.0";
1
+ export declare const VERSION = "0.41.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.40.0'; // x-release-please-version
4
+ exports.VERSION = '0.41.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.40.0'; // x-release-please-version
1
+ export const VERSION = '0.41.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map