Skip to content

Commit b7ebb90

Browse files
Merge pull request #769 from anthropics/release-please--branches--main--changes--next
chore: release main
2 parents e5f2f90 + a171b77 commit b7ebb90

34 files changed

+1252
-81
lines changed

.release-please-manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
".": "0.51.0",
3-
"packages/vertex-sdk": "0.11.3",
4-
"packages/bedrock-sdk": "0.22.0"
2+
".": "0.52.0",
3+
"packages/vertex-sdk": "0.11.4",
4+
"packages/bedrock-sdk": "0.22.1"
55
}

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 21
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-7015ea2d98991d6c2e7931c521e36448778fe868cc1b8a21173898d67b14b819.yml
3-
openapi_spec_hash: 2007ff815a3f39af8cebe1976d50f17d
4-
config_hash: 55aeaebf89fb2ccfcd0b188fc4dc6aba
1+
configured_endpoints: 26
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-1fdf23e8226430012c21819427e8d1ed16c08c0fb2d4abf69b8e318a42e99552.yml
3+
openapi_spec_hash: 836bbb4ab7c33c37456d1842876d7aba
4+
config_hash: 7b17fe2f10f5942177ff51b0a13506fa

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# Changelog
22

3+
## 0.52.0 (2025-05-22)
4+
5+
Full Changelog: [sdk-v0.51.0...sdk-v0.52.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.51.0...sdk-v0.52.0)
6+
7+
### Features
8+
9+
* **api:** add claude 4 models, files API, code execution tool, MCP connector and more ([769f9da](https://github.com/anthropics/anthropic-sdk-typescript/commit/769f9da91cf4480d1e4aa4bb488d6d9cc2471985))
10+
11+
12+
### Chores
13+
14+
* **internal:** codegen related update ([2ed236d](https://github.com/anthropics/anthropic-sdk-typescript/commit/2ed236ddb9977a91289c4799692a583f460ce8b6))
15+
* **internal:** version bump ([8ebaf61](https://github.com/anthropics/anthropic-sdk-typescript/commit/8ebaf616d2e5c6aebc153f19a403dde41ab5a9f1))
16+
317
## 0.51.0 (2025-05-15)
418

519
Full Changelog: [sdk-v0.50.4...sdk-v0.51.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.50.4...sdk-v0.51.0)

MIGRATION.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ This affects the following methods:
7777
- `client.beta.messages.batches.delete()`
7878
- `client.beta.messages.batches.cancel()`
7979
- `client.beta.messages.batches.results()`
80+
- `client.beta.files.list()`
81+
- `client.beta.files.delete()`
82+
- `client.beta.files.download()`
83+
- `client.beta.files.retrieveMetadata()`
8084

8185
### Removed `httpAgent` in favor of `fetchOptions`
8286

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,51 @@ This SDK provides support for tool use, aka function calling. More details can b
184184

185185
We provide support for the [Anthropic Bedrock API](https://aws.amazon.com/bedrock/claude/) through a [separate package](https://github.com/anthropics/anthropic-sdk-typescript/tree/main/packages/bedrock-sdk).
186186

187+
## File uploads
188+
189+
Request parameters that correspond to file uploads can be passed in many different forms:
190+
191+
- `File` (or an object with the same structure)
192+
- a `fetch` `Response` (or an object with the same structure)
193+
- an `fs.ReadStream`
194+
- the return value of our `toFile` helper
195+
196+
Note that we recommend you set the content-type explicitly as the files API will not infer it for you:
197+
198+
```ts
199+
import fs from 'fs';
200+
import Anthropic, { toFile } from '@anthropic-ai/sdk';
201+
202+
const client = new Anthropic();
203+
204+
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
205+
await client.beta.files.upload({
206+
file: await toFile(fs.createReadStream('/path/to/file'), undefined, { type: 'application/json' }),
207+
betas: ['files-api-2025-04-14'],
208+
});
209+
210+
// Or if you have the web `File` API you can pass a `File` instance:
211+
await client.beta.files.upload({
212+
file: new File(['my bytes'], 'file.txt', { type: 'text/plain' }),
213+
betas: ['files-api-2025-04-14'],
214+
});
215+
// You can also pass a `fetch` `Response`:
216+
await client.beta.files.upload({
217+
file: await fetch('https://somesite/file'),
218+
betas: ['files-api-2025-04-14'],
219+
});
220+
221+
// Or a `Buffer` / `Uint8Array`
222+
await client.beta.files.upload({
223+
file: await toFile(Buffer.from('my bytes'), 'file', { type: 'text/plain' }),
224+
betas: ['files-api-2025-04-14'],
225+
});
226+
await client.beta.files.upload({
227+
file: await toFile(new Uint8Array([0, 1, 2]), 'file', { type: 'text/plain' }),
228+
betas: ['files-api-2025-04-14'],
229+
});
230+
```
231+
187232
## Handling errors
188233

189234
When the library is unable to connect to the API,
@@ -309,8 +354,9 @@ Passing `stream: true` or [overriding](#timeouts) the `timeout` option at the cl
309354
An expected request latency longer than the [timeout](#timeouts) for a non-streaming request
310355
will result in the client terminating the connection and retrying without receiving a response.
311356

312-
When supported by the `fetch` implementation, we set a [TCP socket keep-alive](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
313-
option in order to reduce the impact of idle connection timeouts on some networks.
357+
When supported by the `fetch` implementation, we set a [TCP socket keep-alive](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html) option in order
358+
to reduce the impact of idle connection timeouts on some networks.
359+
This can be [overriden](#configuring-an-https-agent-eg-for-proxies) by configuring a custom proxy.
314360

315361
## Auto-pagination
316362

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ before making any information public.
1616
## Reporting Non-SDK Related Security Issues
1717

1818
If you encounter security issues that are not directly related to SDKs but pertain to the services
19-
or products provided by Anthropic please follow the respective company's security reporting guidelines.
19+
or products provided by Anthropic, please follow the respective company's security reporting guidelines.
2020

2121
### Anthropic Terms and Policies
2222

23-
Please contact [email protected] for any questions or concerns regarding security of our services.
23+
Please contact [email protected] for any questions or concerns regarding the security of our services.
2424

2525
---
2626

api.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ Types:
185185
- <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFBlock</a></code>
186186
- <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFSource</a></code>
187187
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheControlEphemeral</a></code>
188+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheCreation</a></code>
188189
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationCharLocation</a></code>
189190
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationCharLocationParam</a></code>
190191
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationContentBlockLocation</a></code>
@@ -195,12 +196,32 @@ Types:
195196
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsConfigParam</a></code>
196197
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsDelta</a></code>
197198
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsWebSearchResultLocation</a></code>
199+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionOutputBlock</a></code>
200+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionOutputBlockParam</a></code>
201+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionResultBlock</a></code>
202+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionResultBlockParam</a></code>
203+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionTool20250522</a></code>
204+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionToolResultBlock</a></code>
205+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionToolResultBlockContent</a></code>
206+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionToolResultBlockParam</a></code>
207+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionToolResultBlockParamContent</a></code>
208+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionToolResultError</a></code>
209+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionToolResultErrorCode</a></code>
210+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCodeExecutionToolResultErrorParam</a></code>
211+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContainer</a></code>
212+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContainerUploadBlock</a></code>
213+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContainerUploadBlockParam</a></code>
198214
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlock</a></code>
199215
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockParam</a></code>
200216
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSource</a></code>
201217
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSourceContent</a></code>
218+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaFileDocumentSource</a></code>
219+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaFileImageSource</a></code>
202220
- <code><a href="./src/resources/beta/messages/messages.ts">BetaImageBlockParam</a></code>
203221
- <code><a href="./src/resources/beta/messages/messages.ts">BetaInputJSONDelta</a></code>
222+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMCPToolResultBlock</a></code>
223+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMCPToolUseBlock</a></code>
224+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMCPToolUseBlockParam</a></code>
204225
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMessage</a></code>
205226
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageDeltaUsage</a></code>
206227
- <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageParam</a></code>
@@ -217,6 +238,9 @@ Types:
217238
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRawMessageStreamEvent</a></code>
218239
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRedactedThinkingBlock</a></code>
219240
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRedactedThinkingBlockParam</a></code>
241+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRequestMCPServerToolConfiguration</a></code>
242+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRequestMCPServerURLDefinition</a></code>
243+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaRequestMCPToolResultBlockParam</a></code>
220244
- <code><a href="./src/resources/beta/messages/messages.ts">BetaServerToolUsage</a></code>
221245
- <code><a href="./src/resources/beta/messages/messages.ts">BetaServerToolUseBlock</a></code>
222246
- <code><a href="./src/resources/beta/messages/messages.ts">BetaServerToolUseBlockParam</a></code>
@@ -246,6 +270,7 @@ Types:
246270
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolResultBlockParam</a></code>
247271
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolTextEditor20241022</a></code>
248272
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolTextEditor20250124</a></code>
273+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolTextEditor20250429</a></code>
249274
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUnion</a></code>
250275
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUseBlock</a></code>
251276
- <code><a href="./src/resources/beta/messages/messages.ts">BetaToolUseBlockParam</a></code>
@@ -261,6 +286,7 @@ Types:
261286
- <code><a href="./src/resources/beta/messages/messages.ts">BetaWebSearchToolResultBlockParam</a></code>
262287
- <code><a href="./src/resources/beta/messages/messages.ts">BetaWebSearchToolResultBlockParamContent</a></code>
263288
- <code><a href="./src/resources/beta/messages/messages.ts">BetaWebSearchToolResultError</a></code>
289+
- <code><a href="./src/resources/beta/messages/messages.ts">BetaWebSearchToolResultErrorCode</a></code>
264290

265291
Methods:
266292

@@ -289,3 +315,18 @@ Methods:
289315
- <code title="delete /v1/messages/batches/{message_batch_id}?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">delete</a>(messageBatchID, { ...params }) -> BetaDeletedMessageBatch</code>
290316
- <code title="post /v1/messages/batches/{message_batch_id}/cancel?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">cancel</a>(messageBatchID, { ...params }) -> BetaMessageBatch</code>
291317
- <code title="get /v1/messages/batches/{message_batch_id}/results?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">results</a>(messageBatchID, { ...params }) -> BetaMessageBatchIndividualResponse</code>
318+
319+
## Files
320+
321+
Types:
322+
323+
- <code><a href="./src/resources/beta/files.ts">DeletedFile</a></code>
324+
- <code><a href="./src/resources/beta/files.ts">FileMetadata</a></code>
325+
326+
Methods:
327+
328+
- <code title="get /v1/files?beta=true">client.beta.files.<a href="./src/resources/beta/files.ts">list</a>({ ...params }) -> FileMetadataPage</code>
329+
- <code title="delete /v1/files/{file_id}?beta=true">client.beta.files.<a href="./src/resources/beta/files.ts">delete</a>(fileID, { ...params }) -> DeletedFile</code>
330+
- <code title="get /v1/files/{file_id}/content?beta=true">client.beta.files.<a href="./src/resources/beta/files.ts">download</a>(fileID, { ...params }) -> Response</code>
331+
- <code title="get /v1/files/{file_id}?beta=true">client.beta.files.<a href="./src/resources/beta/files.ts">retrieveMetadata</a>(fileID, { ...params }) -> FileMetadata</code>
332+
- <code title="post /v1/files?beta=true">client.beta.files.<a href="./src/resources/beta/files.ts">upload</a>({ ...params }) -> FileMetadata</code>

examples/mcp.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env -S npm run tsn -T
2+
3+
import Anthropic from '@anthropic-ai/sdk';
4+
5+
const anthropic = new Anthropic(); // gets API Key from environment variable ANTHROPIC_API_KEY
6+
7+
const main = async () => {
8+
const stream = anthropic.beta.messages.stream(
9+
{
10+
model: 'claude-3-7-sonnet-20250219',
11+
max_tokens: 1000,
12+
mcp_servers: [
13+
{
14+
type: 'url',
15+
url: 'http://example-server.modelcontextprotocol.io/sse',
16+
name: 'example',
17+
tool_configuration: {
18+
// Optional, defaults to allowing all tools
19+
enabled: true, // Optional
20+
allowed_tools: ['echo', 'add'], // Optional
21+
},
22+
},
23+
],
24+
messages: [
25+
{
26+
role: 'user',
27+
content: 'Calculate 1+2',
28+
},
29+
],
30+
},
31+
{
32+
headers: {
33+
'anthropic-beta': 'mcp-client-2025-04-04',
34+
},
35+
},
36+
);
37+
for await (const event of stream) {
38+
if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {
39+
process.stdout.write(event.delta.text);
40+
}
41+
}
42+
process.stdout.write('\n');
43+
};
44+
main();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@anthropic-ai/sdk",
3-
"version": "0.51.0",
3+
"version": "0.52.0",
44
"description": "The official TypeScript library for the Anthropic API",
55
"author": "Anthropic <[email protected]>",
66
"types": "dist/index.d.ts",

packages/bedrock-sdk/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 0.22.1 (2025-05-22)
4+
5+
Full Changelog: [bedrock-sdk-v0.22.0...bedrock-sdk-v0.22.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.22.0...bedrock-sdk-v0.22.1)
6+
7+
### Chores
8+
9+
* **internal:** version bump ([8ebaf61](https://github.com/anthropics/anthropic-sdk-typescript/commit/8ebaf616d2e5c6aebc153f19a403dde41ab5a9f1))
10+
311
## 0.22.0 (2025-05-15)
412

513
Full Changelog: [bedrock-sdk-v0.21.2...bedrock-sdk-v0.22.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.21.2...bedrock-sdk-v0.22.0)

0 commit comments

Comments
 (0)