Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/anthropic-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Node
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'

Expand All @@ -50,10 +50,10 @@ jobs:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Node
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'

Expand All @@ -71,7 +71,7 @@ jobs:
github.repository == 'stainless-sdks/anthropic-typescript' &&
!startsWith(github.ref, 'refs/heads/stl/')
id: github-oidc
uses: actions/github-script@v8
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
with:
script: core.setOutput('github_token', await core.getIDToken());

Expand All @@ -90,10 +90,10 @@ jobs:
runs-on: ${{ github.repository == 'stainless-sdks/anthropic-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Node
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: '20'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/create-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
environment: production-release

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: stainless-api/trigger-release-please@bb6677c5a04578eec1ccfd9e1913b5b78ed64c61 # v1.4.0
id: release
Expand All @@ -24,7 +24,7 @@ jobs:

- name: Set up Node
if: ${{ steps.release.outputs.releases_created }}
uses: actions/setup-node@v3
uses: actions/setup-node@3235b876344d2a9aa001b8d1453c930bba69e610 # v3.9.1
with:
node-version: '20'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
environment: production-release

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Node
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
".": "0.95.2",
".": "0.96.0",
"packages/vertex-sdk": "0.16.0",
"packages/bedrock-sdk": "0.29.1",
"packages/foundry-sdk": "0.2.3",
Expand Down
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 97
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-0df2c793ea4c3ad955e8e488be39d7041a0a95e2fe144dd69ae4d9fb72835190.yml
openapi_spec_hash: b169b786bdf1f07d7f77f18f7b94abfa
config_hash: ed43b84afda7441f472a59dda6badb05
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic/anthropic-9bc52c052beb11ccfff68e9d96335774c8377f914bcf36278e5774c68aa84e69.yml
openapi_spec_hash: 3a5f6e11b9fda1c165c6f9edbdee7d90
config_hash: ed200254fa6776c7b124706c91c80475
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 0.96.0 (2026-05-13)

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

### Features

* **api:** Add BetaManagedAgentsSearchResultBlock types ([08f02f3](https://github.com/anthropics/anthropic-sdk-typescript/commit/08f02f3d0c34a9563b17af40b227acf3b105f8a3))
* **api:** Add support for cache diagnostics beta ([eafbd6d](https://github.com/anthropics/anthropic-sdk-typescript/commit/eafbd6d78b81253c79cb861de6a9232b18eb60de))


### Bug Fixes

* **zod:** ensure only zod/v4 types are used ([#992](https://github.com/anthropics/anthropic-sdk-typescript/issues/992)) ([9e08bcc](https://github.com/anthropics/anthropic-sdk-typescript/commit/9e08bcc988697c195b31569b7519b7954aea6372))


### Chores

* **api:** spec updates ([27d64ef](https://github.com/anthropics/anthropic-sdk-typescript/commit/27d64ef828dc4ec11d44118a7ed1fcf83d67da0d))

## 0.95.2 (2026-05-11)

Full Changelog: [sdk-v0.95.1...sdk-v0.95.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.95.1...sdk-v0.95.2)
Expand Down
11 changes: 11 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,12 @@ Types:
- <code><a href="./src/resources/beta/messages/messages.ts">BetaBashCodeExecutionToolResultErrorParam</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheControlEphemeral</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheCreation</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheMissMessagesChanged</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheMissModelChanged</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheMissPreviousMessageNotFound</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheMissSystemChanged</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheMissToolsChanged</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheMissUnavailable</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationCharLocation</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationCharLocationParam</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationConfig</a></code>
Expand Down Expand Up @@ -343,6 +349,8 @@ Types:
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContextManagementConfig</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaContextManagementResponse</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaCountTokensContextManagementResponse</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaDiagnostics</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaDiagnosticsParam</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaDirectCaller</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaDocumentBlock</a></code>
- <code><a href="./src/resources/beta/messages/messages.ts">BetaEncryptedCodeExecutionResultBlock</a></code>
Expand Down Expand Up @@ -651,6 +659,9 @@ Types:
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsRetryStatusExhausted</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsRetryStatusRetrying</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsRetryStatusTerminal</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsSearchResultBlock</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsSearchResultCitations</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsSearchResultContent</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsSendSessionEvents</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsSessionDeletedEvent</a></code>
- <code><a href="./src/resources/beta/sessions/events.ts">BetaManagedAgentsSessionEndTurn</a></code>
Expand Down
2 changes: 1 addition & 1 deletion examples/structured-outputs-streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { zodOutputFormat } from '@anthropic-ai/sdk/helpers/zod';
import Anthropic from '@anthropic-ai/sdk';
import { z } from 'zod';
import { z } from 'zod/v4';

const WeatherResponse = z.object({
city: z.string(),
Expand Down
2 changes: 1 addition & 1 deletion examples/structured-outputs-zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { zodOutputFormat } from '@anthropic-ai/sdk/helpers/zod';
import Anthropic from '@anthropic-ai/sdk';
import { z } from 'zod';
import { z } from 'zod/v4';

const NumbersResponse = z.object({
primes: z.array(z.number()),
Expand Down
2 changes: 1 addition & 1 deletion examples/tools-helpers-advanced-streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Anthropic from '@anthropic-ai/sdk';
import { betaZodTool } from '@anthropic-ai/sdk/helpers/beta/zod';
import { BetaToolUseBlock } from '@anthropic-ai/sdk/resources/beta';
import { z } from 'zod';
import { z } from 'zod/v4';

const client = new Anthropic();

Expand Down
2 changes: 1 addition & 1 deletion examples/tools-helpers-advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Anthropic from '@anthropic-ai/sdk';
import { betaZodTool } from '@anthropic-ai/sdk/helpers/beta/zod';
import { BetaToolUseBlock } from '@anthropic-ai/sdk/resources/beta';
import { z } from 'zod';
import { z } from 'zod/v4';

const client = new Anthropic();

Expand Down
2 changes: 1 addition & 1 deletion examples/tools-helpers-zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

const client = new Anthropic();

Expand Down
4 changes: 2 additions & 2 deletions helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ The SDK provides helpers for parsing structured JSON outputs from Claude using J
```ts
import { zodOutputFormat } from '@anthropic-ai/sdk/helpers/zod';
import Anthropic from '@anthropic-ai/sdk';
import { z } from 'zod';
import { z } from 'zod/v4';

const client = new Anthropic();

Expand Down Expand Up @@ -183,7 +183,7 @@ The SDK provides helper functions to create runnable tools that can be automatic

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

const weatherTool = betaZodTool({
name: 'get_weather',
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.95.2",
"version": "0.96.0",
"description": "The official TypeScript library for the Anthropic API",
"author": "Anthropic <support@anthropic.com>",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/vertex-sdk/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"@anthropic-ai/sdk@file:../../dist":
# x-release-please-start-version
version "0.95.2"
version "0.96.0"
# x-release-please-end-version
dependencies:
json-schema-to-ts "^3.1.1"
Expand Down
13 changes: 6 additions & 7 deletions src/helpers/beta/zod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { transformJSONSchema } from '../..//lib/transform-json-schema';
import type { infer as zodInfer, ZodType } from 'zod';
import * as z from 'zod/v4';
import { AnthropicError } from '../../core/error';
import { AutoParseableBetaOutputFormat } from '../../lib/beta-parser';
Expand All @@ -14,9 +13,9 @@ import { BetaToolResultContentBlockParam } from '../../resources/beta';
* This can be passed directly to the `.create()` method but will not
* result in any automatic parsing, you'll have to parse the response yourself.
*/
export function betaZodOutputFormat<ZodInput extends ZodType>(
export function betaZodOutputFormat<ZodInput extends z.ZodType>(
zodObject: ZodInput,
): AutoParseableBetaOutputFormat<zodInfer<ZodInput>> {
): AutoParseableBetaOutputFormat<z.infer<ZodInput>> {
let jsonSchema = z.toJSONSchema(zodObject, { reused: 'ref' });

jsonSchema = transformJSONSchema(jsonSchema);
Expand Down Expand Up @@ -46,15 +45,15 @@ export function betaZodOutputFormat<ZodInput extends ZodType>(
* converted into JSON Schema when passed to the API. The provided function's
* input arguments will also be validated against the provided schema.
*/
export function betaZodTool<InputSchema extends ZodType>(options: {
export function betaZodTool<InputSchema extends z.ZodType>(options: {
name: string;
inputSchema: InputSchema;
description: string;
run: (
args: zodInfer<InputSchema>,
args: z.infer<InputSchema>,
context?: BetaToolRunContext,
) => Promisable<string | Array<BetaToolResultContentBlockParam>>;
}): BetaRunnableTool<zodInfer<InputSchema>> {
}): BetaRunnableTool<z.infer<InputSchema>> {
const jsonSchema = z.toJSONSchema(options.inputSchema, { reused: 'ref' });

if (jsonSchema.type !== 'object') {
Expand All @@ -70,6 +69,6 @@ export function betaZodTool<InputSchema extends ZodType>(options: {
input_schema: objectSchema,
description: options.description,
run: options.run,
parse: (args: unknown) => options.inputSchema.parse(args) as zodInfer<InputSchema>,
parse: (args: unknown) => options.inputSchema.parse(args) as z.infer<InputSchema>,
};
}
5 changes: 2 additions & 3 deletions src/helpers/zod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { transformJSONSchema } from '../lib/transform-json-schema';
import type { infer as zodInfer, ZodType } from 'zod';
import * as z from 'zod/v4';
import { AnthropicError } from '../core/error';
import { AutoParseableOutputFormat } from '../lib/parser';
Expand All @@ -13,9 +12,9 @@ import { AutoParseableOutputFormat } from '../lib/parser';
* This can be passed directly to the `.create()` method but will not
* result in any automatic parsing, you'll have to parse the response yourself.
*/
export function zodOutputFormat<ZodInput extends ZodType>(
export function zodOutputFormat<ZodInput extends z.ZodType>(
zodObject: ZodInput,
): AutoParseableOutputFormat<zodInfer<ZodInput>> {
): AutoParseableOutputFormat<z.infer<ZodInput>> {
let jsonSchema = z.toJSONSchema(zodObject, { reused: 'ref' });

jsonSchema = transformJSONSchema(jsonSchema);
Expand Down
19 changes: 18 additions & 1 deletion src/resources/beta/beta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ import {
BetaBashCodeExecutionToolResultErrorParam,
BetaCacheControlEphemeral,
BetaCacheCreation,
BetaCacheMissMessagesChanged,
BetaCacheMissModelChanged,
BetaCacheMissPreviousMessageNotFound,
BetaCacheMissSystemChanged,
BetaCacheMissToolsChanged,
BetaCacheMissUnavailable,
BetaCitationCharLocation,
BetaCitationCharLocationParam,
BetaCitationConfig,
Expand Down Expand Up @@ -218,6 +224,8 @@ import {
BetaContextManagementConfig,
BetaContextManagementResponse,
BetaCountTokensContextManagementResponse,
BetaDiagnostics,
BetaDiagnosticsParam,
BetaDirectCaller,
BetaDocumentBlock,
BetaEncryptedCodeExecutionResultBlock,
Expand Down Expand Up @@ -448,7 +456,8 @@ export type AnthropicBeta =
| 'output-300k-2026-03-24'
| 'user-profiles-2026-03-24'
| 'advisor-tool-2026-03-01'
| 'managed-agents-2026-04-01';
| 'managed-agents-2026-04-01'
| 'cache-diagnosis-2026-04-07';

export interface BetaAPIError {
message: string;
Expand Down Expand Up @@ -590,6 +599,12 @@ export declare namespace Beta {
type BetaBashCodeExecutionToolResultErrorParam as BetaBashCodeExecutionToolResultErrorParam,
type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
type BetaCacheCreation as BetaCacheCreation,
type BetaCacheMissMessagesChanged as BetaCacheMissMessagesChanged,
type BetaCacheMissModelChanged as BetaCacheMissModelChanged,
type BetaCacheMissPreviousMessageNotFound as BetaCacheMissPreviousMessageNotFound,
type BetaCacheMissSystemChanged as BetaCacheMissSystemChanged,
type BetaCacheMissToolsChanged as BetaCacheMissToolsChanged,
type BetaCacheMissUnavailable as BetaCacheMissUnavailable,
type BetaCitationCharLocation as BetaCitationCharLocation,
type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
type BetaCitationConfig as BetaCitationConfig,
Expand Down Expand Up @@ -637,6 +652,8 @@ export declare namespace Beta {
type BetaContextManagementConfig as BetaContextManagementConfig,
type BetaContextManagementResponse as BetaContextManagementResponse,
type BetaCountTokensContextManagementResponse as BetaCountTokensContextManagementResponse,
type BetaDiagnostics as BetaDiagnostics,
type BetaDiagnosticsParam as BetaDiagnosticsParam,
type BetaDirectCaller as BetaDirectCaller,
type BetaDocumentBlock as BetaDocumentBlock,
type BetaEncryptedCodeExecutionResultBlock as BetaEncryptedCodeExecutionResultBlock,
Expand Down
8 changes: 8 additions & 0 deletions src/resources/beta/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ export {
type BetaBashCodeExecutionToolResultErrorParam,
type BetaCacheControlEphemeral,
type BetaCacheCreation,
type BetaCacheMissMessagesChanged,
type BetaCacheMissModelChanged,
type BetaCacheMissPreviousMessageNotFound,
type BetaCacheMissSystemChanged,
type BetaCacheMissToolsChanged,
type BetaCacheMissUnavailable,
type BetaCitationCharLocation,
type BetaCitationCharLocationParam,
type BetaCitationConfig,
Expand Down Expand Up @@ -171,6 +177,8 @@ export {
type BetaContextManagementConfig,
type BetaContextManagementResponse,
type BetaCountTokensContextManagementResponse,
type BetaDiagnostics,
type BetaDiagnosticsParam,
type BetaDirectCaller,
type BetaDocumentBlock,
type BetaEncryptedCodeExecutionResultBlock,
Expand Down
6 changes: 6 additions & 0 deletions src/resources/beta/messages/batches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@ export namespace BatchCreateParams {
*/
context_management?: BetaMessagesAPI.BetaContextManagementConfig | null;

/**
* Request-level diagnostics. Currently carries the previous response id for
* prompt-cache divergence reporting.
*/
diagnostics?: BetaMessagesAPI.BetaDiagnosticsParam | null;

/**
* Specifies the geographic region for inference processing. If not specified, the
* workspace's `default_inference_geo` is used.
Expand Down
Loading
Loading