@anthropic-ai/sdk 0.105.0 → 0.107.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 (211) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +16 -1
  3. package/client.d.mts +2 -2
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +2 -2
  6. package/client.d.ts.map +1 -1
  7. package/client.js.map +1 -1
  8. package/client.mjs.map +1 -1
  9. package/core/streaming.d.mts.map +1 -1
  10. package/core/streaming.d.ts.map +1 -1
  11. package/core/streaming.js +2 -1
  12. package/core/streaming.js.map +1 -1
  13. package/core/streaming.mjs +2 -1
  14. package/core/streaming.mjs.map +1 -1
  15. package/helpers/beta/mcp.d.mts +1 -1
  16. package/helpers/beta/mcp.d.mts.map +1 -1
  17. package/helpers/beta/mcp.d.ts +1 -1
  18. package/helpers/beta/mcp.d.ts.map +1 -1
  19. package/helpers/beta/mcp.js +1 -1
  20. package/helpers/beta/mcp.js.map +1 -1
  21. package/helpers/beta/mcp.mjs +1 -1
  22. package/helpers/beta/mcp.mjs.map +1 -1
  23. package/internal/headers.d.mts +7 -0
  24. package/internal/headers.d.mts.map +1 -1
  25. package/internal/headers.d.ts +7 -0
  26. package/internal/headers.d.ts.map +1 -1
  27. package/internal/headers.js +45 -4
  28. package/internal/headers.js.map +1 -1
  29. package/internal/headers.mjs +43 -3
  30. package/internal/headers.mjs.map +1 -1
  31. package/internal/stainless-helper-header.d.mts +60 -0
  32. package/internal/stainless-helper-header.d.mts.map +1 -0
  33. package/internal/stainless-helper-header.d.ts +60 -0
  34. package/internal/stainless-helper-header.d.ts.map +1 -0
  35. package/{lib → internal}/stainless-helper-header.js +27 -6
  36. package/internal/stainless-helper-header.js.map +1 -0
  37. package/{lib → internal}/stainless-helper-header.mjs +25 -5
  38. package/internal/stainless-helper-header.mjs.map +1 -0
  39. package/lib/BetaMessageStream.d.mts.map +1 -1
  40. package/lib/BetaMessageStream.d.ts.map +1 -1
  41. package/lib/BetaMessageStream.js +2 -1
  42. package/lib/BetaMessageStream.js.map +1 -1
  43. package/lib/BetaMessageStream.mjs +2 -1
  44. package/lib/BetaMessageStream.mjs.map +1 -1
  45. package/lib/MessageStream.d.mts.map +1 -1
  46. package/lib/MessageStream.d.ts.map +1 -1
  47. package/lib/MessageStream.js +2 -1
  48. package/lib/MessageStream.js.map +1 -1
  49. package/lib/MessageStream.mjs +2 -1
  50. package/lib/MessageStream.mjs.map +1 -1
  51. package/lib/helper-client.d.mts +2 -20
  52. package/lib/helper-client.d.mts.map +1 -1
  53. package/lib/helper-client.d.ts +2 -20
  54. package/lib/helper-client.d.ts.map +1 -1
  55. package/lib/helper-client.js +2 -1
  56. package/lib/helper-client.js.map +1 -1
  57. package/lib/helper-client.mjs +2 -1
  58. package/lib/helper-client.mjs.map +1 -1
  59. package/lib/middleware.d.mts.map +1 -1
  60. package/lib/middleware.d.ts.map +1 -1
  61. package/lib/middleware.js +7 -5
  62. package/lib/middleware.js.map +1 -1
  63. package/lib/middleware.mjs +7 -5
  64. package/lib/middleware.mjs.map +1 -1
  65. package/lib/tools/BetaToolRunner.d.mts.map +1 -1
  66. package/lib/tools/BetaToolRunner.d.ts.map +1 -1
  67. package/lib/tools/BetaToolRunner.js +11 -5
  68. package/lib/tools/BetaToolRunner.js.map +1 -1
  69. package/lib/tools/BetaToolRunner.mjs +11 -5
  70. package/lib/tools/BetaToolRunner.mjs.map +1 -1
  71. package/lib/tools/SessionToolRunner.d.mts.map +1 -1
  72. package/lib/tools/SessionToolRunner.d.ts.map +1 -1
  73. package/lib/tools/SessionToolRunner.js +2 -3
  74. package/lib/tools/SessionToolRunner.js.map +1 -1
  75. package/lib/tools/SessionToolRunner.mjs +2 -3
  76. package/lib/tools/SessionToolRunner.mjs.map +1 -1
  77. package/package.json +1 -1
  78. package/resources/beta/agents/agents.d.mts +7 -2
  79. package/resources/beta/agents/agents.d.mts.map +1 -1
  80. package/resources/beta/agents/agents.d.ts +7 -2
  81. package/resources/beta/agents/agents.d.ts.map +1 -1
  82. package/resources/beta/agents/agents.js.map +1 -1
  83. package/resources/beta/agents/agents.mjs.map +1 -1
  84. package/resources/beta/beta.d.mts +2 -2
  85. package/resources/beta/beta.d.mts.map +1 -1
  86. package/resources/beta/beta.d.ts +2 -2
  87. package/resources/beta/beta.d.ts.map +1 -1
  88. package/resources/beta/beta.js.map +1 -1
  89. package/resources/beta/beta.mjs.map +1 -1
  90. package/resources/beta/deployments.d.mts +18 -6
  91. package/resources/beta/deployments.d.mts.map +1 -1
  92. package/resources/beta/deployments.d.ts +18 -6
  93. package/resources/beta/deployments.d.ts.map +1 -1
  94. package/resources/beta/deployments.js +18 -6
  95. package/resources/beta/deployments.js.map +1 -1
  96. package/resources/beta/deployments.mjs +18 -6
  97. package/resources/beta/deployments.mjs.map +1 -1
  98. package/resources/beta/files.js +1 -1
  99. package/resources/beta/files.js.map +1 -1
  100. package/resources/beta/files.mjs +1 -1
  101. package/resources/beta/files.mjs.map +1 -1
  102. package/resources/beta/index.d.mts +1 -1
  103. package/resources/beta/index.d.mts.map +1 -1
  104. package/resources/beta/index.d.ts +1 -1
  105. package/resources/beta/index.d.ts.map +1 -1
  106. package/resources/beta/index.js.map +1 -1
  107. package/resources/beta/index.mjs.map +1 -1
  108. package/resources/beta/messages/batches.d.mts +37 -26
  109. package/resources/beta/messages/batches.d.mts.map +1 -1
  110. package/resources/beta/messages/batches.d.ts +37 -26
  111. package/resources/beta/messages/batches.d.ts.map +1 -1
  112. package/resources/beta/messages/batches.js +11 -8
  113. package/resources/beta/messages/batches.js.map +1 -1
  114. package/resources/beta/messages/batches.mjs +11 -8
  115. package/resources/beta/messages/batches.mjs.map +1 -1
  116. package/resources/beta/messages/index.d.mts +1 -1
  117. package/resources/beta/messages/index.d.mts.map +1 -1
  118. package/resources/beta/messages/index.d.ts +1 -1
  119. package/resources/beta/messages/index.d.ts.map +1 -1
  120. package/resources/beta/messages/index.js.map +1 -1
  121. package/resources/beta/messages/index.mjs.map +1 -1
  122. package/resources/beta/messages/messages.d.mts +170 -39
  123. package/resources/beta/messages/messages.d.mts.map +1 -1
  124. package/resources/beta/messages/messages.d.ts +170 -39
  125. package/resources/beta/messages/messages.d.ts.map +1 -1
  126. package/resources/beta/messages/messages.js +12 -6
  127. package/resources/beta/messages/messages.js.map +1 -1
  128. package/resources/beta/messages/messages.mjs +12 -6
  129. package/resources/beta/messages/messages.mjs.map +1 -1
  130. package/resources/completions.d.mts +12 -7
  131. package/resources/completions.d.mts.map +1 -1
  132. package/resources/completions.d.ts +12 -7
  133. package/resources/completions.d.ts.map +1 -1
  134. package/resources/index.d.mts +1 -1
  135. package/resources/index.d.mts.map +1 -1
  136. package/resources/index.d.ts +1 -1
  137. package/resources/index.d.ts.map +1 -1
  138. package/resources/index.js.map +1 -1
  139. package/resources/index.mjs.map +1 -1
  140. package/resources/messages/batches.d.mts +19 -10
  141. package/resources/messages/batches.d.mts.map +1 -1
  142. package/resources/messages/batches.d.ts +19 -10
  143. package/resources/messages/batches.d.ts.map +1 -1
  144. package/resources/messages/batches.js +16 -8
  145. package/resources/messages/batches.js.map +1 -1
  146. package/resources/messages/batches.mjs +16 -8
  147. package/resources/messages/batches.mjs.map +1 -1
  148. package/resources/messages/index.d.mts +1 -1
  149. package/resources/messages/index.d.mts.map +1 -1
  150. package/resources/messages/index.d.ts +1 -1
  151. package/resources/messages/index.d.ts.map +1 -1
  152. package/resources/messages/index.js.map +1 -1
  153. package/resources/messages/index.mjs.map +1 -1
  154. package/resources/messages/messages.d.mts +209 -68
  155. package/resources/messages/messages.d.mts.map +1 -1
  156. package/resources/messages/messages.d.ts +209 -68
  157. package/resources/messages/messages.d.ts.map +1 -1
  158. package/resources/messages/messages.js +20 -7
  159. package/resources/messages/messages.js.map +1 -1
  160. package/resources/messages/messages.mjs +20 -7
  161. package/resources/messages/messages.mjs.map +1 -1
  162. package/src/client.ts +4 -0
  163. package/src/core/streaming.ts +2 -1
  164. package/src/helpers/beta/mcp.ts +1 -1
  165. package/src/internal/headers.ts +47 -4
  166. package/src/internal/stainless-helper-header.ts +122 -0
  167. package/src/lib/BetaMessageStream.ts +2 -1
  168. package/src/lib/MessageStream.ts +2 -1
  169. package/src/lib/helper-client.ts +6 -9
  170. package/src/lib/middleware.ts +10 -4
  171. package/src/lib/tools/BetaToolRunner.ts +15 -6
  172. package/src/lib/tools/SessionToolRunner.ts +2 -4
  173. package/src/resources/beta/agents/agents.ts +7 -2
  174. package/src/resources/beta/beta.ts +4 -0
  175. package/src/resources/beta/deployments.ts +18 -6
  176. package/src/resources/beta/files.ts +1 -1
  177. package/src/resources/beta/index.ts +2 -0
  178. package/src/resources/beta/messages/batches.ts +43 -29
  179. package/src/resources/beta/messages/index.ts +2 -0
  180. package/src/resources/beta/messages/messages.ts +213 -41
  181. package/src/resources/completions.ts +12 -7
  182. package/src/resources/index.ts +2 -0
  183. package/src/resources/messages/batches.ts +29 -11
  184. package/src/resources/messages/index.ts +2 -0
  185. package/src/resources/messages/messages.ts +260 -71
  186. package/src/tools/agent-toolset/fs-util.ts +7 -1
  187. package/src/tools/agent-toolset/node.ts +19 -3
  188. package/src/version.ts +1 -1
  189. package/tools/agent-toolset/fs-util.d.mts.map +1 -1
  190. package/tools/agent-toolset/fs-util.d.ts.map +1 -1
  191. package/tools/agent-toolset/fs-util.js +7 -1
  192. package/tools/agent-toolset/fs-util.js.map +1 -1
  193. package/tools/agent-toolset/fs-util.mjs +7 -1
  194. package/tools/agent-toolset/fs-util.mjs.map +1 -1
  195. package/tools/agent-toolset/node.d.mts.map +1 -1
  196. package/tools/agent-toolset/node.d.ts.map +1 -1
  197. package/tools/agent-toolset/node.js +21 -4
  198. package/tools/agent-toolset/node.js.map +1 -1
  199. package/tools/agent-toolset/node.mjs +21 -4
  200. package/tools/agent-toolset/node.mjs.map +1 -1
  201. package/version.d.mts +1 -1
  202. package/version.d.ts +1 -1
  203. package/version.js +1 -1
  204. package/version.mjs +1 -1
  205. package/lib/stainless-helper-header.d.mts +0 -34
  206. package/lib/stainless-helper-header.d.mts.map +0 -1
  207. package/lib/stainless-helper-header.d.ts +0 -34
  208. package/lib/stainless-helper-header.d.ts.map +0 -1
  209. package/lib/stainless-helper-header.js.map +0 -1
  210. package/lib/stainless-helper-header.mjs.map +0 -1
  211. package/src/lib/stainless-helper-header.ts +0 -80
@@ -9,7 +9,7 @@ import { Stream } from '../../../core/streaming';
9
9
  import { MODEL_NONSTREAMING_TOKENS } from '../../../internal/constants';
10
10
  import { buildHeaders } from '../../../internal/headers';
11
11
  import { RequestOptions } from '../../../internal/request-options';
12
- import { stainlessHelperHeader } from '../../../lib/stainless-helper-header';
12
+ import { stainlessHelperHeader } from '../../../internal/stainless-helper-header';
13
13
  import {
14
14
  parseBetaMessage,
15
15
  type ExtractParsedContentFromBetaParams,
@@ -84,7 +84,7 @@ export class Messages extends APIResource {
84
84
  * conversations.
85
85
  *
86
86
  * Learn more about the Messages API in our
87
- * [user guide](https://docs.claude.com/en/docs/initial-setup)
87
+ * [user guide](https://platform.claude.com/docs/en/get-started)
88
88
  *
89
89
  * @example
90
90
  * ```ts
@@ -111,7 +111,7 @@ export class Messages extends APIResource {
111
111
  // Transform deprecated output_format to output_config.format
112
112
  const modifiedParams = transformOutputFormat(params);
113
113
 
114
- const { betas, ...body } = modifiedParams;
114
+ const { betas, user_profile_id, ...body } = modifiedParams;
115
115
 
116
116
  if (body.model in DEPRECATED_MODELS) {
117
117
  console.warn(
@@ -145,7 +145,10 @@ export class Messages extends APIResource {
145
145
  timeout: timeout ?? 600000,
146
146
  ...options,
147
147
  headers: buildHeaders([
148
- { ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined) },
148
+ {
149
+ ...(betas?.toString() != null ? { 'anthropic-beta': betas?.toString() } : undefined),
150
+ ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
151
+ },
149
152
  helperHeader,
150
153
  options?.headers,
151
154
  ]),
@@ -203,7 +206,7 @@ export class Messages extends APIResource {
203
206
  * including tools, images, and documents, without creating it.
204
207
  *
205
208
  * Learn more about token counting in our
206
- * [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting)
209
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/token-counting)
207
210
  *
208
211
  * @example
209
212
  * ```ts
@@ -221,12 +224,15 @@ export class Messages extends APIResource {
221
224
  // Transform deprecated output_format to output_config.format
222
225
  const modifiedParams = transformOutputFormat(params);
223
226
 
224
- const { betas, ...body } = modifiedParams;
227
+ const { betas, user_profile_id, ...body } = modifiedParams;
225
228
  return this._client.post('/v1/messages/count_tokens?beta=true', {
226
229
  body,
227
230
  ...options,
228
231
  headers: buildHeaders([
229
- { 'anthropic-beta': [...(betas ?? []), 'token-counting-2024-11-01'].toString() },
232
+ {
233
+ 'anthropic-beta': [...(betas ?? []), 'token-counting-2024-11-01'].toString(),
234
+ ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined),
235
+ },
230
236
  options?.headers,
231
237
  ]),
232
238
  });
@@ -588,7 +594,9 @@ export interface BetaCacheControlEphemeral {
588
594
  * - `5m`: 5 minutes
589
595
  * - `1h`: 1 hour
590
596
  *
591
- * Defaults to `5m`.
597
+ * Defaults to `5m`. See
598
+ * [prompt caching pricing](https://platform.claude.com/docs/en/build-with-claude/prompt-caching)
599
+ * for details.
592
600
  */
593
601
  ttl?: '5m' | '1h';
594
602
  }
@@ -1732,7 +1740,7 @@ export interface BetaFallbackRefusalTrigger {
1732
1740
  /**
1733
1741
  * The policy category that triggered a refusal.
1734
1742
  */
1735
- category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | null;
1743
+ category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | 'military_weapons' | null;
1736
1744
 
1737
1745
  type: 'refusal';
1738
1746
  }
@@ -2504,7 +2512,7 @@ export interface BetaRefusalStopDetails {
2504
2512
  /**
2505
2513
  * The policy category that triggered a refusal.
2506
2514
  */
2507
- category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | null;
2515
+ category: 'cyber' | 'bio' | 'frontier_llm' | 'reasoning_extraction' | 'military_weapons' | null;
2508
2516
 
2509
2517
  /**
2510
2518
  * Human-readable explanation of the refusal.
@@ -2988,7 +2996,7 @@ export interface BetaThinkingConfigEnabled {
2988
2996
  * Must be ≥1024 and less than `max_tokens`.
2989
2997
  *
2990
2998
  * See
2991
- * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
2999
+ * [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking)
2992
3000
  * for details.
2993
3001
  */
2994
3002
  budget_tokens: number;
@@ -3012,7 +3020,7 @@ export interface BetaThinkingConfigEnabled {
3012
3020
  * tokens and counts towards your `max_tokens` limit.
3013
3021
  *
3014
3022
  * See
3015
- * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
3023
+ * [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking)
3016
3024
  * for details.
3017
3025
  */
3018
3026
  export type BetaThinkingConfigParam =
@@ -3740,6 +3748,8 @@ export type BetaToolUnion =
3740
3748
  | BetaWebSearchTool20260209
3741
3749
  | BetaWebFetchTool20260209
3742
3750
  | BetaWebFetchTool20260309
3751
+ | BetaWebSearchTool20260318
3752
+ | BetaWebFetchTool20260318
3743
3753
  | BetaAdvisorTool20260301
3744
3754
  | BetaToolSearchToolBm25_20251119
3745
3755
  | BetaToolSearchToolRegex20251119
@@ -4115,6 +4125,81 @@ export interface BetaWebFetchTool20260309 {
4115
4125
  use_cache?: boolean;
4116
4126
  }
4117
4127
 
4128
+ export interface BetaWebFetchTool20260318 {
4129
+ /**
4130
+ * Name of the tool.
4131
+ *
4132
+ * This is how the tool will be called by the model and in `tool_use` blocks.
4133
+ */
4134
+ name: 'web_fetch';
4135
+
4136
+ type: 'web_fetch_20260318';
4137
+
4138
+ allowed_callers?: Array<
4139
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
4140
+ >;
4141
+
4142
+ /**
4143
+ * List of domains to allow fetching from
4144
+ */
4145
+ allowed_domains?: Array<string> | null;
4146
+
4147
+ /**
4148
+ * List of domains to block fetching from
4149
+ */
4150
+ blocked_domains?: Array<string> | null;
4151
+
4152
+ /**
4153
+ * Create a cache control breakpoint at this content block.
4154
+ */
4155
+ cache_control?: BetaCacheControlEphemeral | null;
4156
+
4157
+ /**
4158
+ * Citations configuration for fetched documents. Citations are disabled by
4159
+ * default.
4160
+ */
4161
+ citations?: BetaCitationsConfigParam | null;
4162
+
4163
+ /**
4164
+ * If true, tool will not be included in initial system prompt. Only loaded when
4165
+ * returned via tool_reference from tool search.
4166
+ */
4167
+ defer_loading?: boolean;
4168
+
4169
+ /**
4170
+ * Maximum number of tokens used by including web page text content in the context.
4171
+ * The limit is approximate and does not apply to binary content such as PDFs.
4172
+ */
4173
+ max_content_tokens?: number | null;
4174
+
4175
+ /**
4176
+ * Maximum number of times the tool can be used in the API request.
4177
+ */
4178
+ max_uses?: number | null;
4179
+
4180
+ /**
4181
+ * How this tool's result blocks appear in the API response when the result was
4182
+ * consumed by a completed code_execution call in the same turn. 'full' returns the
4183
+ * complete content (default). 'excluded' drops the nested server_tool_use and
4184
+ * result block pair entirely. Results from direct calls, or from code_execution
4185
+ * calls that paused before completing, are always returned in full so they can be
4186
+ * sent back on the next turn.
4187
+ */
4188
+ response_inclusion?: 'full' | 'excluded';
4189
+
4190
+ /**
4191
+ * When true, guarantees schema validation on tool names and inputs
4192
+ */
4193
+ strict?: boolean;
4194
+
4195
+ /**
4196
+ * Whether to use cached content. Set to false to bypass the cache and fetch fresh
4197
+ * content. Only set to false when the user explicitly requests fresh content or
4198
+ * when fetching rapidly-changing sources.
4199
+ */
4200
+ use_cache?: boolean;
4201
+ }
4202
+
4118
4203
  export interface BetaWebFetchToolResultBlock {
4119
4204
  content: BetaWebFetchToolResultErrorBlock | BetaWebFetchBlock;
4120
4205
 
@@ -4301,6 +4386,70 @@ export interface BetaWebSearchTool20260209 {
4301
4386
  user_location?: BetaUserLocation | null;
4302
4387
  }
4303
4388
 
4389
+ export interface BetaWebSearchTool20260318 {
4390
+ /**
4391
+ * Name of the tool.
4392
+ *
4393
+ * This is how the tool will be called by the model and in `tool_use` blocks.
4394
+ */
4395
+ name: 'web_search';
4396
+
4397
+ type: 'web_search_20260318';
4398
+
4399
+ allowed_callers?: Array<
4400
+ 'direct' | 'code_execution_20250825' | 'code_execution_20260120' | 'code_execution_20260521'
4401
+ >;
4402
+
4403
+ /**
4404
+ * If provided, only these domains will be included in results. Cannot be used
4405
+ * alongside `blocked_domains`.
4406
+ */
4407
+ allowed_domains?: Array<string> | null;
4408
+
4409
+ /**
4410
+ * If provided, these domains will never appear in results. Cannot be used
4411
+ * alongside `allowed_domains`.
4412
+ */
4413
+ blocked_domains?: Array<string> | null;
4414
+
4415
+ /**
4416
+ * Create a cache control breakpoint at this content block.
4417
+ */
4418
+ cache_control?: BetaCacheControlEphemeral | null;
4419
+
4420
+ /**
4421
+ * If true, tool will not be included in initial system prompt. Only loaded when
4422
+ * returned via tool_reference from tool search.
4423
+ */
4424
+ defer_loading?: boolean;
4425
+
4426
+ /**
4427
+ * Maximum number of times the tool can be used in the API request.
4428
+ */
4429
+ max_uses?: number | null;
4430
+
4431
+ /**
4432
+ * How this tool's result blocks appear in the API response when the result was
4433
+ * consumed by a completed code_execution call in the same turn. 'full' returns the
4434
+ * complete content (default). 'excluded' drops the nested server_tool_use and
4435
+ * result block pair entirely. Results from direct calls, or from code_execution
4436
+ * calls that paused before completing, are always returned in full so they can be
4437
+ * sent back on the next turn.
4438
+ */
4439
+ response_inclusion?: 'full' | 'excluded';
4440
+
4441
+ /**
4442
+ * When true, guarantees schema validation on tool names and inputs
4443
+ */
4444
+ strict?: boolean;
4445
+
4446
+ /**
4447
+ * Parameters for the user's location. Used to provide more relevant search
4448
+ * results.
4449
+ */
4450
+ user_location?: BetaUserLocation | null;
4451
+ }
4452
+
4304
4453
  export interface BetaWebSearchToolRequestError {
4305
4454
  error_code: BetaWebSearchToolResultErrorCode;
4306
4455
 
@@ -4375,11 +4524,12 @@ export interface MessageCreateParamsBase {
4375
4524
  * only specifies the absolute maximum number of tokens to generate.
4376
4525
  *
4377
4526
  * Set to `0` to populate the
4378
- * [prompt cache](https://docs.claude.com/en/docs/build-with-claude/prompt-caching#pre-warming-the-cache)
4527
+ * [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching#pre-warming-the-cache)
4379
4528
  * without generating a response.
4380
4529
  *
4381
4530
  * Different models have different maximum values for this parameter. See
4382
- * [models](https://docs.claude.com/en/docs/models-overview) for details.
4531
+ * [models](https://platform.claude.com/docs/en/about-claude/models/overview) for
4532
+ * details.
4383
4533
  */
4384
4534
  max_tokens: number;
4385
4535
 
@@ -4441,12 +4591,13 @@ export interface MessageCreateParamsBase {
4441
4591
  * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
4442
4592
  * ```
4443
4593
  *
4444
- * See [input examples](https://docs.claude.com/en/api/messages-examples).
4594
+ * See
4595
+ * [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).
4445
4596
  *
4446
4597
  * Note that if you want to include a
4447
- * [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the
4448
- * top-level `system` parameter — there is no `"system"` role for input messages in
4449
- * the Messages API.
4598
+ * [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role),
4599
+ * you can use the top-level `system` parameter — there is no `"system"` role for
4600
+ * input messages in the Messages API.
4450
4601
  *
4451
4602
  * There is a limit of 100,000 messages in a single request.
4452
4603
  */
@@ -4551,7 +4702,8 @@ export interface MessageCreateParamsBase {
4551
4702
  * standard capacity for this request.
4552
4703
  *
4553
4704
  * Anthropic offers different levels of service for your API requests. See
4554
- * [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.
4705
+ * [service-tiers](https://platform.claude.com/docs/en/api/service-tiers) for
4706
+ * details.
4555
4707
  */
4556
4708
  service_tier?: 'auto' | 'standard_only';
4557
4709
 
@@ -4578,7 +4730,8 @@ export interface MessageCreateParamsBase {
4578
4730
  * Body param: Whether to incrementally stream the response using server-sent
4579
4731
  * events.
4580
4732
  *
4581
- * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
4733
+ * See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming)
4734
+ * for details.
4582
4735
  */
4583
4736
  stream?: boolean;
4584
4737
 
@@ -4587,7 +4740,7 @@ export interface MessageCreateParamsBase {
4587
4740
  *
4588
4741
  * A system prompt is a way of providing context and instructions to Claude, such
4589
4742
  * as specifying a particular goal or role. See our
4590
- * [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).
4743
+ * [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).
4591
4744
  */
4592
4745
  system?: string | Array<BetaTextBlockParam>;
4593
4746
 
@@ -4606,7 +4759,7 @@ export interface MessageCreateParamsBase {
4606
4759
  * tokens and counts towards your `max_tokens` limit.
4607
4760
  *
4608
4761
  * See
4609
- * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
4762
+ * [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking)
4610
4763
  * for details.
4611
4764
  */
4612
4765
  thinking?: BetaThinkingConfigParam;
@@ -4627,9 +4780,9 @@ export interface MessageCreateParamsBase {
4627
4780
  *
4628
4781
  * There are two types of tools: **client tools** and **server tools**. The
4629
4782
  * behavior described below applies to client tools. For
4630
- * [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
4783
+ * [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools),
4631
4784
  * see their individual documentation as each has its own behavior (e.g., the
4632
- * [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
4785
+ * [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).
4633
4786
  *
4634
4787
  * Each tool definition includes:
4635
4788
  *
@@ -4692,7 +4845,9 @@ export interface MessageCreateParamsBase {
4692
4845
  * functions, or more generally whenever you want the model to produce a particular
4693
4846
  * JSON structure of output.
4694
4847
  *
4695
- * See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.
4848
+ * See our
4849
+ * [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview)
4850
+ * for more details.
4696
4851
  */
4697
4852
  tools?: Array<BetaToolUnion>;
4698
4853
 
@@ -4710,15 +4865,16 @@ export interface MessageCreateParamsBase {
4710
4865
  top_p?: number;
4711
4866
 
4712
4867
  /**
4713
- * Body param: The user profile ID to attribute this request to. Use when acting on
4714
- * behalf of a party other than your organization.
4868
+ * Header param: Optional header to specify the beta version(s) you want to use.
4715
4869
  */
4716
- user_profile_id?: string | null;
4870
+ betas?: Array<BetaAPI.AnthropicBeta>;
4717
4871
 
4718
4872
  /**
4719
- * Header param: Optional header to specify the beta version(s) you want to use.
4873
+ * Header param: The user profile ID to attribute this request to. Use when acting
4874
+ * on behalf of a party other than your organization. Requires the `user-profiles`
4875
+ * beta header.
4720
4876
  */
4721
- betas?: Array<BetaAPI.AnthropicBeta>;
4877
+ user_profile_id?: string;
4722
4878
  }
4723
4879
 
4724
4880
  export namespace MessageCreateParams {
@@ -4731,7 +4887,8 @@ export interface MessageCreateParamsNonStreaming extends MessageCreateParamsBase
4731
4887
  * Body param: Whether to incrementally stream the response using server-sent
4732
4888
  * events.
4733
4889
  *
4734
- * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
4890
+ * See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming)
4891
+ * for details.
4735
4892
  */
4736
4893
  stream?: false;
4737
4894
  }
@@ -4741,7 +4898,8 @@ export interface MessageCreateParamsStreaming extends MessageCreateParamsBase {
4741
4898
  * Body param: Whether to incrementally stream the response using server-sent
4742
4899
  * events.
4743
4900
  *
4744
- * See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
4901
+ * See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming)
4902
+ * for details.
4745
4903
  */
4746
4904
  stream: true;
4747
4905
  }
@@ -4805,12 +4963,13 @@ export interface MessageCountTokensParams {
4805
4963
  * { "role": "user", "content": [{ "type": "text", "text": "Hello, Claude" }] }
4806
4964
  * ```
4807
4965
  *
4808
- * See [input examples](https://docs.claude.com/en/api/messages-examples).
4966
+ * See
4967
+ * [input examples](https://platform.claude.com/docs/en/build-with-claude/working-with-messages).
4809
4968
  *
4810
4969
  * Note that if you want to include a
4811
- * [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the
4812
- * top-level `system` parameter — there is no `"system"` role for input messages in
4813
- * the Messages API.
4970
+ * [system prompt](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role),
4971
+ * you can use the top-level `system` parameter — there is no `"system"` role for
4972
+ * input messages in the Messages API.
4814
4973
  *
4815
4974
  * There is a limit of 100,000 messages in a single request.
4816
4975
  */
@@ -4869,7 +5028,7 @@ export interface MessageCountTokensParams {
4869
5028
  *
4870
5029
  * A system prompt is a way of providing context and instructions to Claude, such
4871
5030
  * as specifying a particular goal or role. See our
4872
- * [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).
5031
+ * [guide to system prompts](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices#give-claude-a-role).
4873
5032
  */
4874
5033
  system?: string | Array<BetaTextBlockParam>;
4875
5034
 
@@ -4881,7 +5040,7 @@ export interface MessageCountTokensParams {
4881
5040
  * tokens and counts towards your `max_tokens` limit.
4882
5041
  *
4883
5042
  * See
4884
- * [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking)
5043
+ * [extended thinking](https://platform.claude.com/docs/en/build-with-claude/extended-thinking)
4885
5044
  * for details.
4886
5045
  */
4887
5046
  thinking?: BetaThinkingConfigParam;
@@ -4902,9 +5061,9 @@ export interface MessageCountTokensParams {
4902
5061
  *
4903
5062
  * There are two types of tools: **client tools** and **server tools**. The
4904
5063
  * behavior described below applies to client tools. For
4905
- * [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
5064
+ * [server tools](https://platform.claude.com/docs/en/agents-and-tools/tool-use/server-tools),
4906
5065
  * see their individual documentation as each has its own behavior (e.g., the
4907
- * [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
5066
+ * [web search tool](https://platform.claude.com/docs/en/agents-and-tools/tool-use/web-search-tool)).
4908
5067
  *
4909
5068
  * Each tool definition includes:
4910
5069
  *
@@ -4967,7 +5126,9 @@ export interface MessageCountTokensParams {
4967
5126
  * functions, or more generally whenever you want the model to produce a particular
4968
5127
  * JSON structure of output.
4969
5128
  *
4970
- * See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.
5129
+ * See our
5130
+ * [guide](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview)
5131
+ * for more details.
4971
5132
  */
4972
5133
  tools?: Array<
4973
5134
  | BetaTool
@@ -4990,6 +5151,8 @@ export interface MessageCountTokensParams {
4990
5151
  | BetaWebSearchTool20260209
4991
5152
  | BetaWebFetchTool20260209
4992
5153
  | BetaWebFetchTool20260309
5154
+ | BetaWebSearchTool20260318
5155
+ | BetaWebFetchTool20260318
4993
5156
  | BetaAdvisorTool20260301
4994
5157
  | BetaToolSearchToolBm25_20251119
4995
5158
  | BetaToolSearchToolRegex20251119
@@ -5000,6 +5163,13 @@ export interface MessageCountTokensParams {
5000
5163
  * Header param: Optional header to specify the beta version(s) you want to use.
5001
5164
  */
5002
5165
  betas?: Array<BetaAPI.AnthropicBeta>;
5166
+
5167
+ /**
5168
+ * Header param: The user profile ID to attribute this request to. Use when acting
5169
+ * on behalf of a party other than your organization. Requires the `user-profiles`
5170
+ * beta header.
5171
+ */
5172
+ user_profile_id?: string;
5003
5173
  }
5004
5174
 
5005
5175
  export { BetaToolRunner, type BetaToolRunnerParams } from '../../../lib/tools/BetaToolRunner';
@@ -5224,6 +5394,7 @@ export declare namespace Messages {
5224
5394
  type BetaWebFetchTool20250910 as BetaWebFetchTool20250910,
5225
5395
  type BetaWebFetchTool20260209 as BetaWebFetchTool20260209,
5226
5396
  type BetaWebFetchTool20260309 as BetaWebFetchTool20260309,
5397
+ type BetaWebFetchTool20260318 as BetaWebFetchTool20260318,
5227
5398
  type BetaWebFetchToolResultBlock as BetaWebFetchToolResultBlock,
5228
5399
  type BetaWebFetchToolResultBlockParam as BetaWebFetchToolResultBlockParam,
5229
5400
  type BetaWebFetchToolResultErrorBlock as BetaWebFetchToolResultErrorBlock,
@@ -5233,6 +5404,7 @@ export declare namespace Messages {
5233
5404
  type BetaWebSearchResultBlockParam as BetaWebSearchResultBlockParam,
5234
5405
  type BetaWebSearchTool20250305 as BetaWebSearchTool20250305,
5235
5406
  type BetaWebSearchTool20260209 as BetaWebSearchTool20260209,
5407
+ type BetaWebSearchTool20260318 as BetaWebSearchTool20260318,
5236
5408
  type BetaWebSearchToolRequestError as BetaWebSearchToolRequestError,
5237
5409
  type BetaWebSearchToolResultBlock as BetaWebSearchToolResultBlock,
5238
5410
  type BetaWebSearchToolResultBlockContent as BetaWebSearchToolResultBlockContent,
@@ -14,10 +14,10 @@ export class Completions extends APIResource {
14
14
  * [Legacy] Create a Text Completion.
15
15
  *
16
16
  * The Text Completions API is a legacy API. We recommend using the
17
- * [Messages API](https://docs.claude.com/en/api/messages) going forward.
17
+ * [Messages API](https://platform.claude.com/docs/en/api/messages) going forward.
18
18
  *
19
19
  * Future models and features will not be compatible with Text Completions. See our
20
- * [migration guide](https://docs.claude.com/en/api/migrating-from-text-completions-to-messages)
20
+ * [migration guide](https://platform.claude.com/docs/en/build-with-claude/working-with-messages)
21
21
  * for guidance in migrating from Text Completions to Messages.
22
22
  *
23
23
  * @example
@@ -122,8 +122,10 @@ export interface CompletionCreateParamsBase {
122
122
  * "\n\nHuman: {userQuestion}\n\nAssistant:"
123
123
  * ```
124
124
  *
125
- * See [prompt validation](https://docs.claude.com/en/api/prompt-validation) and
126
- * our guide to [prompt design](https://docs.claude.com/en/docs/intro-to-prompting)
125
+ * See
126
+ * [prompt validation](https://platform.claude.com/docs/en/build-with-claude/working-with-messages)
127
+ * and our guide to
128
+ * [prompt design](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview)
127
129
  * for more details.
128
130
  */
129
131
  prompt: string;
@@ -146,7 +148,8 @@ export interface CompletionCreateParamsBase {
146
148
  * Body param: Whether to incrementally stream the response using server-sent
147
149
  * events.
148
150
  *
149
- * See [streaming](https://docs.claude.com/en/api/streaming) for details.
151
+ * See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming)
152
+ * for details.
150
153
  */
151
154
  stream?: boolean;
152
155
 
@@ -191,7 +194,8 @@ export interface CompletionCreateParamsNonStreaming extends CompletionCreatePara
191
194
  * Body param: Whether to incrementally stream the response using server-sent
192
195
  * events.
193
196
  *
194
- * See [streaming](https://docs.claude.com/en/api/streaming) for details.
197
+ * See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming)
198
+ * for details.
195
199
  */
196
200
  stream?: false;
197
201
  }
@@ -201,7 +205,8 @@ export interface CompletionCreateParamsStreaming extends CompletionCreateParamsB
201
205
  * Body param: Whether to incrementally stream the response using server-sent
202
206
  * events.
203
207
  *
204
- * See [streaming](https://docs.claude.com/en/api/streaming) for details.
208
+ * See [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming)
209
+ * for details.
205
210
  */
206
211
  stream: true;
207
212
  }
@@ -173,6 +173,7 @@ export {
173
173
  type WebFetchTool20250910,
174
174
  type WebFetchTool20260209,
175
175
  type WebFetchTool20260309,
176
+ type WebFetchTool20260318,
176
177
  type WebFetchToolResultBlock,
177
178
  type WebFetchToolResultBlockParam,
178
179
  type WebFetchToolResultErrorBlock,
@@ -182,6 +183,7 @@ export {
182
183
  type WebSearchResultBlockParam,
183
184
  type WebSearchTool20250305,
184
185
  type WebSearchTool20260209,
186
+ type WebSearchTool20260318,
185
187
  type WebSearchToolRequestError,
186
188
  type WebSearchToolResultBlock,
187
189
  type WebSearchToolResultBlockContent,
@@ -20,7 +20,7 @@ export class Batches extends APIResource {
20
20
  * can take up to 24 hours to complete.
21
21
  *
22
22
  * Learn more about the Message Batches API in our
23
- * [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
23
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
24
24
  *
25
25
  * @example
26
26
  * ```ts
@@ -40,8 +40,16 @@ export class Batches extends APIResource {
40
40
  * });
41
41
  * ```
42
42
  */
43
- create(body: BatchCreateParams, options?: RequestOptions): APIPromise<MessageBatch> {
44
- return this._client.post('/v1/messages/batches', { body, ...options });
43
+ create(params: BatchCreateParams, options?: RequestOptions): APIPromise<MessageBatch> {
44
+ const { user_profile_id, ...body } = params;
45
+ return this._client.post('/v1/messages/batches', {
46
+ body,
47
+ ...options,
48
+ headers: buildHeaders([
49
+ { ...(user_profile_id != null ? { 'anthropic-user-profile-id': user_profile_id } : undefined) },
50
+ options?.headers,
51
+ ]),
52
+ });
45
53
  }
46
54
 
47
55
  /**
@@ -50,7 +58,7 @@ export class Batches extends APIResource {
50
58
  * `results_url` field in the response.
51
59
  *
52
60
  * Learn more about the Message Batches API in our
53
- * [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
61
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
54
62
  *
55
63
  * @example
56
64
  * ```ts
@@ -68,7 +76,7 @@ export class Batches extends APIResource {
68
76
  * returned first.
69
77
  *
70
78
  * Learn more about the Message Batches API in our
71
- * [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
79
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
72
80
  *
73
81
  * @example
74
82
  * ```ts
@@ -92,7 +100,7 @@ export class Batches extends APIResource {
92
100
  * like to delete an in-progress batch, you must first cancel it.
93
101
  *
94
102
  * Learn more about the Message Batches API in our
95
- * [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
103
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
96
104
  *
97
105
  * @example
98
106
  * ```ts
@@ -116,7 +124,7 @@ export class Batches extends APIResource {
116
124
  * non-interruptible.
117
125
  *
118
126
  * Learn more about the Message Batches API in our
119
- * [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
127
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
120
128
  *
121
129
  * @example
122
130
  * ```ts
@@ -137,7 +145,7 @@ export class Batches extends APIResource {
137
145
  * requests. Use the `custom_id` field to match results to requests.
138
146
  *
139
147
  * Learn more about the Message Batches API in our
140
- * [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
148
+ * [user guide](https://platform.claude.com/docs/en/build-with-claude/batch-processing)
141
149
  *
142
150
  * @example
143
151
  * ```ts
@@ -350,10 +358,19 @@ export interface MessageBatchSucceededResult {
350
358
 
351
359
  export interface BatchCreateParams {
352
360
  /**
353
- * List of requests for prompt completion. Each is an individual request to create
354
- * a Message.
361
+ * Body param: List of requests for prompt completion. Each is an individual
362
+ * request to create a Message.
355
363
  */
356
364
  requests: Array<BatchCreateParams.Request>;
365
+
366
+ /**
367
+ * Header param: The user profile ID to attribute the requests in this batch to.
368
+ * Use when acting on behalf of a party other than your organization. Requires the
369
+ * `user-profiles` beta header. Applies to every request in the batch; an
370
+ * individual request whose `user_profile_id` body field conflicts with this header
371
+ * is errored.
372
+ */
373
+ user_profile_id?: string;
357
374
  }
358
375
 
359
376
  export namespace BatchCreateParams {
@@ -369,7 +386,8 @@ export namespace BatchCreateParams {
369
386
  /**
370
387
  * Messages API creation parameters for the individual request.
371
388
  *
372
- * See the [Messages API reference](https://docs.claude.com/en/api/messages) for
389
+ * See the
390
+ * [Messages API reference](https://platform.claude.com/docs/en/api/messages) for
373
391
  * full documentation on available parameters.
374
392
  */
375
393
  params: MessagesAPI.MessageCreateParamsNonStreaming;