Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
aec4cce
don't strip path from filename in multipart
sd-st Nov 18, 2025
c6b2675
address feedback
sd-st Dec 3, 2025
493258b
address feedback
sd-st Dec 10, 2025
0b98943
fix(mcp): return correct lines on typescript errors
stainless-app[bot] Dec 11, 2025
2a6e2cd
chore(internal): codegen related update
stainless-app[bot] Dec 11, 2025
ba21721
fix(mcp): correct code tool API endpoint
stainless-app[bot] Dec 11, 2025
a7fbcd8
chore(internal): codegen related update
stainless-app[bot] Dec 11, 2025
f3e89e8
chore(internal): version bump
stainless-app[bot] Dec 6, 2025
be4e942
codegen metadata
stainless-app[bot] Dec 11, 2025
fd388c6
chore(tests): remove extraneous header test
dtmeadows Dec 11, 2025
9610d4f
Merge pull request #849 from sd-st/fix-multipart-path
packyg Dec 16, 2025
203223a
docs: update README with Claude branding (#611)
felixfbecker Dec 19, 2025
0a6c372
chore(ci): Add Claude Code GitHub Workflow (#612)
dtmeadows Dec 19, 2025
7d51dac
feat(ci): add breaking change detection workflow
stainless-app[bot] Jan 5, 2026
80e8e4c
chore: break long lines in snippets into multiline
stainless-app[bot] Jan 6, 2026
a7e605c
chore(ci): fix multi package publishing
RobertCraigie Jan 6, 2026
ef8da95
docs: tool use documentation link (#873) (#616)
stainless-sdks[bot] Jan 9, 2026
1521bb0
codegen metadata
stainless-app[bot] Jan 12, 2026
1d0dc5b
codegen metadata
stainless-app[bot] Jan 14, 2026
fe4dca7
chore(internal): upgrade babel, qs, js-yaml
stainless-app[bot] Jan 15, 2026
0048e31
feat(api): migrate sending message format in output_config rather tha…
stainless-app[bot] Jan 15, 2026
ffa42ba
chore: release main
stainless-app[bot] Jan 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions .github/workflows/claude-code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Claude Code Review

on:
pull_request:
types: [opened, synchronize]
# Optional: Only run on specific file changes
# paths:
# - "src/**/*.ts"
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

jobs:
claude-review:
# Optional: Filter by PR author
# if: |
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: |
REPO: ${{ github.repository }}
PR NUMBER: ${{ github.event.pull_request.number }}

Please review this pull request and provide feedback on:
- Code quality and best practices
- Potential bugs or issues
- Performance considerations
- Security concerns
- Test coverage

Use the repository's CLAUDE.md for guidance on style and conventions. Be constructive and helpful in your feedback.

Use `gh pr comment` with your Bash tool to leave your review as a comment on the PR.

# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
claude_args: '--allowed-tools "Bash(gh issue view:*),Bash(gh search:*),Bash(gh issue list:*),Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr list:*)"'
49 changes: 49 additions & 0 deletions .github/workflows/claude.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Claude Code

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]

jobs:
claude:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
id-token: write
actions: read # Required for Claude to read CI results on PRs
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

# This is an optional setting that allows Claude to read CI results on PRs
additional_permissions: |
actions: read

# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
# prompt: 'Update the pull request description to include a summary of changes.'

# Optional: Add claude_args to customize behavior and configuration
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
# or https://code.claude.com/docs/en/cli-reference for available options
# claude_args: '--allowed-tools Bash(gh pr:*)'
3 changes: 2 additions & 1 deletion .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- name: Publish to NPM
if: ${{ steps.release.outputs.releases_created }}
run: |
bash ./bin/publish-npm
yarn tsn scripts/publish-packages.ts
env:
DATA: ${{ toJSON(steps.release.outputs) }}
NPM_TOKEN: ${{ secrets.ANTHROPIC_NPM_TOKEN || secrets.NPM_TOKEN }}
36 changes: 36 additions & 0 deletions .github/workflows/detect-breaking-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI
on:
pull_request:
branches:
- main
- next

jobs:
detect_breaking_changes:
runs-on: 'ubuntu-latest'
name: detect-breaking-changes
if: github.repository == 'anthropics/anthropic-sdk-typescript'
steps:
- name: Calculate fetch-depth
run: |
echo "FETCH_DEPTH=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_ENV

- uses: actions/checkout@v4
with:
# Ensure we can check out the pull request base in the script below.
fetch-depth: ${{ env.FETCH_DEPTH }}

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: |
yarn install

- name: Detect breaking changes
run: |
# Try to check out previous versions of the breaking change detection script. This ensures that
# we still detect breaking changes when entire files and their tests are removed.
git checkout "${{ github.event.pull_request.base.sha }}" -- ./scripts/detect-breaking-changes 2>/dev/null || true
./scripts/detect-breaking-changes ${{ github.event.pull_request.base.sha }}
Comment on lines +10 to +36

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 10 days ago

In general, the fix is to explicitly define permissions for the workflow or for the specific job so that the GITHUB_TOKEN has only the minimal scopes required. For this job, we only need to read repository contents to check out code and run the breaking-change detection script, so setting contents: read at the job or workflow level is appropriate.

The best fix without changing existing functionality is to add a permissions block that grants contents: read for the job detect_breaking_changes. This keeps the scope tight and does not affect any other workflows. Concretely, in .github/workflows/detect-breaking-changes.yml, add a permissions: mapping under the detect_breaking_changes job, between the name: and if: lines. No new imports or external dependencies are required; this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/detect-breaking-changes.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/detect-breaking-changes.yml b/.github/workflows/detect-breaking-changes.yml
--- a/.github/workflows/detect-breaking-changes.yml
+++ b/.github/workflows/detect-breaking-changes.yml
@@ -9,6 +9,8 @@
   detect_breaking_changes:
     runs-on: 'ubuntu-latest'
     name: detect-breaking-changes
+    permissions:
+      contents: read
     if: github.repository == 'anthropics/anthropic-sdk-typescript'
     steps:
       - name: Calculate fetch-depth
EOF
@@ -9,6 +9,8 @@
detect_breaking_changes:
runs-on: 'ubuntu-latest'
name: detect-breaking-changes
permissions:
contents: read
if: github.repository == 'anthropics/anthropic-sdk-typescript'
steps:
- name: Calculate fetch-depth
Copilot is powered by AI and may make mistakes. Always verify output.
8 changes: 4 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
".": "0.71.2",
"packages/vertex-sdk": "0.14.1",
"packages/bedrock-sdk": "0.26.1",
"packages/foundry-sdk": "0.2.1"
".": "0.72.0",
"packages/vertex-sdk": "0.14.2",
"packages/bedrock-sdk": "0.26.2",
"packages/foundry-sdk": "0.2.2"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 34
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-a49e89deec4e00d1da490808099d66e2001531b12d8666a7f5d0b496f760440d.yml
openapi_spec_hash: c93ef3808c58e233b01966ff154f31ce
config_hash: a5d8cd02f9a686d4e0baa7ba652e3e55
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic%2Fanthropic-f7bcdc13402c6129b30be620021a724945de44cffc6add091798f9cce33a1e32.yml
openapi_spec_hash: e78807e31b9233abc50ccc00304bfa4d
config_hash: 92ca93edc068c543f2da38737239322d
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## 0.72.0 (2026-01-15)

Full Changelog: [sdk-v0.71.2...sdk-v0.72.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.71.2...sdk-v0.72.0)

### Features

* **api:** migrate sending message format in output_config rather than output_format ([0048e31](https://github.com/anthropics/anthropic-sdk-typescript/commit/0048e31ef0e2a4a59626adfee16c76337e28b565))
* **ci:** add breaking change detection workflow ([7d51dac](https://github.com/anthropics/anthropic-sdk-typescript/commit/7d51dacef07727ceaae192e6a0fefb2e0a60a987))


### Bug Fixes

* **mcp:** correct code tool API endpoint ([ba21721](https://github.com/anthropics/anthropic-sdk-typescript/commit/ba21721557b96dd0fd89e2b3459aed7e95dd733a))
* **mcp:** return correct lines on typescript errors ([0b98943](https://github.com/anthropics/anthropic-sdk-typescript/commit/0b98943430f7d6c5c85047d9d676efbf2b6b8052))


### Chores

* break long lines in snippets into multiline ([80e8e4c](https://github.com/anthropics/anthropic-sdk-typescript/commit/80e8e4c8027db6f5238eb2e0c62d89f5ddbd0bd0))
* **ci:** Add Claude Code GitHub Workflow ([#612](https://github.com/anthropics/anthropic-sdk-typescript/issues/612)) ([0a6c372](https://github.com/anthropics/anthropic-sdk-typescript/commit/0a6c372e5c9524aef125c854a0f39680d82be642))
* **ci:** fix multi package publishing ([a7e605c](https://github.com/anthropics/anthropic-sdk-typescript/commit/a7e605c3bee736409b10ef92f95da1ad9bf8ac8b))
* **internal:** codegen related update ([a7fbcd8](https://github.com/anthropics/anthropic-sdk-typescript/commit/a7fbcd8733d554a7682d612ab0cf4873a4d05265))
* **internal:** codegen related update ([2a6e2cd](https://github.com/anthropics/anthropic-sdk-typescript/commit/2a6e2cd068a6c5846054e4d0d0103be9750b1f57))
* **internal:** upgrade babel, qs, js-yaml ([fe4dca7](https://github.com/anthropics/anthropic-sdk-typescript/commit/fe4dca74f8a04dea8208f7cb3bb57952c7e518c5))
* **internal:** version bump ([f3e89e8](https://github.com/anthropics/anthropic-sdk-typescript/commit/f3e89e84a2c807d7ded1738a9a9090710cb6605e))
* **tests:** remove extraneous header test ([fd388c6](https://github.com/anthropics/anthropic-sdk-typescript/commit/fd388c6a113d655409659aff82dd3336b946f8b4))


### Documentation

* tool use documentation link ([#873](https://github.com/anthropics/anthropic-sdk-typescript/issues/873)) ([#616](https://github.com/anthropics/anthropic-sdk-typescript/issues/616)) ([ef8da95](https://github.com/anthropics/anthropic-sdk-typescript/commit/ef8da9541155168061125cb7dd22d3eb38613c96))
* update README with Claude branding ([#611](https://github.com/anthropics/anthropic-sdk-typescript/issues/611)) ([203223a](https://github.com/anthropics/anthropic-sdk-typescript/commit/203223ac1720b1387b37dc83d6e36a89c2af9179))

## 0.71.2 (2025-12-05)

Full Changelog: [sdk-v0.71.1...sdk-v0.71.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.71.1...sdk-v0.71.2)
Expand Down
93 changes: 47 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Anthropic TypeScript API Library
# <img src=".github/logo.svg" alt="" width="32"> Claude SDK for TypeScript

[![NPM version](<https://img.shields.io/npm/v/@anthropic-ai/sdk.svg?label=npm%20(stable)>)](https://npmjs.org/package/@anthropic-ai/sdk) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/@anthropic-ai/sdk)

This library provides convenient access to the Anthropic REST API from server-side TypeScript or JavaScript.
This library provides convenient access to the Claude API from TypeScript or JavaScript.

The REST API documentation can be found on [docs.anthropic.com](https://docs.anthropic.com/claude/reference/). The full API of this library can be found in [api.md](api.md).
The full API documentation can be found at [platform.claude.com/docs](https://platform.claude.com/docs/en/api/typescript/messages/create) or in [api.md](api.md).

## Installation

Expand All @@ -14,8 +14,6 @@ npm install @anthropic-ai/sdk

## Usage

The full API of this library can be found in [api.md](api.md).

<!-- prettier-ignore -->
```js
import Anthropic from '@anthropic-ai/sdk';
Expand Down Expand Up @@ -124,42 +122,9 @@ Streaming with `client.messages.stream(...)` exposes [various helpers for your c

Alternatively, you can use `client.messages.create({ ..., stream: true })` which only returns an async iterable of the events in the stream and thus uses less memory (it does not build up a final message object for you).

## Tool Helpers

This SDK provides helpers for making it easy to create and run tools in the Messages API. You can use Zod schemas or JSON Schemas to describe the input to a tool. You can then run those tools using the `client.messages.toolRunner()` method. This method will handle passing the inputs generated by the chosen model into the right tool and passing the result back to the model.

```ts
import Anthropic from '@anthropic-ai/sdk';

import { betaZodTool } from '@anthropic-ai/sdk/helpers/beta/zod';
import { z } from 'zod';

const anthropic = new Anthropic();

const weatherTool = betaZodTool({
name: 'get_weather',
inputSchema: z.object({
location: z.string(),
}),
description: 'Get the current weather in a given location',
run: (input) => {
return `The weather in ${input.location} is foggy and 60°F`;
},
});

const finalMessage = await anthropic.beta.messages.toolRunner({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1000,
messages: [{ role: 'user', content: 'What is the weather in San Francisco?' }],
tools: [weatherTool],
});
```

You can find more details on how to use these tool helpers [here](helpers.md#tool-helpers).

## Message Batches

This SDK provides support for the [Message Batches API](https://docs.anthropic.com/en/docs/build-with-claude/message-batches) under the `client.messages.batches` namespace.
This SDK provides support for the [Message Batches API](https://platform.claude.com/docs/en/api/typescript/messages/batches/create) under the `client.messages.batches` namespace.

### Creating a batch

Expand Down Expand Up @@ -203,7 +168,35 @@ for await (const entry of results) {

## Tool use

This SDK provides support for tool use, aka function calling. More details can be found in [the documentation](https://docs.anthropic.com/claude/docs/tool-use).
This SDK provides support for tool use, aka function calling. More details can be found in [the documentation](https://platform.claude.com/docs/en/agents-and-tools/tool-use/overview).
The SDK provides helpers for making it easy to create and run tools. You can use Zod schemas or JSON Schemas to describe the input to a tool. You can then run those tools using the `client.messages.toolRunner()` method. This method will handle passing the inputs generated by the chosen model into the right tool and passing the result back to the model.

```ts
import Anthropic from '@anthropic-ai/sdk';

import { betaZodTool } from '@anthropic-ai/sdk/helpers/beta/zod';
import { z } from 'zod';

const anthropic = new Anthropic();

const weatherTool = betaZodTool({
name: 'get_weather',
inputSchema: z.object({
location: z.string(),
}),
description: 'Get the current weather in a given location',
run: (input) => {
return `The weather in ${input.location} is foggy and 60°F`;
},
});

const finalMessage = await anthropic.beta.messages.toolRunner({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1000,
messages: [{ role: 'user', content: 'What is the weather in San Francisco?' }],
tools: [weatherTool],
});
```

## AWS Bedrock

Expand Down Expand Up @@ -294,7 +287,7 @@ Error codes are as follows:

## Request IDs

> For more information on debugging requests, see [these docs](https://docs.anthropic.com/en/api/errors#request-id)
> For more information on debugging requests, see [these docs](https://platform.claude.com/docs/en/api/errors#request-id)

All object responses in the SDK provide a `_request_id` property which is added from the `request-id` response header so that you can quickly log failing requests and report them back to Anthropic.

Expand Down Expand Up @@ -323,7 +316,11 @@ const client = new Anthropic({
});

// Or, configure per-request:
await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-sonnet-4-5-20250929' }, {
await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-sonnet-4-5-20250929',
}, {
maxRetries: 5,
});
```
Expand Down Expand Up @@ -351,7 +348,11 @@ const client = new Anthropic({
});

// Override per-request:
await client.messages.create({ max_tokens: 1024, messages: [{ role: 'user', content: 'Hello, Claude' }], model: 'claude-sonnet-4-5-20250929' }, {
await client.messages.create({
max_tokens: 1024,
messages: [{ role: 'user', content: 'Hello, Claude' }],
model: 'claude-sonnet-4-5-20250929',
}, {
timeout: 5 * 1000,
});
```
Expand Down Expand Up @@ -381,7 +382,7 @@ This can be [overriden](#configuring-an-https-agent-eg-for-proxies) by configuri

## Auto-pagination

List methods in the Anthropic API are paginated.
List methods in the Claude API are paginated.
You can use the `for await … of` syntax to iterate through items across all pages:

```ts
Expand Down Expand Up @@ -645,9 +646,9 @@ const client = new Anthropic({

### Beta Features

We introduce beta features before they are generally available to get early feedback and test new functionality. You can check the availability of all of Claude's capabilities and tools [here](https://docs.anthropic.com/en/docs/build-with-claude/overview).
We introduce beta features before they are generally available to get early feedback and test new functionality. You can check the availability of all of Claude's capabilities and tools [here](https://platform.claude.com/docs/en/api/overview).

You can access most beta API features through the beta property of the client. To enable a particular beta feature, you need to add the appropriate [beta header](https://docs.anthropic.com/en/api/beta-headers) to the `betas` field when creating a message.
You can access most beta API features through the beta property of the client. To enable a particular beta feature, you need to add the appropriate [beta header](https://platform.claude.com/docs/en/api/beta-headers) to the `betas` field when creating a message.

For example, to use code execution:

Expand Down
2 changes: 1 addition & 1 deletion helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ Updates the conversation parameters. Can accept new parameters or a mutator func
// Direct parameter update
runner.setMessagesParams({
...runner.params,
model: 'claude-3-5-haiku-20241022',
model: 'claude-haiku-4-5',
max_tokens: 500,
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@anthropic-ai/sdk",
"version": "0.71.2",
"version": "0.72.0",
"description": "The official TypeScript library for the Anthropic API",
"author": "Anthropic <[email protected]>",
"types": "dist/index.d.ts",
Expand Down
Loading