Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): update dependency @anthropic-ai/sdk to v0.36.3 #240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Feb 12, 2025

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@anthropic-ai/sdk 0.35.0 -> 0.36.3 age adoption passing confidence

Release Notes

anthropics/anthropic-sdk-typescript (@​anthropic-ai/sdk)

v0.36.3

Full Changelog: sdk-v0.36.2...sdk-v0.36.3

Bug Fixes
Chores

v0.36.2

Full Changelog: sdk-v0.36.1...sdk-v0.36.2

Bug Fixes
  • bedrock: update streaming util import (255c059)

Configuration

📅 Schedule: Branch creation - "* 0-12 * * 3" (UTC), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

Copy link

anthropic debug - [puLL-Merge] - anthropics/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index cb210381..e6222438 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,5 +1,5 @@
 {
-  ".": "0.35.0",
-  "packages/vertex-sdk": "0.6.3",
-  "packages/bedrock-sdk": "0.12.2"
+  ".": "0.36.3",
+  "packages/vertex-sdk": "0.6.4",
+  "packages/bedrock-sdk": "0.12.4"
 }
diff --git .stats.yml .stats.yml
index 239e17b7..64f8716d 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 21
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fd67aea6883f1ee9e46f31a42d3940f0acb1749e787055bd9b9f278b20fa53ec.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-f5276eeef7512112e802c85530c51e0a971ee521eebe3a0db309621587b4973d.yml
diff --git CHANGELOG.md CHANGELOG.md
index 499e576c..da99f256 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,52 @@
 # Changelog
 
+## 0.36.3 (2025-01-27)
+
+Full Changelog: [sdk-v0.36.2...sdk-v0.36.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.2...sdk-v0.36.3)
+
+### Bug Fixes
+
+* **streaming:** accumulate citations ([#675](https://github.com/anthropics/anthropic-sdk-typescript/issues/675)) ([522118f](https://github.com/anthropics/anthropic-sdk-typescript/commit/522118ffeab327e8476f12d9b9fa1f19042ed714))
+
+
+### Chores
+
+* **docs:** updates ([#673](https://github.com/anthropics/anthropic-sdk-typescript/issues/673)) ([751ecd0](https://github.com/anthropics/anthropic-sdk-typescript/commit/751ecd0d44707b21ccb390c81716937fae3d8e35))
+
+## 0.36.2 (2025-01-23)
+
+Full Changelog: [sdk-v0.36.1...sdk-v0.36.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.1...sdk-v0.36.2)
+
+### Bug Fixes
+
+* **bedrock:** update streaming util import ([255c059](https://github.com/anthropics/anthropic-sdk-typescript/commit/255c0599e333e6fae582255e3b0631538b168c69))
+
+## 0.36.1 (2025-01-23)
+
+Full Changelog: [sdk-v0.36.0...sdk-v0.36.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.0...sdk-v0.36.1)
+
+### Chores
+
+* **tests:** fix types ([9efe3ee](https://github.com/anthropics/anthropic-sdk-typescript/commit/9efe3eebf64bd762a34caf362a1cd1a0f0858f92))
+
+## 0.36.0 (2025-01-23)
+
+Full Changelog: [sdk-v0.35.0...sdk-v0.36.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.35.0...sdk-v0.36.0)
+
+### Features
+
+* **api:** add citations ([#668](https://github.com/anthropics/anthropic-sdk-typescript/issues/668)) ([1fef177](https://github.com/anthropics/anthropic-sdk-typescript/commit/1fef17749adbbeb243480b96c04941be29c0746c))
+* **client:** support results endpoint ([#666](https://github.com/anthropics/anthropic-sdk-typescript/issues/666)) ([db5fffe](https://github.com/anthropics/anthropic-sdk-typescript/commit/db5fffeb38a99a3e9283ebf001fbf767d756162e))
+* **stream:** expose `response` property as well ([b0235c7](https://github.com/anthropics/anthropic-sdk-typescript/commit/b0235c7b3ac174b3c8e670e381b4aa038e61c826))
+
+
+### Chores
+
+* **bedrock:** bump dependency on @anthropic-ai/sdk ([8745ca2](https://github.com/anthropics/anthropic-sdk-typescript/commit/8745ca2160f5af4d89e5732a44e560c5e2787aa8))
+* **internal:** fix import ([628b55e](https://github.com/anthropics/anthropic-sdk-typescript/commit/628b55ef5ff8f0245287ecaea688480a0174e2e9))
+* **internal:** minor restructuring ([#664](https://github.com/anthropics/anthropic-sdk-typescript/issues/664)) ([57aefa7](https://github.com/anthropics/anthropic-sdk-typescript/commit/57aefa73230d54da24d787a89adc277481986d02))
+* **vertex:** bump dependency on @anthropic-ai/sdk ([a1c7fcd](https://github.com/anthropics/anthropic-sdk-typescript/commit/a1c7fcdce081f860cbb1148c3862e3303ddb8a62))
+
 ## 0.35.0 (2025-01-21)
 
 Full Changelog: [sdk-v0.34.0...sdk-v0.35.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.34.0...sdk-v0.35.0)
diff --git api.md api.md
index 9aed2e92..1a3d66bc 100644
--- api.md
+++ api.md
@@ -22,9 +22,19 @@ Types:
 
 - <code><a href="./src/resources/messages/messages.ts">Base64PDFSource</a></code>
 - <code><a href="./src/resources/messages/messages.ts">CacheControlEphemeral</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationCharLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationCharLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationContentBlockLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationContentBlockLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationPageLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationPageLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationsConfigParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationsDelta</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlock</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">ContentBlockSource</a></code>
+- <code><a href="./src/resources/messages/messages.ts">ContentBlockSourceContent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockStopEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">DocumentBlockParam</a></code>
@@ -40,6 +50,7 @@ Types:
 - <code><a href="./src/resources/messages/messages.ts">MessageTokensCount</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Metadata</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Model</a></code>
+- <code><a href="./src/resources/messages/messages.ts">PlainTextSource</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockStopEvent</a></code>
@@ -49,6 +60,8 @@ Types:
 - <code><a href="./src/resources/messages/messages.ts">RawMessageStreamEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextBlock</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextBlockParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">TextCitation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">TextCitationParam</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextDelta</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Tool</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ToolChoice</a></code>
@@ -87,7 +100,7 @@ Methods:
 - <code title="get /v1/messages/batches">client.messages.batches.<a href="./src/resources/messages/batches.ts">list</a>({ ...params }) -> MessageBatchesPage</code>
 - <code title="delete /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/resources/messages/batches.ts">delete</a>(messageBatchId) -> DeletedMessageBatch</code>
 - <code title="post /v1/messages/batches/{message_batch_id}/cancel">client.messages.batches.<a href="./src/resources/messages/batches.ts">cancel</a>(messageBatchId) -> MessageBatch</code>
-- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
+- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder&lt;MessageBatchIndividualResponse&gt;</code>
 
 # Models
 
@@ -135,8 +148,18 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFSource</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheControlEphemeral</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">BetaCitationContentBlockLocation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationContentBlockLocationParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationPageLocation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationPageLocationParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsConfigParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSource</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSourceContent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaImageBlockParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaInputJSONDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessage</a></code>
@@ -144,6 +167,7 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageTokensCount</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMetadata</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaPlainTextSource</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockStopEvent</a></code>
@@ -153,6 +177,8 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawMessageStreamEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlockParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextCitation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextCitationParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTool</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaToolBash20241022</a></code>
@@ -194,4 +220,4 @@ Methods:
 - <code title="get /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">list</a>({ ...params }) -> BetaMessageBatchesPage</code>
 - <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>
 - <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>
-- <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 }) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
+- <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 }) -> JSONLDecoder&lt;BetaMessageBatchIndividualResponse&gt;</code>
diff --git package.json package.json
index aa23123e..6fb9c0c4 100644
--- package.json
+++ package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/sdk",
-  "version": "0.35.0",
+  "version": "0.36.3",
   "description": "The official TypeScript library for the Anthropic API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/bedrock-sdk/CHANGELOG.md packages/bedrock-sdk/CHANGELOG.md
index 12fec54c..4b46a678 100644
--- packages/bedrock-sdk/CHANGELOG.md
+++ packages/bedrock-sdk/CHANGELOG.md
@@ -1,5 +1,21 @@
 # Changelog
 
+## 0.12.4 (2025-01-23)
+
+Full Changelog: [bedrock-sdk-v0.12.3...bedrock-sdk-v0.12.4](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.3...bedrock-sdk-v0.12.4)
+
+### Bug Fixes
+
+* **bedrock:** update streaming util import ([255c059](https://github.com/anthropics/anthropic-sdk-typescript/commit/255c0599e333e6fae582255e3b0631538b168c69))
+
+## 0.12.3 (2025-01-23)
+
+Full Changelog: [bedrock-sdk-v0.12.2...bedrock-sdk-v0.12.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.2...bedrock-sdk-v0.12.3)
+
+### Chores
+
+* **bedrock:** bump dependency on @anthropic-ai/sdk ([8745ca2](https://github.com/anthropics/anthropic-sdk-typescript/commit/8745ca2160f5af4d89e5732a44e560c5e2787aa8))
+
 ## 0.12.2 (2025-01-21)
 
 Full Changelog: [bedrock-sdk-v0.12.1...bedrock-sdk-v0.12.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.1...bedrock-sdk-v0.12.2)
diff --git packages/bedrock-sdk/package.json packages/bedrock-sdk/package.json
index 8e7a906d..8236a27d 100644
--- packages/bedrock-sdk/package.json
+++ packages/bedrock-sdk/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/bedrock-sdk",
-  "version": "0.12.2",
+  "version": "0.12.4",
   "description": "The official TypeScript library for the Anthropic Bedrock API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
index 12a41324..aeaa36a3 100644
--- packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
+++ packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
@@ -4,8 +4,8 @@ const pkgJson = require('../dist/package.json');
 for (const dep in pkgJson.dependencies) {
   // ensure we point to NPM instead of a local directory
   if (dep === '@anthropic-ai/sdk') {
-    pkgJson.dependencies[dep] = '^0';
+    pkgJson.dependencies[dep] = '>=0.36 <1';
   }
 }
 
-fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
+fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));
diff --git packages/bedrock-sdk/src/streaming.ts packages/bedrock-sdk/src/streaming.ts
index 01f0956b..7a97ee64 100644
--- packages/bedrock-sdk/src/streaming.ts
+++ packages/bedrock-sdk/src/streaming.ts
@@ -2,11 +2,8 @@ import { EventStreamMarshaller } from '@smithy/eventstream-serde-node';
 import { fromBase64, toBase64 } from '@smithy/util-base64';
 import { streamCollector } from '@smithy/fetch-http-handler';
 import { EventStreamSerdeContext, SerdeContext } from '@smithy/types';
-import {
-  Stream as CoreStream,
-  readableStreamAsyncIterable,
-  ServerSentEvent,
-} from '@anthropic-ai/sdk/streaming';
+import { Stream as CoreStream, ServerSentEvent } from '@anthropic-ai/sdk/streaming';
+import { ReadableStreamToAsyncIterable } from '@anthropic-ai/sdk/internal/stream-utils';
 import { AnthropicError } from '@anthropic-ai/sdk/error';
 import { APIError } from '@anthropic-ai/sdk';
 import { createResponseHeaders, safeJSON } from '@anthropic-ai/sdk/core';
@@ -42,7 +39,7 @@ export class Stream<Item> extends CoreStream<Item> {
         throw new AnthropicError(`Attempted to iterate over a response with no body`);
       }
 
-      const responseBodyIter = readableStreamAsyncIterable<Bytes>(response.body);
+      const responseBodyIter = ReadableStreamToAsyncIterable<Bytes>(response.body);
       const eventStream = de_ResponseStream(responseBodyIter, getMinimalSerdeContext());
       for await (const event of eventStream) {
         if (event.chunk && event.chunk.bytes) {
diff --git packages/vertex-sdk/CHANGELOG.md packages/vertex-sdk/CHANGELOG.md
index e01d1d71..9e83b1e8 100644
--- packages/vertex-sdk/CHANGELOG.md
+++ packages/vertex-sdk/CHANGELOG.md
@@ -1,5 +1,13 @@
 # Changelog
 
+## 0.6.4 (2025-01-23)
+
+Full Changelog: [vertex-sdk-v0.6.3...vertex-sdk-v0.6.4](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.3...vertex-sdk-v0.6.4)
+
+### Chores
+
+* **vertex:** bump dependency on @anthropic-ai/sdk ([a1c7fcd](https://github.com/anthropics/anthropic-sdk-typescript/commit/a1c7fcdce081f860cbb1148c3862e3303ddb8a62))
+
 ## 0.6.3 (2025-01-21)
 
 Full Changelog: [vertex-sdk-v0.6.2...vertex-sdk-v0.6.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.2...vertex-sdk-v0.6.3)
diff --git packages/vertex-sdk/package.json packages/vertex-sdk/package.json
index ae4cf6f9..ac5bda51 100644
--- packages/vertex-sdk/package.json
+++ packages/vertex-sdk/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/vertex-sdk",
-  "version": "0.6.3",
+  "version": "0.6.4",
   "description": "The official TypeScript library for the Anthropic Vertex API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
index f8abd4b9..da232fe3 100644
--- packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
+++ packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
@@ -4,8 +4,8 @@ const pkgJson = require('../dist/package.json');
 for (const dep in pkgJson.dependencies) {
   // ensure we point to NPM instead of a local directory
   if (dep === '@anthropic-ai/sdk') {
-    pkgJson.dependencies[dep] = '>=0.14 <1';
+    pkgJson.dependencies[dep] = '>=0.35 <1';
   }
 }
 
-fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
+fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));
diff --git src/index.ts src/index.ts
index 44f6bc2d..0872e7a7 100644
--- src/index.ts
+++ src/index.ts
@@ -33,9 +33,19 @@ import {
 import {
   Base64PDFSource,
   CacheControlEphemeral,
+  CitationCharLocation,
+  CitationCharLocationParam,
+  CitationContentBlockLocation,
+  CitationContentBlockLocationParam,
+  CitationPageLocation,
+  CitationPageLocationParam,
+  CitationsConfigParam,
+  CitationsDelta,
   ContentBlock,
   ContentBlockDeltaEvent,
   ContentBlockParam,
+  ContentBlockSource,
+  ContentBlockSourceContent,
   ContentBlockStartEvent,
   ContentBlockStopEvent,
   DocumentBlockParam,
@@ -57,6 +67,7 @@ import {
   Messages,
   Metadata,
   Model,
+  PlainTextSource,
   RawContentBlockDeltaEvent,
   RawContentBlockStartEvent,
   RawContentBlockStopEvent,
@@ -66,6 +77,8 @@ import {
   RawMessageStreamEvent,
   TextBlock,
   TextBlockParam,
+  TextCitation,
+  TextCitationParam,
   TextDelta,
   Tool,
   ToolChoice,
@@ -322,9 +335,19 @@ export declare namespace Anthropic {
     Messages as Messages,
     type Base64PDFSource as Base64PDFSource,
     type CacheControlEphemeral as CacheControlEphemeral,
+    type CitationCharLocation as CitationCharLocation,
+    type CitationCharLocationParam as CitationCharLocationParam,
+    type CitationContentBlockLocation as CitationContentBlockLocation,
+    type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
+    type CitationPageLocation as CitationPageLocation,
+    type CitationPageLocationParam as CitationPageLocationParam,
+    type CitationsConfigParam as CitationsConfigParam,
+    type CitationsDelta as CitationsDelta,
     type ContentBlock as ContentBlock,
     type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
     type ContentBlockParam as ContentBlockParam,
+    type ContentBlockSource as ContentBlockSource,
+    type ContentBlockSourceContent as ContentBlockSourceContent,
     type ContentBlockStartEvent as ContentBlockStartEvent,
     type ContentBlockStopEvent as ContentBlockStopEvent,
     type DocumentBlockParam as DocumentBlockParam,
@@ -340,6 +363,7 @@ export declare namespace Anthropic {
     type MessageTokensCount as MessageTokensCount,
     type Metadata as Metadata,
     type Model as Model,
+    type PlainTextSource as PlainTextSource,
     type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
     type RawContentBlockStartEvent as RawContentBlockStartEvent,
     type RawContentBlockStopEvent as RawContentBlockStopEvent,
@@ -349,6 +373,8 @@ export declare namespace Anthropic {
     type RawMessageStreamEvent as RawMessageStreamEvent,
     type TextBlock as TextBlock,
     type TextBlockParam as TextBlockParam,
+    type TextCitation as TextCitation,
+    type TextCitationParam as TextCitationParam,
     type TextDelta as TextDelta,
     type Tool as Tool,
     type ToolChoice as ToolChoice,
diff --git src/internal/decoders/jsonl.ts src/internal/decoders/jsonl.ts
index 8d3693d8..15751255 100644
--- src/internal/decoders/jsonl.ts
+++ src/internal/decoders/jsonl.ts
@@ -1,5 +1,5 @@
 import { AnthropicError } from '../../error';
-import { readableStreamAsyncIterable } from '../../streaming';
+import { ReadableStreamToAsyncIterable } from '../stream-utils';
 import { type Response } from '../../_shims/index';
 import { LineDecoder, type Bytes } from './line';
 
@@ -36,6 +36,6 @@ export class JSONLDecoder<T> {
       throw new AnthropicError(`Attempted to iterate over a response with no body`);
     }
 
-    return new JSONLDecoder(readableStreamAsyncIterable<Bytes>(response.body), controller);
+    return new JSONLDecoder(ReadableStreamToAsyncIterable<Bytes>(response.body), controller);
   }
 }
diff --git a/src/internal/stream-utils.ts b/src/internal/stream-utils.ts
new file mode 100644
index 00000000..37f7793c
--- /dev/null
+++ src/internal/stream-utils.ts
@@ -0,0 +1,32 @@
+/**
+ * Most browsers don't yet have async iterable support for ReadableStream,
+ * and Node has a very different way of reading bytes from its "ReadableStream".
+ *
+ * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
+ */
+export function ReadableStreamToAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
+  if (stream[Symbol.asyncIterator]) return stream;
+
+  const reader = stream.getReader();
+  return {
+    async next() {
+      try {
+        const result = await reader.read();
+        if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
+        return result;
+      } catch (e) {
+        reader.releaseLock(); // release lock when stream becomes errored
+        throw e;
+      }
+    },
+    async return() {
+      const cancelPromise = reader.cancel();
+      reader.releaseLock();
+      await cancelPromise;
+      return { done: true, value: undefined };
+    },
+    [Symbol.asyncIterator]() {
+      return this;
+    },
+  };
+}
diff --git src/lib/BetaMessageStream.ts src/lib/BetaMessageStream.ts
index 06fbc46a..5de54f06 100644
--- src/lib/BetaMessageStream.ts
+++ src/lib/BetaMessageStream.ts
@@ -9,6 +9,7 @@ import {
   type MessageCreateParams as BetaMessageCreateParams,
   type MessageCreateParamsBase as BetaMessageCreateParamsBase,
   type BetaTextBlock,
+  type BetaTextCitation,
 } from '@anthropic-ai/sdk/resources/beta/messages/messages';
 import { type ReadableStream, type Response } from '@anthropic-ai/sdk/_shims/index';
 import { Stream } from '@anthropic-ai/sdk/streaming';
@@ -18,6 +19,7 @@ export interface MessageStreamEvents {
   connect: () => void;
   streamEvent: (event: BetaMessageStreamEvent, snapshot: BetaMessage) => void;
   text: (textDelta: string, textSnapshot: string) => void;
+  citation: (citation: BetaTextCitation, citationsSnapshot: BetaTextCitation[]) => void;
   inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
   message: (message: BetaMessage) => void;
   contentBlock: (content: BetaContentBlock) => void;
@@ -55,6 +57,7 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
   #errored = false;
   #aborted = false;
   #catchingPromiseCreated = false;
+  #response: Response | null | undefined;
   #request_id: string | null | undefined;
 
   constructor() {
@@ -76,6 +79,10 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     this.#endPromise.catch(() => {});
   }
 
+  get response(): Response | null | undefined {
+    return this.#response;
+  }
+
   get request_id(): string | null | undefined {
     return this.#request_id;
   }
@@ -183,6 +190,7 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
 
   protected _connected(response: Response | null) {
     if (this.ended) return;
+    this.#response = response;
     this.#request_id = response?.headers.get('request-id');
     this.#resolveConnectedPromise(response);
     this._emit('connect');
@@ -407,12 +415,27 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     switch (event.type) {
       case 'content_block_delta': {
         const content = messageSnapshot.content.at(-1)!;
-        if (event.delta.type === 'text_delta' && content.type === 'text') {
-          this._emit('text', event.delta.text, content.text || '');
-        } else if (event.delta.type === 'input_json_delta' && content.type === 'tool_use') {
-          if (content.input) {
-            this._emit('inputJson', event.delta.partial_json, content.input);
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (content.type === 'text') {
+              this._emit('text', event.delta.text, content.text || '');
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (content.type === 'text') {
+              this._emit('citation', event.delta.citation, content.citations ?? []);
+            }
+            break;
+          }
+          case 'input_json_delta': {
+            if (content.type === 'tool_use' && content.input) {
+              this._emit('inputJson', event.delta.partial_json, content.input);
+            }
+            break;
           }
+          default:
+            checkNever(event.delta);
         }
         break;
       }
@@ -499,24 +522,43 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
         return snapshot;
       case 'content_block_delta': {
         const snapshotContent = snapshot.content.at(event.index);
-        if (snapshotContent?.type === 'text' && event.delta.type === 'text_delta') {
-          snapshotContent.text += event.delta.text;
-        } else if (snapshotContent?.type === 'tool_use' && event.delta.type === 'input_json_delta') {
-          // we need to keep track of the raw JSON string as well so that we can
-          // re-parse it for each delta, for now we just store it as an untyped
-          // non-enumerable property on the snapshot
-          let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
-          jsonBuf += event.delta.partial_json;
-
-          Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
-            value: jsonBuf,
-            enumerable: false,
-            writable: true,
-          });
-
-          if (jsonBuf) {
-            snapshotContent.input = partialParse(jsonBuf);
+
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.text += event.delta.text;
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.citations ??= [];
+              snapshotContent.citations.push(event.delta.citation);
+            }
+            break;
           }
+          case 'input_json_delta': {
+            if (snapshotContent?.type === 'tool_use') {
+              // we need to keep track of the raw JSON string as well so that we can
+              // re-parse it for each delta, for now we just store it as an untyped
+              // non-enumerable property on the snapshot
+              let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
+              jsonBuf += event.delta.partial_json;
+
+              Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
+                value: jsonBuf,
+                enumerable: false,
+                writable: true,
+              });
+
+              if (jsonBuf) {
+                snapshotContent.input = partialParse(jsonBuf);
+              }
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
         return snapshot;
       }
@@ -591,3 +633,6 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     return stream.toReadableStream();
   }
 }
+
+// used to ensure exhaustive case matching without throwing a runtime error
+function checkNever(x: never) {}
diff --git src/lib/MessageStream.ts src/lib/MessageStream.ts
index 65e84b29..4ce3a382 100644
--- src/lib/MessageStream.ts
+++ src/lib/MessageStream.ts
@@ -9,6 +9,7 @@ import {
   type MessageCreateParams,
   type MessageCreateParamsBase,
   type TextBlock,
+  type TextCitation,
 } from '@anthropic-ai/sdk/resources/messages';
 import { type ReadableStream, type Response } from '@anthropic-ai/sdk/_shims/index';
 import { Stream } from '@anthropic-ai/sdk/streaming';
@@ -18,6 +19,7 @@ export interface MessageStreamEvents {
   connect: () => void;
   streamEvent: (event: MessageStreamEvent, snapshot: Message) => void;
   text: (textDelta: string, textSnapshot: string) => void;
+  citation: (citation: TextCitation, citationsSnapshot: TextCitation[]) => void;
   inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
   message: (message: Message) => void;
   contentBlock: (content: ContentBlock) => void;
@@ -55,6 +57,7 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
   #errored = false;
   #aborted = false;
   #catchingPromiseCreated = false;
+  #response: Response | null | undefined;
   #request_id: string | null | undefined;
 
   constructor() {
@@ -76,6 +79,10 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     this.#endPromise.catch(() => {});
   }
 
+  get response(): Response | null | undefined {
+    return this.#response;
+  }
+
   get request_id(): string | null | undefined {
     return this.#request_id;
   }
@@ -183,6 +190,7 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
 
   protected _connected(response: Response | null) {
     if (this.ended) return;
+    this.#response = response;
     this.#request_id = response?.headers.get('request-id');
     this.#resolveConnectedPromise(response);
     this._emit('connect');
@@ -407,12 +415,27 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     switch (event.type) {
       case 'content_block_delta': {
         const content = messageSnapshot.content.at(-1)!;
-        if (event.delta.type === 'text_delta' && content.type === 'text') {
-          this._emit('text', event.delta.text, content.text || '');
-        } else if (event.delta.type === 'input_json_delta' && content.type === 'tool_use') {
-          if (content.input) {
-            this._emit('inputJson', event.delta.partial_json, content.input);
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (content.type === 'text') {
+              this._emit('text', event.delta.text, content.text || '');
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (content.type === 'text') {
+              this._emit('citation', event.delta.citation, content.citations ?? []);
+            }
+            break;
           }
+          case 'input_json_delta': {
+            if (content.type === 'tool_use' && content.input) {
+              this._emit('inputJson', event.delta.partial_json, content.input);
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
         break;
       }
@@ -499,25 +522,45 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
         return snapshot;
       case 'content_block_delta': {
         const snapshotContent = snapshot.content.at(event.index);
-        if (snapshotContent?.type === 'text' && event.delta.type === 'text_delta') {
-          snapshotContent.text += event.delta.text;
-        } else if (snapshotContent?.type === 'tool_use' && event.delta.type === 'input_json_delta') {
-          // we need to keep track of the raw JSON string as well so that we can
-          // re-parse it for each delta, for now we just store it as an untyped
-          // non-enumerable property on the snapshot
-          let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
-          jsonBuf += event.delta.partial_json;
-
-          Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
-            value: jsonBuf,
-            enumerable: false,
-            writable: true,
-          });
-
-          if (jsonBuf) {
-            snapshotContent.input = partialParse(jsonBuf);
+
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.text += event.delta.text;
+            }
+            break;
           }
+          case 'citations_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.citations ??= [];
+              snapshotContent.citations.push(event.delta.citation);
+            }
+            break;
+          }
+          case 'input_json_delta': {
+            if (snapshotContent?.type === 'tool_use') {
+              // we need to keep track of the raw JSON string as well so that we can
+              // re-parse it for each delta, for now we just store it as an untyped
+              // non-enumerable property on the snapshot
+              let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
+              jsonBuf += event.delta.partial_json;
+
+              Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
+                value: jsonBuf,
+                enumerable: false,
+                writable: true,
+              });
+
+              if (jsonBuf) {
+                snapshotContent.input = partialParse(jsonBuf);
+              }
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
+
         return snapshot;
       }
       case 'content_block_stop':
@@ -591,3 +634,6 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     return stream.toReadableStream();
   }
 }
+
+// used to ensure exhaustive case matching without throwing a runtime error
+function checkNever(x: never) {}
diff --git src/resources/beta/beta.ts src/resources/beta/beta.ts
index e29a187c..a1f3f0d4 100644
--- src/resources/beta/beta.ts
+++ src/resources/beta/beta.ts
@@ -8,8 +8,18 @@ import {
   BetaBase64PDFBlock,
   BetaBase64PDFSource,
   BetaCacheControlEphemeral,
+  BetaCitationCharLocation,
+  BetaCitationCharLocationParam,
+  BetaCitationContentBlockLocation,
+  BetaCitationContentBlockLocationParam,
+  BetaCitationPageLocation,
+  BetaCitationPageLocationParam,
+  BetaCitationsConfigParam,
+  BetaCitationsDelta,
   BetaContentBlock,
   BetaContentBlockParam,
+  BetaContentBlockSource,
+  BetaContentBlockSourceContent,
   BetaImageBlockParam,
   BetaInputJSONDelta,
   BetaMessage,
@@ -17,6 +27,7 @@ import {
   BetaMessageParam,
   BetaMessageTokensCount,
   BetaMetadata,
+  BetaPlainTextSource,
   BetaRawContentBlockDeltaEvent,
   BetaRawContentBlockStartEvent,
   BetaRawContentBlockStopEvent,
@@ -26,6 +37,8 @@ import {
   BetaRawMessageStreamEvent,
   BetaTextBlock,
   BetaTextBlockParam,
+  BetaTextCitation,
+  BetaTextCitationParam,
   BetaTextDelta,
   BetaTool,
   BetaToolBash20241022,
@@ -163,8 +176,18 @@ export declare namespace Beta {
     type BetaBase64PDFBlock as BetaBase64PDFBlock,
     type BetaBase64PDFSource as BetaBase64PDFSource,
     type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
+    type BetaCitationCharLocation as BetaCitationCharLocation,
+    type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
+    type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
+    type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
+    type BetaCitationPageLocation as BetaCitationPageLocation,
+    type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
+    type BetaCitationsConfigParam as BetaCitationsConfigParam,
+    type BetaCitationsDelta as BetaCitationsDelta,
     type BetaContentBlock as BetaContentBlock,
     type BetaContentBlockParam as BetaContentBlockParam,
+    type BetaContentBlockSource as BetaContentBlockSource,
+    type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
     type BetaImageBlockParam as BetaImageBlockParam,
     type BetaInputJSONDelta as BetaInputJSONDelta,
     type BetaMessage as BetaMessage,
@@ -172,6 +195,7 @@ export declare namespace Beta {
     type BetaMessageParam as BetaMessageParam,
     type BetaMessageTokensCount as BetaMessageTokensCount,
     type BetaMetadata as BetaMetadata,
+    type BetaPlainTextSource as BetaPlainTextSource,
     type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
     type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
     type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
@@ -181,6 +205,8 @@ export declare namespace Beta {
     type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
     type BetaTextBlock as BetaTextBlock,
     type BetaTextBlockParam as BetaTextBlockParam,
+    type BetaTextCitation as BetaTextCitation,
+    type BetaTextCitationParam as BetaTextCitationParam,
     type BetaTextDelta as BetaTextDelta,
     type BetaTool as BetaTool,
     type BetaToolBash20241022 as BetaToolBash20241022,
diff --git src/resources/beta/index.ts src/resources/beta/index.ts
index a68f2327..743f9c42 100644
--- src/resources/beta/index.ts
+++ src/resources/beta/index.ts
@@ -21,8 +21,18 @@ export {
   type BetaBase64PDFBlock,
   type BetaBase64PDFSource,
   type BetaCacheControlEphemeral,
+  type BetaCitationCharLocation,
+  type BetaCitationCharLocationParam,
+  type BetaCitationContentBlockLocation,
+  type BetaCitationContentBlockLocationParam,
+  type BetaCitationPageLocation,
+  type BetaCitationPageLocationParam,
+  type BetaCitationsConfigParam,
+  type BetaCitationsDelta,
   type BetaContentBlock,
   type BetaContentBlockParam,
+  type BetaContentBlockSource,
+  type BetaContentBlockSourceContent,
   type BetaImageBlockParam,
   type BetaInputJSONDelta,
   type BetaMessage,
@@ -30,6 +40,7 @@ export {
   type BetaMessageParam,
   type BetaMessageTokensCount,
   type BetaMetadata,
+  type BetaPlainTextSource,
   type BetaRawContentBlockDeltaEvent,
   type BetaRawContentBlockStartEvent,
   type BetaRawContentBlockStopEvent,
@@ -39,6 +50,8 @@ export {
   type BetaRawMessageStreamEvent,
   type BetaTextBlock,
   type BetaTextBlockParam,
+  type BetaTextCitation,
+  type BetaTextCitationParam,
   type BetaTextDelta,
   type BetaTool,
   type BetaToolBash20241022,
diff --git src/resources/beta/messages/batches.ts src/resources/beta/messages/batches.ts
index 74f4e53b..6370119c 100644
--- src/resources/beta/messages/batches.ts
+++ src/resources/beta/messages/batches.ts
@@ -86,9 +86,10 @@ export class Batches extends APIResource {
   }
 
   /**
-   * This endpoint is idempotent and can be used to poll for Message Batch
-   * completion. To access the results of a Message Batch, make a request to the
-   * `results_url` field in the response.
+   * Delete a Message Batch.
+   *
+   * Message Batches can only be deleted once they've finished processing. If you'd
+   * like to delete an in-progress batch, you must first cancel it.
    */
   delete(
     messageBatchId: string,
@@ -298,6 +299,10 @@ export interface BetaMessageBatchExpiredResult {
   type: 'expired';
 }
 
+/**
+ * This is a single line in the response `.jsonl` file and does not represent the
+ * response as a whole.
+ */
 export interface BetaMessageBatchIndividualResponse {
   /**
    * Developer-provided ID created for each request in a Message Batch. Useful for
diff --git src/resources/beta/messages/index.ts src/resources/beta/messages/index.ts
index eac5d34f..51a0f935 100644
--- src/resources/beta/messages/index.ts
+++ src/resources/beta/messages/index.ts
@@ -24,8 +24,18 @@ export {
   type BetaBase64PDFBlock,
   type BetaBase64PDFSource,
   type BetaCacheControlEphemeral,
+  type BetaCitationCharLocation,
+  type BetaCitationCharLocationParam,
+  type BetaCitationContentBlockLocation,
+  type BetaCitationContentBlockLocationParam,
+  type BetaCitationPageLocation,
+  type BetaCitationPageLocationParam,
+  type BetaCitationsConfigParam,
+  type BetaCitationsDelta,
   type BetaContentBlock,
   type BetaContentBlockParam,
+  type BetaContentBlockSource,
+  type BetaContentBlockSourceContent,
   type BetaImageBlockParam,
   type BetaInputJSONDelta,
   type BetaMessage,
@@ -33,6 +43,7 @@ export {
   type BetaMessageParam,
   type BetaMessageTokensCount,
   type BetaMetadata,
+  type BetaPlainTextSource,
   type BetaRawContentBlockDeltaEvent,
   type BetaRawContentBlockStartEvent,
   type BetaRawContentBlockStopEvent,
@@ -42,6 +53,8 @@ export {
   type BetaRawMessageStreamEvent,
   type BetaTextBlock,
   type BetaTextBlockParam,
+  type BetaTextCitation,
+  type BetaTextCitationParam,
   type BetaTextDelta,
   type BetaTool,
   type BetaToolBash20241022,
diff --git src/resources/beta/messages/messages.ts src/resources/beta/messages/messages.ts
index ecb1d79f..3b35717a 100644
--- src/resources/beta/messages/messages.ts
+++ src/resources/beta/messages/messages.ts
@@ -120,11 +120,17 @@ export class Messages extends APIResource {
 export type BetaMessageStreamParams = MessageCreateParamsBase;
 
 export interface BetaBase64PDFBlock {
-  source: BetaBase64PDFSource;
+  source: BetaBase64PDFSource | BetaPlainTextSource | BetaContentBlockSource;
 
   type: 'document';
 
   cache_control?: BetaCacheControlEphemeral | null;
+
+  citations?: BetaCitationsConfigParam;
+
+  context?: string | null;
+
+  title?: string | null;
 }
 
 export interface BetaBase64PDFSource {
@@ -139,6 +145,100 @@ export interface BetaCacheControlEphemeral {
   type: 'ephemeral';
 }
 
+export interface BetaCitationCharLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface BetaCitationCharLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface BetaCitationContentBlockLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface BetaCitationContentBlockLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface BetaCitationPageLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface BetaCitationPageLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface BetaCitationsConfigParam {
+  enabled?: boolean;
+}
+
+export interface BetaCitationsDelta {
+  citation: BetaCitationCharLocation | BetaCitationPageLocation | BetaCitationContentBlockLocation;
+
+  type: 'citations_delta';
+}
+
 export type BetaContentBlock = BetaTextBlock | BetaToolUseBlock;
 
 export type BetaContentBlockParam =
@@ -148,6 +248,14 @@ export type BetaContentBlockParam =
   | BetaToolResultBlockParam
   | BetaBase64PDFBlock;
 
+export interface BetaContentBlockSource {
+  content: string | Array<BetaContentBlockSourceContent>;
+
+  type: 'content';
+}
+
+export type BetaContentBlockSourceContent = BetaTextBlockParam | BetaImageBlockParam;
+
 export interface BetaImageBlockParam {
   source: BetaImageBlockParam.Source;
 
@@ -309,8 +417,16 @@ export interface BetaMetadata {
   user_id?: string | null;
 }
 
+export interface BetaPlainTextSource {
+  data: string;
+
+  media_type: 'text/plain';
+
+  type: 'text';
+}
+
 export interface BetaRawContentBlockDeltaEvent {
-  delta: BetaTextDelta | BetaInputJSONDelta;
+  delta: BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta;
 
   index: number;
 
@@ -380,6 +496,15 @@ export type BetaRawMessageStreamEvent =
   | BetaRawContentBlockStopEvent;
 
 export interface BetaTextBlock {
+  /**
+   * Citations supporting the text block.
+   *
+   * The type of citation returned will depend on the type of document being cited.
+   * Citing a PDF results in `page_location`, plain text results in `char_location`,
+   * and content document results in `content_block_location`.
+   */
+  citations: Array<BetaTextCitation> | null;
+
   text: string;
 
   type: 'text';
@@ -391,8 +516,20 @@ export interface BetaTextBlockParam {
   type: 'text';
 
   cache_control?: BetaCacheControlEphemeral | null;
+
+  citations?: Array<BetaTextCitationParam> | null;
 }
 
+export type BetaTextCitation =
+  | BetaCitationCharLocation
+  | BetaCitationPageLocation
+  | BetaCitationContentBlockLocation;
+
+export type BetaTextCitationParam =
+  | BetaCitationCharLocationParam
+  | BetaCitationPageLocationParam
+  | BetaCitationContentBlockLocationParam;
+
 export interface BetaTextDelta {
   text: string;
 
@@ -1110,8 +1247,18 @@ export declare namespace Messages {
     type BetaBase64PDFBlock as BetaBase64PDFBlock,
     type BetaBase64PDFSource as BetaBase64PDFSource,
     type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
+    type BetaCitationCharLocation as BetaCitationCharLocation,
+    type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
+    type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
+    type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
+    type BetaCitationPageLocation as BetaCitationPageLocation,
+    type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
+    type BetaCitationsConfigParam as BetaCitationsConfigParam,
+    type BetaCitationsDelta as BetaCitationsDelta,
     type BetaContentBlock as BetaContentBlock,
     type BetaContentBlockParam as BetaContentBlockParam,
+    type BetaContentBlockSource as BetaContentBlockSource,
+    type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
     type BetaImageBlockParam as BetaImageBlockParam,
     type BetaInputJSONDelta as BetaInputJSONDelta,
     type BetaMessage as BetaMessage,
@@ -1119,6 +1266,7 @@ export declare namespace Messages {
     type BetaMessageParam as BetaMessageParam,
     type BetaMessageTokensCount as BetaMessageTokensCount,
     type BetaMetadata as BetaMetadata,
+    type BetaPlainTextSource as BetaPlainTextSource,
     type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
     type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
     type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
@@ -1128,6 +1276,8 @@ export declare namespace Messages {
     type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
     type BetaTextBlock as BetaTextBlock,
     type BetaTextBlockParam as BetaTextBlockParam,
+    type BetaTextCitation as BetaTextCitation,
+    type BetaTextCitationParam as BetaTextCitationParam,
     type BetaTextDelta as BetaTextDelta,
     type BetaTool as BetaTool,
     type BetaToolBash20241022 as BetaToolBash20241022,
diff --git src/resources/index.ts src/resources/index.ts
index 23366973..3d4b385a 100644
--- src/resources/index.ts
+++ src/resources/index.ts
@@ -27,9 +27,19 @@ export {
   Messages,
   type Base64PDFSource,
   type CacheControlEphemeral,
+  type CitationCharLocation,
+  type CitationCharLocationParam,
+  type CitationContentBlockLocation,
+  type CitationContentBlockLocationParam,
+  type CitationPageLocation,
+  type CitationPageLocationParam,
+  type CitationsConfigParam,
+  type CitationsDelta,
   type ContentBlock,
   type ContentBlockDeltaEvent,
   type ContentBlockParam,
+  type ContentBlockSource,
+  type ContentBlockSourceContent,
   type ContentBlockStartEvent,
   type ContentBlockStopEvent,
   type DocumentBlockParam,
@@ -47,6 +57,7 @@ export {
   type MessageTokensCount,
   type Metadata,
   type Model,
+  type PlainTextSource,
   type RawContentBlockDeltaEvent,
   type RawContentBlockStartEvent,
   type RawContentBlockStopEvent,
@@ -56,6 +67,8 @@ export {
   type RawMessageStreamEvent,
   type TextBlock,
   type TextBlockParam,
+  type TextCitation,
+  type TextCitationParam,
   type TextDelta,
   type Tool,
   type ToolChoice,
diff --git src/resources/messages/batches.ts src/resources/messages/batches.ts
index a6b328e2..46bc64ed 100644
--- src/resources/messages/batches.ts
+++ src/resources/messages/batches.ts
@@ -50,9 +50,10 @@ export class Batches extends APIResource {
   }
 
   /**
-   * This endpoint is idempotent and can be used to poll for Message Batch
-   * completion. To access the results of a Message Batch, make a request to the
-   * `results_url` field in the response.
+   * Delete a Message Batch.
+   *
+   * Message Batches can only be deleted once they've finished processing. If you'd
+   * like to delete an in-progress batch, you must first cancel it.
    */
   delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<DeletedMessageBatch> {
     return this._client.delete(`/v1/messages/batches/${messageBatchId}`, options);
@@ -206,6 +207,10 @@ export interface MessageBatchExpiredResult {
   type: 'expired';
 }
 
+/**
+ * This is a single line in the response `.jsonl` file and does not represent the
+ * response as a whole.
+ */
 export interface MessageBatchIndividualResponse {
   /**
    * Developer-provided ID created for each request in a Message Batch. Useful for
diff --git src/resources/messages/index.ts src/resources/messages/index.ts
index 1c9178ad..2f7a0a7f 100644
--- src/resources/messages/index.ts
+++ src/resources/messages/index.ts
@@ -19,9 +19,19 @@ export {
   Messages,
   type Base64PDFSource,
   type CacheControlEphemeral,
+  type CitationCharLocation,
+  type CitationCharLocationParam,
+  type CitationContentBlockLocation,
+  type CitationContentBlockLocationParam,
+  type CitationPageLocation,
+  type CitationPageLocationParam,
+  type CitationsConfigParam,
+  type CitationsDelta,
   type ContentBlock,
   type ContentBlockDeltaEvent,
   type ContentBlockParam,
+  type ContentBlockSource,
+  type ContentBlockSourceContent,
   type ContentBlockStartEvent,
   type ContentBlockStopEvent,
   type DocumentBlockParam,
@@ -37,6 +47,7 @@ export {
   type MessageTokensCount,
   type Metadata,
   type Model,
+  type PlainTextSource,
   type RawContentBlockDeltaEvent,
   type RawContentBlockStartEvent,
   type RawContentBlockStopEvent,
@@ -46,6 +57,8 @@ export {
   type RawMessageStreamEvent,
   type TextBlock,
   type TextBlockParam,
+  type TextCitation,
+  type TextCitationParam,
   type TextDelta,
   type Tool,
   type ToolChoice,
diff --git src/resources/messages/messages.ts src/resources/messages/messages.ts
index 12cc9b83..f1b4fb8e 100644
--- src/resources/messages/messages.ts
+++ src/resources/messages/messages.ts
@@ -96,6 +96,100 @@ export interface CacheControlEphemeral {
   type: 'ephemeral';
 }
 
+export interface CitationCharLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface CitationCharLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface CitationContentBlockLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface CitationContentBlockLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface CitationPageLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface CitationPageLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface CitationsConfigParam {
+  enabled?: boolean;
+}
+
+export interface CitationsDelta {
+  citation: CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
+
+  type: 'citations_delta';
+}
+
 export type ContentBlock = TextBlock | ToolUseBlock;
 
 export type ContentBlockDeltaEvent = RawContentBlockDeltaEvent;
@@ -107,16 +201,30 @@ export type ContentBlockParam =
   | ToolResultBlockParam
   | DocumentBlockParam;
 
+export interface ContentBlockSource {
+  content: string | Array<ContentBlockSourceContent>;
+
+  type: 'content';
+}
+
+export type ContentBlockSourceContent = TextBlockParam | ImageBlockParam;
+
 export type ContentBlockStartEvent = RawContentBlockStartEvent;
 
 export type ContentBlockStopEvent = RawContentBlockStopEvent;
 
 export interface DocumentBlockParam {
-  source: Base64PDFSource;
+  source: Base64PDFSource | PlainTextSource | ContentBlockSource;
 
   type: 'document';
 
   cache_control?: CacheControlEphemeral | null;
+
+  citations?: CitationsConfigParam;
+
+  context?: string | null;
+
+  title?: string | null;
 }
 
 export interface ImageBlockParam {
@@ -322,8 +430,16 @@ const DEPRECATED_MODELS: {
   'claude-2.0': 'July 21st, 2025',
 };
 
+export interface PlainTextSource {
+  data: string;
+
+  media_type: 'text/plain';
+
+  type: 'text';
+}
+
 export interface RawContentBlockDeltaEvent {
-  delta: TextDelta | InputJSONDelta;
+  delta: TextDelta | InputJSONDelta | CitationsDelta;
 
   index: number;
 
@@ -393,6 +509,15 @@ export type RawMessageStreamEvent =
   | RawContentBlockStopEvent;
 
 export interface TextBlock {
+  /**
+   * Citations supporting the text block.
+   *
+   * The type of citation returned will depend on the type of document being cited.
+   * Citing a PDF results in `page_location`, plain text results in `char_location`,
+   * and content document results in `content_block_location`.
+   */
+  citations: Array<TextCitation> | null;
+
   text: string;
 
   type: 'text';
@@ -404,8 +529,17 @@ export interface TextBlockParam {
   type: 'text';
 
   cache_control?: CacheControlEphemeral | null;
+
+  citations?: Array<TextCitationParam> | null;
 }
 
+export type TextCitation = CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
+
+export type TextCitationParam =
+  | CitationCharLocationParam
+  | CitationPageLocationParam
+  | CitationContentBlockLocationParam;
+
 export interface TextDelta {
   text: string;
 
@@ -1069,9 +1203,19 @@ export declare namespace Messages {
   export {
     type Base64PDFSource as Base64PDFSource,
     type CacheControlEphemeral as CacheControlEphemeral,
+    type CitationCharLocation as CitationCharLocation,
+    type CitationCharLocationParam as CitationCharLocationParam,
+    type CitationContentBlockLocation as CitationContentBlockLocation,
+    type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
+    type CitationPageLocation as CitationPageLocation,
+    type CitationPageLocationParam as CitationPageLocationParam,
+    type CitationsConfigParam as CitationsConfigParam,
+    type CitationsDelta as CitationsDelta,
     type ContentBlock as ContentBlock,
     type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
     type ContentBlockParam as ContentBlockParam,
+    type ContentBlockSource as ContentBlockSource,
+    type ContentBlockSourceContent as ContentBlockSourceContent,
     type ContentBlockStartEvent as ContentBlockStartEvent,
     type ContentBlockStopEvent as ContentBlockStopEvent,
     type DocumentBlockParam as DocumentBlockParam,
@@ -1088,6 +1232,7 @@ export declare namespace Messages {
     type MessageTokensCount as MessageTokensCount,
     type Metadata as Metadata,
     type Model as Model,
+    type PlainTextSource as PlainTextSource,
     type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
     type RawContentBlockStartEvent as RawContentBlockStartEvent,
     type RawContentBlockStopEvent as RawContentBlockStopEvent,
@@ -1097,6 +1242,8 @@ export declare namespace Messages {
     type RawMessageStreamEvent as RawMessageStreamEvent,
     type TextBlock as TextBlock,
     type TextBlockParam as TextBlockParam,
+    type TextCitation as TextCitation,
+    type TextCitationParam as TextCitationParam,
     type TextDelta as TextDelta,
     type Tool as Tool,
     type ToolChoice as ToolChoice,
diff --git src/streaming.ts src/streaming.ts
index 2eff6ef9..ad1b78e6 100644
--- src/streaming.ts
+++ src/streaming.ts
@@ -1,6 +1,7 @@
 import { ReadableStream, type Response } from './_shims/index';
 import { AnthropicError } from './error';
 import { LineDecoder } from './internal/decoders/line';
+import { ReadableStreamToAsyncIterable } from './internal/stream-utils';
 
 import { createResponseHeaders } from './core';
 import { APIError } from './error';
@@ -98,7 +99,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
     async function* iterLines(): AsyncGenerator<string, void, unknown> {
       const lineDecoder = new LineDecoder();
 
-      const iter = readableStreamAsyncIterable<Bytes>(readableStream);
+      const iter = ReadableStreamToAsyncIterable<Bytes>(readableStream);
       for await (const chunk of iter) {
         for (const line of lineDecoder.decode(chunk)) {
           yield line;
@@ -212,7 +213,7 @@ export async function* _iterSSEMessages(
   const sseDecoder = new SSEDecoder();
   const lineDecoder = new LineDecoder();
 
-  const iter = readableStreamAsyncIterable<Bytes>(response.body);
+  const iter = ReadableStreamToAsyncIterable<Bytes>(response.body);
   for await (const sseChunk of iterSSEChunks(iter)) {
     for (const line of lineDecoder.decode(sseChunk)) {
       const sse = sseDecoder.decode(line);
@@ -365,36 +366,3 @@ function partition(str: string, delimiter: string): [string, string, string] {
 
   return [str, '', ''];
 }
-
-/**
- * Most browsers don't yet have async iterable support for ReadableStream,
- * and Node has a very different way of reading bytes from its "ReadableStream".
- *
- * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
- */
-export function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
-  if (stream[Symbol.asyncIterator]) return stream;
-
-  const reader = stream.getReader();
-  return {
-    async next() {
-      try {
-        const result = await reader.read();
-        if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
-        return result;
-      } catch (e) {
-        reader.releaseLock(); // release lock when stream becomes errored
-        throw e;
-      }
-    },
-    async return() {
-      const cancelPromise = reader.cancel();
-      reader.releaseLock();
-      await cancelPromise;
-      return { done: true, value: undefined };
-    },
-    [Symbol.asyncIterator]() {
-      return this;
-    },
-  };
-}
diff --git src/version.ts src/version.ts
index 3f1d4329..0d285762 100644
--- src/version.ts
+++ src/version.ts
@@ -1 +1 @@
-export const VERSION = '0.35.0'; // x-release-please-version
+export const VERSION = '0.36.3'; // x-release-please-version
diff --git tests/api-resources/MessageStream.test.ts tests/api-resources/MessageStream.test.ts
index 0051d397..21407524 100644
--- tests/api-resources/MessageStream.test.ts
+++ tests/api-resources/MessageStream.test.ts
@@ -22,7 +22,7 @@ async function* messageIterable(message: Message): AsyncGenerator<MessageStreamE
     yield {
       type: 'content_block_start',
       content_block:
-        content.type === 'text' ? { type: 'text', text: '' }
+        content.type === 'text' ? { type: 'text', text: '', citations: null }
         : content.type === 'tool_use' ?
           {
             type: 'tool_use',
@@ -145,7 +145,7 @@ describe('MessageStream class', () => {
         type: 'message',
         id: 'msg_01hhptzfxdaeehfxfv070yb6b8',
         role: 'assistant',
-        content: [{ type: 'text', text: 'Hello there!' }],
+        content: [{ type: 'text', text: 'Hello there!', citations: null }],
         model: 'claude-3-opus-20240229',
         stop_reason: 'end_turn',
         stop_sequence: null,
@@ -221,15 +221,15 @@ describe('MessageStream class', () => {
         },
         {
           "args": [
-            "{"type":"content_block_start","content_block":{"type":"text","text":""},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":""}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"content_block_start","content_block":{"type":"text","text":"","citations":null},"index":0}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -243,7 +243,7 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":" ther"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello ther"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello ther","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -257,7 +257,7 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":"e!"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequ,ence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -271,39 +271,39 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_stop","index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
-            "{"type":"text","text":"Hello there!"}",
+            "{"type":"text","text":"Hello there!","citations":null}",
           ],
           "type": "contentBlock",
         },
         {
           "args": [
             "{"type":"message_delta","usage":{"output_tokens":6},"delta":{"stop_reason":"end_turn","stop_sequence":null}}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
             "{"type":"message_stop"}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "message",
         },
         {
           "args": [
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "finalMessage",
         },
@@ -320,6 +320,7 @@ describe('MessageStream class', () => {
       {
         "content": [
           {
+            "citations": null,
             "text": "Hello there!",
             "type": "text",
           },
@@ -356,7 +357,7 @@ describe('MessageStream class', () => {
         type: 'message',
         id: 'msg_01hhptzfxdaeehfxfv070yb6b8',
         role: 'assistant',
-        content: [{ type: 'text', text: 'Hello there!' }],
+        content: [{ type: 'text', text: 'Hello there!', citations: null }],
         model: 'claude-3-opus-20240229',
         stop_reason: 'end_turn',
         stop_sequence: null,
diff --git tests/api-resources/beta/messages/batches.test.ts tests/api-resources/beta/messages/batches.test.ts
index 98d39506..b91258ea 100644
--- tests/api-resources/beta/messages/batches.test.ts
+++ tests/api-resources/beta/messages/batches.test.ts
@@ -44,7 +44,21 @@ describe('resource batches', () => {
             stop_sequences: ['string'],
             stream: false,
             system: [
-              { text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
+              {
+                text: "Today's date is 2024-06-01.",
+                type: 'text',
+                cache_control: { type: 'ephemeral' },
+                citations: [
+                  {
+                    cited_text: 'cited_text',
+                    document_index: 0,
+                    document_title: 'x',
+                    end_char_index: 0,
+                    start_char_index: 0,
+                    type: 'char_location',
+                  },
+                ],
+              },
             ],
             temperature: 1,
             tool_choice: { type: 'auto', disable_parallel_tool_use: true },
@@ -190,14 +204,16 @@ describe('resource batches', () => {
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options instead of params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options instead of params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.beta.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options and params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options and params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.beta.messages.batches.results(
diff --git tests/api-resources/beta/messages/messages.test.ts tests/api-resources/beta/messages/messages.test.ts
index 493de962..f2f6964b 100644
--- tests/api-resources/beta/messages/messages.test.ts
+++ tests/api-resources/beta/messages/messages.test.ts
@@ -32,7 +32,23 @@ describe('resource messages', () => {
       metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
       stop_sequences: ['string'],
       stream: false,
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       temperature: 1,
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
@@ -74,7 +90,23 @@ describe('resource messages', () => {
     const response = await client.beta.messages.countTokens({
       messages: [{ content: 'string', role: 'user' }],
       model: 'string',
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
         {
diff --git tests/api-resources/messages/batches.test.ts tests/api-resources/messages/batches.test.ts
index 4137fa31..c7239648 100644
--- tests/api-resources/messages/batches.test.ts
+++ tests/api-resources/messages/batches.test.ts
@@ -43,7 +43,21 @@ describe('resource batches', () => {
             metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
             stop_sequences: ['string'],
             system: [
-              { text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
+              {
+                text: "Today's date is 2024-06-01.",
+                type: 'text',
+                cache_control: { type: 'ephemeral' },
+                citations: [
+                  {
+                    cited_text: 'cited_text',
+                    document_index: 0,
+                    document_title: 'x',
+                    end_char_index: 0,
+                    start_char_index: 0,
+                    type: 'char_location',
+                  },
+                ],
+              },
             ],
             temperature: 1,
             tool_choice: { type: 'auto', disable_parallel_tool_use: true },
@@ -154,7 +168,8 @@ describe('resource batches', () => {
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options instead of params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options instead of params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
diff --git tests/api-resources/messages/messages.test.ts tests/api-resources/messages/messages.test.ts
index 7b9d6f96..a5b5d328 100644
--- tests/api-resources/messages/messages.test.ts
+++ tests/api-resources/messages/messages.test.ts
@@ -32,7 +32,23 @@ describe('resource messages', () => {
       metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
       stop_sequences: ['string'],
       stream: false,
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       temperature: 1,
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
@@ -72,7 +88,23 @@ describe('resource messages', () => {
     const response = await client.messages.countTokens({
       messages: [{ content: 'string', role: 'user' }],
       model: 'string',
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
         {

Description

This PR updates the Anthropic TypeScript SDK to version 0.36.3, adding support for citations in message responses and making several other improvements to streaming functionality. The changes include adding citation types, improving streaming utilities, and updating documentation.

Changes

Changes

By filename:

  • BetaMessageStream.ts/MessageStream.ts:

    • Added support for citation events in message streams
    • Added response property to stream class
    • Improved type safety with exhaustive checks
    • Enhanced event handling for citations
  • stream-utils.ts:

    • Moved stream utilities to a dedicated file
    • Refactored ReadableStreamToAsyncIterable function
    • Improved async iteration handling
  • messages.ts:

    • Added new types for citations (CitationCharLocation, CitationPageLocation, etc.)
    • Enhanced TextBlock interface with citations support
    • Added citation configuration parameters
  • batches.ts:

    • Improved documentation for batch operations
    • Enhanced typing for batch responses
    • Added better support for JSONL responses
  • Version updates:

    • Main SDK: 0.35.0 → 0.36.3
    • Vertex SDK: 0.6.3 → 0.6.4
    • Bedrock SDK: 0.12.2 → 0.12.4
sequenceDiagram
    participant Client
    participant MessageStream
    participant StreamUtils
    participant APIResource
    
    Client->>MessageStream: Create stream
    MessageStream->>StreamUtils: Initialize ReadableStreamToAsyncIterable
    MessageStream->>APIResource: Send request
    APIResource-->>MessageStream: Return response
    
    loop For each event
        MessageStream->>StreamUtils: Process chunk
        StreamUtils-->>MessageStream: Return parsed data
        alt Is Citation Event
            MessageStream->>Client: Emit citation event
        else Is Text Event
            MessageStream->>Client: Emit text event
        end
    end
    
    MessageStream->>Client: Complete stream
Loading

Copy link

openai debug - [puLL-Merge] - anthropics/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index cb210381..e6222438 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,5 +1,5 @@
 {
-  ".": "0.35.0",
-  "packages/vertex-sdk": "0.6.3",
-  "packages/bedrock-sdk": "0.12.2"
+  ".": "0.36.3",
+  "packages/vertex-sdk": "0.6.4",
+  "packages/bedrock-sdk": "0.12.4"
 }
diff --git .stats.yml .stats.yml
index 239e17b7..64f8716d 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 21
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fd67aea6883f1ee9e46f31a42d3940f0acb1749e787055bd9b9f278b20fa53ec.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-f5276eeef7512112e802c85530c51e0a971ee521eebe3a0db309621587b4973d.yml
diff --git CHANGELOG.md CHANGELOG.md
index 499e576c..da99f256 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,52 @@
 # Changelog
 
+## 0.36.3 (2025-01-27)
+
+Full Changelog: [sdk-v0.36.2...sdk-v0.36.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.2...sdk-v0.36.3)
+
+### Bug Fixes
+
+* **streaming:** accumulate citations ([#675](https://github.com/anthropics/anthropic-sdk-typescript/issues/675)) ([522118f](https://github.com/anthropics/anthropic-sdk-typescript/commit/522118ffeab327e8476f12d9b9fa1f19042ed714))
+
+
+### Chores
+
+* **docs:** updates ([#673](https://github.com/anthropics/anthropic-sdk-typescript/issues/673)) ([751ecd0](https://github.com/anthropics/anthropic-sdk-typescript/commit/751ecd0d44707b21ccb390c81716937fae3d8e35))
+
+## 0.36.2 (2025-01-23)
+
+Full Changelog: [sdk-v0.36.1...sdk-v0.36.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.1...sdk-v0.36.2)
+
+### Bug Fixes
+
+* **bedrock:** update streaming util import ([255c059](https://github.com/anthropics/anthropic-sdk-typescript/commit/255c0599e333e6fae582255e3b0631538b168c69))
+
+## 0.36.1 (2025-01-23)
+
+Full Changelog: [sdk-v0.36.0...sdk-v0.36.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.0...sdk-v0.36.1)
+
+### Chores
+
+* **tests:** fix types ([9efe3ee](https://github.com/anthropics/anthropic-sdk-typescript/commit/9efe3eebf64bd762a34caf362a1cd1a0f0858f92))
+
+## 0.36.0 (2025-01-23)
+
+Full Changelog: [sdk-v0.35.0...sdk-v0.36.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.35.0...sdk-v0.36.0)
+
+### Features
+
+* **api:** add citations ([#668](https://github.com/anthropics/anthropic-sdk-typescript/issues/668)) ([1fef177](https://github.com/anthropics/anthropic-sdk-typescript/commit/1fef17749adbbeb243480b96c04941be29c0746c))
+* **client:** support results endpoint ([#666](https://github.com/anthropics/anthropic-sdk-typescript/issues/666)) ([db5fffe](https://github.com/anthropics/anthropic-sdk-typescript/commit/db5fffeb38a99a3e9283ebf001fbf767d756162e))
+* **stream:** expose `response` property as well ([b0235c7](https://github.com/anthropics/anthropic-sdk-typescript/commit/b0235c7b3ac174b3c8e670e381b4aa038e61c826))
+
+
+### Chores
+
+* **bedrock:** bump dependency on @anthropic-ai/sdk ([8745ca2](https://github.com/anthropics/anthropic-sdk-typescript/commit/8745ca2160f5af4d89e5732a44e560c5e2787aa8))
+* **internal:** fix import ([628b55e](https://github.com/anthropics/anthropic-sdk-typescript/commit/628b55ef5ff8f0245287ecaea688480a0174e2e9))
+* **internal:** minor restructuring ([#664](https://github.com/anthropics/anthropic-sdk-typescript/issues/664)) ([57aefa7](https://github.com/anthropics/anthropic-sdk-typescript/commit/57aefa73230d54da24d787a89adc277481986d02))
+* **vertex:** bump dependency on @anthropic-ai/sdk ([a1c7fcd](https://github.com/anthropics/anthropic-sdk-typescript/commit/a1c7fcdce081f860cbb1148c3862e3303ddb8a62))
+
 ## 0.35.0 (2025-01-21)
 
 Full Changelog: [sdk-v0.34.0...sdk-v0.35.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.34.0...sdk-v0.35.0)
diff --git api.md api.md
index 9aed2e92..1a3d66bc 100644
--- api.md
+++ api.md
@@ -22,9 +22,19 @@ Types:
 
 - <code><a href="./src/resources/messages/messages.ts">Base64PDFSource</a></code>
 - <code><a href="./src/resources/messages/messages.ts">CacheControlEphemeral</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationCharLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationCharLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationContentBlockLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationContentBlockLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationPageLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationPageLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationsConfigParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationsDelta</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlock</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">ContentBlockSource</a></code>
+- <code><a href="./src/resources/messages/messages.ts">ContentBlockSourceContent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockStopEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">DocumentBlockParam</a></code>
@@ -40,6 +50,7 @@ Types:
 - <code><a href="./src/resources/messages/messages.ts">MessageTokensCount</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Metadata</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Model</a></code>
+- <code><a href="./src/resources/messages/messages.ts">PlainTextSource</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockStopEvent</a></code>
@@ -49,6 +60,8 @@ Types:
 - <code><a href="./src/resources/messages/messages.ts">RawMessageStreamEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextBlock</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextBlockParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">TextCitation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">TextCitationParam</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextDelta</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Tool</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ToolChoice</a></code>
@@ -87,7 +100,7 @@ Methods:
 - <code title="get /v1/messages/batches">client.messages.batches.<a href="./src/resources/messages/batches.ts">list</a>({ ...params }) -> MessageBatchesPage</code>
 - <code title="delete /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/resources/messages/batches.ts">delete</a>(messageBatchId) -> DeletedMessageBatch</code>
 - <code title="post /v1/messages/batches/{message_batch_id}/cancel">client.messages.batches.<a href="./src/resources/messages/batches.ts">cancel</a>(messageBatchId) -> MessageBatch</code>
-- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
+- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder&lt;MessageBatchIndividualResponse&gt;</code>
 
 # Models
 
@@ -135,8 +148,18 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFSource</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheControlEphemeral</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">BetaCitationContentBlockLocation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationContentBlockLocationParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationPageLocation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationPageLocationParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsConfigParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSource</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSourceContent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaImageBlockParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaInputJSONDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessage</a></code>
@@ -144,6 +167,7 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageTokensCount</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMetadata</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaPlainTextSource</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockStopEvent</a></code>
@@ -153,6 +177,8 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawMessageStreamEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlockParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextCitation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextCitationParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTool</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaToolBash20241022</a></code>
@@ -194,4 +220,4 @@ Methods:
 - <code title="get /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">list</a>({ ...params }) -> BetaMessageBatchesPage</code>
 - <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>
 - <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>
-- <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 }) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
+- <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 }) -> JSONLDecoder&lt;BetaMessageBatchIndividualResponse&gt;</code>
diff --git package.json package.json
index aa23123e..6fb9c0c4 100644
--- package.json
+++ package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/sdk",
-  "version": "0.35.0",
+  "version": "0.36.3",
   "description": "The official TypeScript library for the Anthropic API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/bedrock-sdk/CHANGELOG.md packages/bedrock-sdk/CHANGELOG.md
index 12fec54c..4b46a678 100644
--- packages/bedrock-sdk/CHANGELOG.md
+++ packages/bedrock-sdk/CHANGELOG.md
@@ -1,5 +1,21 @@
 # Changelog
 
+## 0.12.4 (2025-01-23)
+
+Full Changelog: [bedrock-sdk-v0.12.3...bedrock-sdk-v0.12.4](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.3...bedrock-sdk-v0.12.4)
+
+### Bug Fixes
+
+* **bedrock:** update streaming util import ([255c059](https://github.com/anthropics/anthropic-sdk-typescript/commit/255c0599e333e6fae582255e3b0631538b168c69))
+
+## 0.12.3 (2025-01-23)
+
+Full Changelog: [bedrock-sdk-v0.12.2...bedrock-sdk-v0.12.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.2...bedrock-sdk-v0.12.3)
+
+### Chores
+
+* **bedrock:** bump dependency on @anthropic-ai/sdk ([8745ca2](https://github.com/anthropics/anthropic-sdk-typescript/commit/8745ca2160f5af4d89e5732a44e560c5e2787aa8))
+
 ## 0.12.2 (2025-01-21)
 
 Full Changelog: [bedrock-sdk-v0.12.1...bedrock-sdk-v0.12.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.1...bedrock-sdk-v0.12.2)
diff --git packages/bedrock-sdk/package.json packages/bedrock-sdk/package.json
index 8e7a906d..8236a27d 100644
--- packages/bedrock-sdk/package.json
+++ packages/bedrock-sdk/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/bedrock-sdk",
-  "version": "0.12.2",
+  "version": "0.12.4",
   "description": "The official TypeScript library for the Anthropic Bedrock API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
index 12a41324..aeaa36a3 100644
--- packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
+++ packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
@@ -4,8 +4,8 @@ const pkgJson = require('../dist/package.json');
 for (const dep in pkgJson.dependencies) {
   // ensure we point to NPM instead of a local directory
   if (dep === '@anthropic-ai/sdk') {
-    pkgJson.dependencies[dep] = '^0';
+    pkgJson.dependencies[dep] = '>=0.36 <1';
   }
 }
 
-fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
+fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));
diff --git packages/bedrock-sdk/src/streaming.ts packages/bedrock-sdk/src/streaming.ts
index 01f0956b..7a97ee64 100644
--- packages/bedrock-sdk/src/streaming.ts
+++ packages/bedrock-sdk/src/streaming.ts
@@ -2,11 +2,8 @@ import { EventStreamMarshaller } from '@smithy/eventstream-serde-node';
 import { fromBase64, toBase64 } from '@smithy/util-base64';
 import { streamCollector } from '@smithy/fetch-http-handler';
 import { EventStreamSerdeContext, SerdeContext } from '@smithy/types';
-import {
-  Stream as CoreStream,
-  readableStreamAsyncIterable,
-  ServerSentEvent,
-} from '@anthropic-ai/sdk/streaming';
+import { Stream as CoreStream, ServerSentEvent } from '@anthropic-ai/sdk/streaming';
+import { ReadableStreamToAsyncIterable } from '@anthropic-ai/sdk/internal/stream-utils';
 import { AnthropicError } from '@anthropic-ai/sdk/error';
 import { APIError } from '@anthropic-ai/sdk';
 import { createResponseHeaders, safeJSON } from '@anthropic-ai/sdk/core';
@@ -42,7 +39,7 @@ export class Stream<Item> extends CoreStream<Item> {
         throw new AnthropicError(`Attempted to iterate over a response with no body`);
       }
 
-      const responseBodyIter = readableStreamAsyncIterable<Bytes>(response.body);
+      const responseBodyIter = ReadableStreamToAsyncIterable<Bytes>(response.body);
       const eventStream = de_ResponseStream(responseBodyIter, getMinimalSerdeContext());
       for await (const event of eventStream) {
         if (event.chunk && event.chunk.bytes) {
diff --git packages/vertex-sdk/CHANGELOG.md packages/vertex-sdk/CHANGELOG.md
index e01d1d71..9e83b1e8 100644
--- packages/vertex-sdk/CHANGELOG.md
+++ packages/vertex-sdk/CHANGELOG.md
@@ -1,5 +1,13 @@
 # Changelog
 
+## 0.6.4 (2025-01-23)
+
+Full Changelog: [vertex-sdk-v0.6.3...vertex-sdk-v0.6.4](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.3...vertex-sdk-v0.6.4)
+
+### Chores
+
+* **vertex:** bump dependency on @anthropic-ai/sdk ([a1c7fcd](https://github.com/anthropics/anthropic-sdk-typescript/commit/a1c7fcdce081f860cbb1148c3862e3303ddb8a62))
+
 ## 0.6.3 (2025-01-21)
 
 Full Changelog: [vertex-sdk-v0.6.2...vertex-sdk-v0.6.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.2...vertex-sdk-v0.6.3)
diff --git packages/vertex-sdk/package.json packages/vertex-sdk/package.json
index ae4cf6f9..ac5bda51 100644
--- packages/vertex-sdk/package.json
+++ packages/vertex-sdk/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/vertex-sdk",
-  "version": "0.6.3",
+  "version": "0.6.4",
   "description": "The official TypeScript library for the Anthropic Vertex API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
index f8abd4b9..da232fe3 100644
--- packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
+++ packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
@@ -4,8 +4,8 @@ const pkgJson = require('../dist/package.json');
 for (const dep in pkgJson.dependencies) {
   // ensure we point to NPM instead of a local directory
   if (dep === '@anthropic-ai/sdk') {
-    pkgJson.dependencies[dep] = '>=0.14 <1';
+    pkgJson.dependencies[dep] = '>=0.35 <1';
   }
 }
 
-fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
+fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));
diff --git src/index.ts src/index.ts
index 44f6bc2d..0872e7a7 100644
--- src/index.ts
+++ src/index.ts
@@ -33,9 +33,19 @@ import {
 import {
   Base64PDFSource,
   CacheControlEphemeral,
+  CitationCharLocation,
+  CitationCharLocationParam,
+  CitationContentBlockLocation,
+  CitationContentBlockLocationParam,
+  CitationPageLocation,
+  CitationPageLocationParam,
+  CitationsConfigParam,
+  CitationsDelta,
   ContentBlock,
   ContentBlockDeltaEvent,
   ContentBlockParam,
+  ContentBlockSource,
+  ContentBlockSourceContent,
   ContentBlockStartEvent,
   ContentBlockStopEvent,
   DocumentBlockParam,
@@ -57,6 +67,7 @@ import {
   Messages,
   Metadata,
   Model,
+  PlainTextSource,
   RawContentBlockDeltaEvent,
   RawContentBlockStartEvent,
   RawContentBlockStopEvent,
@@ -66,6 +77,8 @@ import {
   RawMessageStreamEvent,
   TextBlock,
   TextBlockParam,
+  TextCitation,
+  TextCitationParam,
   TextDelta,
   Tool,
   ToolChoice,
@@ -322,9 +335,19 @@ export declare namespace Anthropic {
     Messages as Messages,
     type Base64PDFSource as Base64PDFSource,
     type CacheControlEphemeral as CacheControlEphemeral,
+    type CitationCharLocation as CitationCharLocation,
+    type CitationCharLocationParam as CitationCharLocationParam,
+    type CitationContentBlockLocation as CitationContentBlockLocation,
+    type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
+    type CitationPageLocation as CitationPageLocation,
+    type CitationPageLocationParam as CitationPageLocationParam,
+    type CitationsConfigParam as CitationsConfigParam,
+    type CitationsDelta as CitationsDelta,
     type ContentBlock as ContentBlock,
     type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
     type ContentBlockParam as ContentBlockParam,
+    type ContentBlockSource as ContentBlockSource,
+    type ContentBlockSourceContent as ContentBlockSourceContent,
     type ContentBlockStartEvent as ContentBlockStartEvent,
     type ContentBlockStopEvent as ContentBlockStopEvent,
     type DocumentBlockParam as DocumentBlockParam,
@@ -340,6 +363,7 @@ export declare namespace Anthropic {
     type MessageTokensCount as MessageTokensCount,
     type Metadata as Metadata,
     type Model as Model,
+    type PlainTextSource as PlainTextSource,
     type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
     type RawContentBlockStartEvent as RawContentBlockStartEvent,
     type RawContentBlockStopEvent as RawContentBlockStopEvent,
@@ -349,6 +373,8 @@ export declare namespace Anthropic {
     type RawMessageStreamEvent as RawMessageStreamEvent,
     type TextBlock as TextBlock,
     type TextBlockParam as TextBlockParam,
+    type TextCitation as TextCitation,
+    type TextCitationParam as TextCitationParam,
     type TextDelta as TextDelta,
     type Tool as Tool,
     type ToolChoice as ToolChoice,
diff --git src/internal/decoders/jsonl.ts src/internal/decoders/jsonl.ts
index 8d3693d8..15751255 100644
--- src/internal/decoders/jsonl.ts
+++ src/internal/decoders/jsonl.ts
@@ -1,5 +1,5 @@
 import { AnthropicError } from '../../error';
-import { readableStreamAsyncIterable } from '../../streaming';
+import { ReadableStreamToAsyncIterable } from '../stream-utils';
 import { type Response } from '../../_shims/index';
 import { LineDecoder, type Bytes } from './line';
 
@@ -36,6 +36,6 @@ export class JSONLDecoder<T> {
       throw new AnthropicError(`Attempted to iterate over a response with no body`);
     }
 
-    return new JSONLDecoder(readableStreamAsyncIterable<Bytes>(response.body), controller);
+    return new JSONLDecoder(ReadableStreamToAsyncIterable<Bytes>(response.body), controller);
   }
 }
diff --git a/src/internal/stream-utils.ts b/src/internal/stream-utils.ts
new file mode 100644
index 00000000..37f7793c
--- /dev/null
+++ src/internal/stream-utils.ts
@@ -0,0 +1,32 @@
+/**
+ * Most browsers don't yet have async iterable support for ReadableStream,
+ * and Node has a very different way of reading bytes from its "ReadableStream".
+ *
+ * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
+ */
+export function ReadableStreamToAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
+  if (stream[Symbol.asyncIterator]) return stream;
+
+  const reader = stream.getReader();
+  return {
+    async next() {
+      try {
+        const result = await reader.read();
+        if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
+        return result;
+      } catch (e) {
+        reader.releaseLock(); // release lock when stream becomes errored
+        throw e;
+      }
+    },
+    async return() {
+      const cancelPromise = reader.cancel();
+      reader.releaseLock();
+      await cancelPromise;
+      return { done: true, value: undefined };
+    },
+    [Symbol.asyncIterator]() {
+      return this;
+    },
+  };
+}
diff --git src/lib/BetaMessageStream.ts src/lib/BetaMessageStream.ts
index 06fbc46a..5de54f06 100644
--- src/lib/BetaMessageStream.ts
+++ src/lib/BetaMessageStream.ts
@@ -9,6 +9,7 @@ import {
   type MessageCreateParams as BetaMessageCreateParams,
   type MessageCreateParamsBase as BetaMessageCreateParamsBase,
   type BetaTextBlock,
+  type BetaTextCitation,
 } from '@anthropic-ai/sdk/resources/beta/messages/messages';
 import { type ReadableStream, type Response } from '@anthropic-ai/sdk/_shims/index';
 import { Stream } from '@anthropic-ai/sdk/streaming';
@@ -18,6 +19,7 @@ export interface MessageStreamEvents {
   connect: () => void;
   streamEvent: (event: BetaMessageStreamEvent, snapshot: BetaMessage) => void;
   text: (textDelta: string, textSnapshot: string) => void;
+  citation: (citation: BetaTextCitation, citationsSnapshot: BetaTextCitation[]) => void;
   inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
   message: (message: BetaMessage) => void;
   contentBlock: (content: BetaContentBlock) => void;
@@ -55,6 +57,7 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
   #errored = false;
   #aborted = false;
   #catchingPromiseCreated = false;
+  #response: Response | null | undefined;
   #request_id: string | null | undefined;
 
   constructor() {
@@ -76,6 +79,10 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     this.#endPromise.catch(() => {});
   }
 
+  get response(): Response | null | undefined {
+    return this.#response;
+  }
+
   get request_id(): string | null | undefined {
     return this.#request_id;
   }
@@ -183,6 +190,7 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
 
   protected _connected(response: Response | null) {
     if (this.ended) return;
+    this.#response = response;
     this.#request_id = response?.headers.get('request-id');
     this.#resolveConnectedPromise(response);
     this._emit('connect');
@@ -407,12 +415,27 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     switch (event.type) {
       case 'content_block_delta': {
         const content = messageSnapshot.content.at(-1)!;
-        if (event.delta.type === 'text_delta' && content.type === 'text') {
-          this._emit('text', event.delta.text, content.text || '');
-        } else if (event.delta.type === 'input_json_delta' && content.type === 'tool_use') {
-          if (content.input) {
-            this._emit('inputJson', event.delta.partial_json, content.input);
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (content.type === 'text') {
+              this._emit('text', event.delta.text, content.text || '');
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (content.type === 'text') {
+              this._emit('citation', event.delta.citation, content.citations ?? []);
+            }
+            break;
+          }
+          case 'input_json_delta': {
+            if (content.type === 'tool_use' && content.input) {
+              this._emit('inputJson', event.delta.partial_json, content.input);
+            }
+            break;
           }
+          default:
+            checkNever(event.delta);
         }
         break;
       }
@@ -499,24 +522,43 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
         return snapshot;
       case 'content_block_delta': {
         const snapshotContent = snapshot.content.at(event.index);
-        if (snapshotContent?.type === 'text' && event.delta.type === 'text_delta') {
-          snapshotContent.text += event.delta.text;
-        } else if (snapshotContent?.type === 'tool_use' && event.delta.type === 'input_json_delta') {
-          // we need to keep track of the raw JSON string as well so that we can
-          // re-parse it for each delta, for now we just store it as an untyped
-          // non-enumerable property on the snapshot
-          let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
-          jsonBuf += event.delta.partial_json;
-
-          Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
-            value: jsonBuf,
-            enumerable: false,
-            writable: true,
-          });
-
-          if (jsonBuf) {
-            snapshotContent.input = partialParse(jsonBuf);
+
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.text += event.delta.text;
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.citations ??= [];
+              snapshotContent.citations.push(event.delta.citation);
+            }
+            break;
           }
+          case 'input_json_delta': {
+            if (snapshotContent?.type === 'tool_use') {
+              // we need to keep track of the raw JSON string as well so that we can
+              // re-parse it for each delta, for now we just store it as an untyped
+              // non-enumerable property on the snapshot
+              let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
+              jsonBuf += event.delta.partial_json;
+
+              Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
+                value: jsonBuf,
+                enumerable: false,
+                writable: true,
+              });
+
+              if (jsonBuf) {
+                snapshotContent.input = partialParse(jsonBuf);
+              }
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
         return snapshot;
       }
@@ -591,3 +633,6 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     return stream.toReadableStream();
   }
 }
+
+// used to ensure exhaustive case matching without throwing a runtime error
+function checkNever(x: never) {}
diff --git src/lib/MessageStream.ts src/lib/MessageStream.ts
index 65e84b29..4ce3a382 100644
--- src/lib/MessageStream.ts
+++ src/lib/MessageStream.ts
@@ -9,6 +9,7 @@ import {
   type MessageCreateParams,
   type MessageCreateParamsBase,
   type TextBlock,
+  type TextCitation,
 } from '@anthropic-ai/sdk/resources/messages';
 import { type ReadableStream, type Response } from '@anthropic-ai/sdk/_shims/index';
 import { Stream } from '@anthropic-ai/sdk/streaming';
@@ -18,6 +19,7 @@ export interface MessageStreamEvents {
   connect: () => void;
   streamEvent: (event: MessageStreamEvent, snapshot: Message) => void;
   text: (textDelta: string, textSnapshot: string) => void;
+  citation: (citation: TextCitation, citationsSnapshot: TextCitation[]) => void;
   inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
   message: (message: Message) => void;
   contentBlock: (content: ContentBlock) => void;
@@ -55,6 +57,7 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
   #errored = false;
   #aborted = false;
   #catchingPromiseCreated = false;
+  #response: Response | null | undefined;
   #request_id: string | null | undefined;
 
   constructor() {
@@ -76,6 +79,10 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     this.#endPromise.catch(() => {});
   }
 
+  get response(): Response | null | undefined {
+    return this.#response;
+  }
+
   get request_id(): string | null | undefined {
     return this.#request_id;
   }
@@ -183,6 +190,7 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
 
   protected _connected(response: Response | null) {
     if (this.ended) return;
+    this.#response = response;
     this.#request_id = response?.headers.get('request-id');
     this.#resolveConnectedPromise(response);
     this._emit('connect');
@@ -407,12 +415,27 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     switch (event.type) {
       case 'content_block_delta': {
         const content = messageSnapshot.content.at(-1)!;
-        if (event.delta.type === 'text_delta' && content.type === 'text') {
-          this._emit('text', event.delta.text, content.text || '');
-        } else if (event.delta.type === 'input_json_delta' && content.type === 'tool_use') {
-          if (content.input) {
-            this._emit('inputJson', event.delta.partial_json, content.input);
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (content.type === 'text') {
+              this._emit('text', event.delta.text, content.text || '');
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (content.type === 'text') {
+              this._emit('citation', event.delta.citation, content.citations ?? []);
+            }
+            break;
           }
+          case 'input_json_delta': {
+            if (content.type === 'tool_use' && content.input) {
+              this._emit('inputJson', event.delta.partial_json, content.input);
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
         break;
       }
@@ -499,25 +522,45 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
         return snapshot;
       case 'content_block_delta': {
         const snapshotContent = snapshot.content.at(event.index);
-        if (snapshotContent?.type === 'text' && event.delta.type === 'text_delta') {
-          snapshotContent.text += event.delta.text;
-        } else if (snapshotContent?.type === 'tool_use' && event.delta.type === 'input_json_delta') {
-          // we need to keep track of the raw JSON string as well so that we can
-          // re-parse it for each delta, for now we just store it as an untyped
-          // non-enumerable property on the snapshot
-          let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
-          jsonBuf += event.delta.partial_json;
-
-          Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
-            value: jsonBuf,
-            enumerable: false,
-            writable: true,
-          });
-
-          if (jsonBuf) {
-            snapshotContent.input = partialParse(jsonBuf);
+
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.text += event.delta.text;
+            }
+            break;
           }
+          case 'citations_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.citations ??= [];
+              snapshotContent.citations.push(event.delta.citation);
+            }
+            break;
+          }
+          case 'input_json_delta': {
+            if (snapshotContent?.type === 'tool_use') {
+              // we need to keep track of the raw JSON string as well so that we can
+              // re-parse it for each delta, for now we just store it as an untyped
+              // non-enumerable property on the snapshot
+              let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
+              jsonBuf += event.delta.partial_json;
+
+              Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
+                value: jsonBuf,
+                enumerable: false,
+                writable: true,
+              });
+
+              if (jsonBuf) {
+                snapshotContent.input = partialParse(jsonBuf);
+              }
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
+
         return snapshot;
       }
       case 'content_block_stop':
@@ -591,3 +634,6 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     return stream.toReadableStream();
   }
 }
+
+// used to ensure exhaustive case matching without throwing a runtime error
+function checkNever(x: never) {}
diff --git src/resources/beta/beta.ts src/resources/beta/beta.ts
index e29a187c..a1f3f0d4 100644
--- src/resources/beta/beta.ts
+++ src/resources/beta/beta.ts
@@ -8,8 +8,18 @@ import {
   BetaBase64PDFBlock,
   BetaBase64PDFSource,
   BetaCacheControlEphemeral,
+  BetaCitationCharLocation,
+  BetaCitationCharLocationParam,
+  BetaCitationContentBlockLocation,
+  BetaCitationContentBlockLocationParam,
+  BetaCitationPageLocation,
+  BetaCitationPageLocationParam,
+  BetaCitationsConfigParam,
+  BetaCitationsDelta,
   BetaContentBlock,
   BetaContentBlockParam,
+  BetaContentBlockSource,
+  BetaContentBlockSourceContent,
   BetaImageBlockParam,
   BetaInputJSONDelta,
   BetaMessage,
@@ -17,6 +27,7 @@ import {
   BetaMessageParam,
   BetaMessageTokensCount,
   BetaMetadata,
+  BetaPlainTextSource,
   BetaRawContentBlockDeltaEvent,
   BetaRawContentBlockStartEvent,
   BetaRawContentBlockStopEvent,
@@ -26,6 +37,8 @@ import {
   BetaRawMessageStreamEvent,
   BetaTextBlock,
   BetaTextBlockParam,
+  BetaTextCitation,
+  BetaTextCitationParam,
   BetaTextDelta,
   BetaTool,
   BetaToolBash20241022,
@@ -163,8 +176,18 @@ export declare namespace Beta {
     type BetaBase64PDFBlock as BetaBase64PDFBlock,
     type BetaBase64PDFSource as BetaBase64PDFSource,
     type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
+    type BetaCitationCharLocation as BetaCitationCharLocation,
+    type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
+    type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
+    type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
+    type BetaCitationPageLocation as BetaCitationPageLocation,
+    type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
+    type BetaCitationsConfigParam as BetaCitationsConfigParam,
+    type BetaCitationsDelta as BetaCitationsDelta,
     type BetaContentBlock as BetaContentBlock,
     type BetaContentBlockParam as BetaContentBlockParam,
+    type BetaContentBlockSource as BetaContentBlockSource,
+    type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
     type BetaImageBlockParam as BetaImageBlockParam,
     type BetaInputJSONDelta as BetaInputJSONDelta,
     type BetaMessage as BetaMessage,
@@ -172,6 +195,7 @@ export declare namespace Beta {
     type BetaMessageParam as BetaMessageParam,
     type BetaMessageTokensCount as BetaMessageTokensCount,
     type BetaMetadata as BetaMetadata,
+    type BetaPlainTextSource as BetaPlainTextSource,
     type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
     type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
     type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
@@ -181,6 +205,8 @@ export declare namespace Beta {
     type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
     type BetaTextBlock as BetaTextBlock,
     type BetaTextBlockParam as BetaTextBlockParam,
+    type BetaTextCitation as BetaTextCitation,
+    type BetaTextCitationParam as BetaTextCitationParam,
     type BetaTextDelta as BetaTextDelta,
     type BetaTool as BetaTool,
     type BetaToolBash20241022 as BetaToolBash20241022,
diff --git src/resources/beta/index.ts src/resources/beta/index.ts
index a68f2327..743f9c42 100644
--- src/resources/beta/index.ts
+++ src/resources/beta/index.ts
@@ -21,8 +21,18 @@ export {
   type BetaBase64PDFBlock,
   type BetaBase64PDFSource,
   type BetaCacheControlEphemeral,
+  type BetaCitationCharLocation,
+  type BetaCitationCharLocationParam,
+  type BetaCitationContentBlockLocation,
+  type BetaCitationContentBlockLocationParam,
+  type BetaCitationPageLocation,
+  type BetaCitationPageLocationParam,
+  type BetaCitationsConfigParam,
+  type BetaCitationsDelta,
   type BetaContentBlock,
   type BetaContentBlockParam,
+  type BetaContentBlockSource,
+  type BetaContentBlockSourceContent,
   type BetaImageBlockParam,
   type BetaInputJSONDelta,
   type BetaMessage,
@@ -30,6 +40,7 @@ export {
   type BetaMessageParam,
   type BetaMessageTokensCount,
   type BetaMetadata,
+  type BetaPlainTextSource,
   type BetaRawContentBlockDeltaEvent,
   type BetaRawContentBlockStartEvent,
   type BetaRawContentBlockStopEvent,
@@ -39,6 +50,8 @@ export {
   type BetaRawMessageStreamEvent,
   type BetaTextBlock,
   type BetaTextBlockParam,
+  type BetaTextCitation,
+  type BetaTextCitationParam,
   type BetaTextDelta,
   type BetaTool,
   type BetaToolBash20241022,
diff --git src/resources/beta/messages/batches.ts src/resources/beta/messages/batches.ts
index 74f4e53b..6370119c 100644
--- src/resources/beta/messages/batches.ts
+++ src/resources/beta/messages/batches.ts
@@ -86,9 +86,10 @@ export class Batches extends APIResource {
   }
 
   /**
-   * This endpoint is idempotent and can be used to poll for Message Batch
-   * completion. To access the results of a Message Batch, make a request to the
-   * `results_url` field in the response.
+   * Delete a Message Batch.
+   *
+   * Message Batches can only be deleted once they've finished processing. If you'd
+   * like to delete an in-progress batch, you must first cancel it.
    */
   delete(
     messageBatchId: string,
@@ -298,6 +299,10 @@ export interface BetaMessageBatchExpiredResult {
   type: 'expired';
 }
 
+/**
+ * This is a single line in the response `.jsonl` file and does not represent the
+ * response as a whole.
+ */
 export interface BetaMessageBatchIndividualResponse {
   /**
    * Developer-provided ID created for each request in a Message Batch. Useful for
diff --git src/resources/beta/messages/index.ts src/resources/beta/messages/index.ts
index eac5d34f..51a0f935 100644
--- src/resources/beta/messages/index.ts
+++ src/resources/beta/messages/index.ts
@@ -24,8 +24,18 @@ export {
   type BetaBase64PDFBlock,
   type BetaBase64PDFSource,
   type BetaCacheControlEphemeral,
+  type BetaCitationCharLocation,
+  type BetaCitationCharLocationParam,
+  type BetaCitationContentBlockLocation,
+  type BetaCitationContentBlockLocationParam,
+  type BetaCitationPageLocation,
+  type BetaCitationPageLocationParam,
+  type BetaCitationsConfigParam,
+  type BetaCitationsDelta,
   type BetaContentBlock,
   type BetaContentBlockParam,
+  type BetaContentBlockSource,
+  type BetaContentBlockSourceContent,
   type BetaImageBlockParam,
   type BetaInputJSONDelta,
   type BetaMessage,
@@ -33,6 +43,7 @@ export {
   type BetaMessageParam,
   type BetaMessageTokensCount,
   type BetaMetadata,
+  type BetaPlainTextSource,
   type BetaRawContentBlockDeltaEvent,
   type BetaRawContentBlockStartEvent,
   type BetaRawContentBlockStopEvent,
@@ -42,6 +53,8 @@ export {
   type BetaRawMessageStreamEvent,
   type BetaTextBlock,
   type BetaTextBlockParam,
+  type BetaTextCitation,
+  type BetaTextCitationParam,
   type BetaTextDelta,
   type BetaTool,
   type BetaToolBash20241022,
diff --git src/resources/beta/messages/messages.ts src/resources/beta/messages/messages.ts
index ecb1d79f..3b35717a 100644
--- src/resources/beta/messages/messages.ts
+++ src/resources/beta/messages/messages.ts
@@ -120,11 +120,17 @@ export class Messages extends APIResource {
 export type BetaMessageStreamParams = MessageCreateParamsBase;
 
 export interface BetaBase64PDFBlock {
-  source: BetaBase64PDFSource;
+  source: BetaBase64PDFSource | BetaPlainTextSource | BetaContentBlockSource;
 
   type: 'document';
 
   cache_control?: BetaCacheControlEphemeral | null;
+
+  citations?: BetaCitationsConfigParam;
+
+  context?: string | null;
+
+  title?: string | null;
 }
 
 export interface BetaBase64PDFSource {
@@ -139,6 +145,100 @@ export interface BetaCacheControlEphemeral {
   type: 'ephemeral';
 }
 
+export interface BetaCitationCharLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface BetaCitationCharLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface BetaCitationContentBlockLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface BetaCitationContentBlockLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface BetaCitationPageLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface BetaCitationPageLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface BetaCitationsConfigParam {
+  enabled?: boolean;
+}
+
+export interface BetaCitationsDelta {
+  citation: BetaCitationCharLocation | BetaCitationPageLocation | BetaCitationContentBlockLocation;
+
+  type: 'citations_delta';
+}
+
 export type BetaContentBlock = BetaTextBlock | BetaToolUseBlock;
 
 export type BetaContentBlockParam =
@@ -148,6 +248,14 @@ export type BetaContentBlockParam =
   | BetaToolResultBlockParam
   | BetaBase64PDFBlock;
 
+export interface BetaContentBlockSource {
+  content: string | Array<BetaContentBlockSourceContent>;
+
+  type: 'content';
+}
+
+export type BetaContentBlockSourceContent = BetaTextBlockParam | BetaImageBlockParam;
+
 export interface BetaImageBlockParam {
   source: BetaImageBlockParam.Source;
 
@@ -309,8 +417,16 @@ export interface BetaMetadata {
   user_id?: string | null;
 }
 
+export interface BetaPlainTextSource {
+  data: string;
+
+  media_type: 'text/plain';
+
+  type: 'text';
+}
+
 export interface BetaRawContentBlockDeltaEvent {
-  delta: BetaTextDelta | BetaInputJSONDelta;
+  delta: BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta;
 
   index: number;
 
@@ -380,6 +496,15 @@ export type BetaRawMessageStreamEvent =
   | BetaRawContentBlockStopEvent;
 
 export interface BetaTextBlock {
+  /**
+   * Citations supporting the text block.
+   *
+   * The type of citation returned will depend on the type of document being cited.
+   * Citing a PDF results in `page_location`, plain text results in `char_location`,
+   * and content document results in `content_block_location`.
+   */
+  citations: Array<BetaTextCitation> | null;
+
   text: string;
 
   type: 'text';
@@ -391,8 +516,20 @@ export interface BetaTextBlockParam {
   type: 'text';
 
   cache_control?: BetaCacheControlEphemeral | null;
+
+  citations?: Array<BetaTextCitationParam> | null;
 }
 
+export type BetaTextCitation =
+  | BetaCitationCharLocation
+  | BetaCitationPageLocation
+  | BetaCitationContentBlockLocation;
+
+export type BetaTextCitationParam =
+  | BetaCitationCharLocationParam
+  | BetaCitationPageLocationParam
+  | BetaCitationContentBlockLocationParam;
+
 export interface BetaTextDelta {
   text: string;
 
@@ -1110,8 +1247,18 @@ export declare namespace Messages {
     type BetaBase64PDFBlock as BetaBase64PDFBlock,
     type BetaBase64PDFSource as BetaBase64PDFSource,
     type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
+    type BetaCitationCharLocation as BetaCitationCharLocation,
+    type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
+    type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
+    type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
+    type BetaCitationPageLocation as BetaCitationPageLocation,
+    type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
+    type BetaCitationsConfigParam as BetaCitationsConfigParam,
+    type BetaCitationsDelta as BetaCitationsDelta,
     type BetaContentBlock as BetaContentBlock,
     type BetaContentBlockParam as BetaContentBlockParam,
+    type BetaContentBlockSource as BetaContentBlockSource,
+    type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
     type BetaImageBlockParam as BetaImageBlockParam,
     type BetaInputJSONDelta as BetaInputJSONDelta,
     type BetaMessage as BetaMessage,
@@ -1119,6 +1266,7 @@ export declare namespace Messages {
     type BetaMessageParam as BetaMessageParam,
     type BetaMessageTokensCount as BetaMessageTokensCount,
     type BetaMetadata as BetaMetadata,
+    type BetaPlainTextSource as BetaPlainTextSource,
     type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
     type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
     type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
@@ -1128,6 +1276,8 @@ export declare namespace Messages {
     type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
     type BetaTextBlock as BetaTextBlock,
     type BetaTextBlockParam as BetaTextBlockParam,
+    type BetaTextCitation as BetaTextCitation,
+    type BetaTextCitationParam as BetaTextCitationParam,
     type BetaTextDelta as BetaTextDelta,
     type BetaTool as BetaTool,
     type BetaToolBash20241022 as BetaToolBash20241022,
diff --git src/resources/index.ts src/resources/index.ts
index 23366973..3d4b385a 100644
--- src/resources/index.ts
+++ src/resources/index.ts
@@ -27,9 +27,19 @@ export {
   Messages,
   type Base64PDFSource,
   type CacheControlEphemeral,
+  type CitationCharLocation,
+  type CitationCharLocationParam,
+  type CitationContentBlockLocation,
+  type CitationContentBlockLocationParam,
+  type CitationPageLocation,
+  type CitationPageLocationParam,
+  type CitationsConfigParam,
+  type CitationsDelta,
   type ContentBlock,
   type ContentBlockDeltaEvent,
   type ContentBlockParam,
+  type ContentBlockSource,
+  type ContentBlockSourceContent,
   type ContentBlockStartEvent,
   type ContentBlockStopEvent,
   type DocumentBlockParam,
@@ -47,6 +57,7 @@ export {
   type MessageTokensCount,
   type Metadata,
   type Model,
+  type PlainTextSource,
   type RawContentBlockDeltaEvent,
   type RawContentBlockStartEvent,
   type RawContentBlockStopEvent,
@@ -56,6 +67,8 @@ export {
   type RawMessageStreamEvent,
   type TextBlock,
   type TextBlockParam,
+  type TextCitation,
+  type TextCitationParam,
   type TextDelta,
   type Tool,
   type ToolChoice,
diff --git src/resources/messages/batches.ts src/resources/messages/batches.ts
index a6b328e2..46bc64ed 100644
--- src/resources/messages/batches.ts
+++ src/resources/messages/batches.ts
@@ -50,9 +50,10 @@ export class Batches extends APIResource {
   }
 
   /**
-   * This endpoint is idempotent and can be used to poll for Message Batch
-   * completion. To access the results of a Message Batch, make a request to the
-   * `results_url` field in the response.
+   * Delete a Message Batch.
+   *
+   * Message Batches can only be deleted once they've finished processing. If you'd
+   * like to delete an in-progress batch, you must first cancel it.
    */
   delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<DeletedMessageBatch> {
     return this._client.delete(`/v1/messages/batches/${messageBatchId}`, options);
@@ -206,6 +207,10 @@ export interface MessageBatchExpiredResult {
   type: 'expired';
 }
 
+/**
+ * This is a single line in the response `.jsonl` file and does not represent the
+ * response as a whole.
+ */
 export interface MessageBatchIndividualResponse {
   /**
    * Developer-provided ID created for each request in a Message Batch. Useful for
diff --git src/resources/messages/index.ts src/resources/messages/index.ts
index 1c9178ad..2f7a0a7f 100644
--- src/resources/messages/index.ts
+++ src/resources/messages/index.ts
@@ -19,9 +19,19 @@ export {
   Messages,
   type Base64PDFSource,
   type CacheControlEphemeral,
+  type CitationCharLocation,
+  type CitationCharLocationParam,
+  type CitationContentBlockLocation,
+  type CitationContentBlockLocationParam,
+  type CitationPageLocation,
+  type CitationPageLocationParam,
+  type CitationsConfigParam,
+  type CitationsDelta,
   type ContentBlock,
   type ContentBlockDeltaEvent,
   type ContentBlockParam,
+  type ContentBlockSource,
+  type ContentBlockSourceContent,
   type ContentBlockStartEvent,
   type ContentBlockStopEvent,
   type DocumentBlockParam,
@@ -37,6 +47,7 @@ export {
   type MessageTokensCount,
   type Metadata,
   type Model,
+  type PlainTextSource,
   type RawContentBlockDeltaEvent,
   type RawContentBlockStartEvent,
   type RawContentBlockStopEvent,
@@ -46,6 +57,8 @@ export {
   type RawMessageStreamEvent,
   type TextBlock,
   type TextBlockParam,
+  type TextCitation,
+  type TextCitationParam,
   type TextDelta,
   type Tool,
   type ToolChoice,
diff --git src/resources/messages/messages.ts src/resources/messages/messages.ts
index 12cc9b83..f1b4fb8e 100644
--- src/resources/messages/messages.ts
+++ src/resources/messages/messages.ts
@@ -96,6 +96,100 @@ export interface CacheControlEphemeral {
   type: 'ephemeral';
 }
 
+export interface CitationCharLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface CitationCharLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface CitationContentBlockLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface CitationContentBlockLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface CitationPageLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface CitationPageLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface CitationsConfigParam {
+  enabled?: boolean;
+}
+
+export interface CitationsDelta {
+  citation: CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
+
+  type: 'citations_delta';
+}
+
 export type ContentBlock = TextBlock | ToolUseBlock;
 
 export type ContentBlockDeltaEvent = RawContentBlockDeltaEvent;
@@ -107,16 +201,30 @@ export type ContentBlockParam =
   | ToolResultBlockParam
   | DocumentBlockParam;
 
+export interface ContentBlockSource {
+  content: string | Array<ContentBlockSourceContent>;
+
+  type: 'content';
+}
+
+export type ContentBlockSourceContent = TextBlockParam | ImageBlockParam;
+
 export type ContentBlockStartEvent = RawContentBlockStartEvent;
 
 export type ContentBlockStopEvent = RawContentBlockStopEvent;
 
 export interface DocumentBlockParam {
-  source: Base64PDFSource;
+  source: Base64PDFSource | PlainTextSource | ContentBlockSource;
 
   type: 'document';
 
   cache_control?: CacheControlEphemeral | null;
+
+  citations?: CitationsConfigParam;
+
+  context?: string | null;
+
+  title?: string | null;
 }
 
 export interface ImageBlockParam {
@@ -322,8 +430,16 @@ const DEPRECATED_MODELS: {
   'claude-2.0': 'July 21st, 2025',
 };
 
+export interface PlainTextSource {
+  data: string;
+
+  media_type: 'text/plain';
+
+  type: 'text';
+}
+
 export interface RawContentBlockDeltaEvent {
-  delta: TextDelta | InputJSONDelta;
+  delta: TextDelta | InputJSONDelta | CitationsDelta;
 
   index: number;
 
@@ -393,6 +509,15 @@ export type RawMessageStreamEvent =
   | RawContentBlockStopEvent;
 
 export interface TextBlock {
+  /**
+   * Citations supporting the text block.
+   *
+   * The type of citation returned will depend on the type of document being cited.
+   * Citing a PDF results in `page_location`, plain text results in `char_location`,
+   * and content document results in `content_block_location`.
+   */
+  citations: Array<TextCitation> | null;
+
   text: string;
 
   type: 'text';
@@ -404,8 +529,17 @@ export interface TextBlockParam {
   type: 'text';
 
   cache_control?: CacheControlEphemeral | null;
+
+  citations?: Array<TextCitationParam> | null;
 }
 
+export type TextCitation = CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
+
+export type TextCitationParam =
+  | CitationCharLocationParam
+  | CitationPageLocationParam
+  | CitationContentBlockLocationParam;
+
 export interface TextDelta {
   text: string;
 
@@ -1069,9 +1203,19 @@ export declare namespace Messages {
   export {
     type Base64PDFSource as Base64PDFSource,
     type CacheControlEphemeral as CacheControlEphemeral,
+    type CitationCharLocation as CitationCharLocation,
+    type CitationCharLocationParam as CitationCharLocationParam,
+    type CitationContentBlockLocation as CitationContentBlockLocation,
+    type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
+    type CitationPageLocation as CitationPageLocation,
+    type CitationPageLocationParam as CitationPageLocationParam,
+    type CitationsConfigParam as CitationsConfigParam,
+    type CitationsDelta as CitationsDelta,
     type ContentBlock as ContentBlock,
     type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
     type ContentBlockParam as ContentBlockParam,
+    type ContentBlockSource as ContentBlockSource,
+    type ContentBlockSourceContent as ContentBlockSourceContent,
     type ContentBlockStartEvent as ContentBlockStartEvent,
     type ContentBlockStopEvent as ContentBlockStopEvent,
     type DocumentBlockParam as DocumentBlockParam,
@@ -1088,6 +1232,7 @@ export declare namespace Messages {
     type MessageTokensCount as MessageTokensCount,
     type Metadata as Metadata,
     type Model as Model,
+    type PlainTextSource as PlainTextSource,
     type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
     type RawContentBlockStartEvent as RawContentBlockStartEvent,
     type RawContentBlockStopEvent as RawContentBlockStopEvent,
@@ -1097,6 +1242,8 @@ export declare namespace Messages {
     type RawMessageStreamEvent as RawMessageStreamEvent,
     type TextBlock as TextBlock,
     type TextBlockParam as TextBlockParam,
+    type TextCitation as TextCitation,
+    type TextCitationParam as TextCitationParam,
     type TextDelta as TextDelta,
     type Tool as Tool,
     type ToolChoice as ToolChoice,
diff --git src/streaming.ts src/streaming.ts
index 2eff6ef9..ad1b78e6 100644
--- src/streaming.ts
+++ src/streaming.ts
@@ -1,6 +1,7 @@
 import { ReadableStream, type Response } from './_shims/index';
 import { AnthropicError } from './error';
 import { LineDecoder } from './internal/decoders/line';
+import { ReadableStreamToAsyncIterable } from './internal/stream-utils';
 
 import { createResponseHeaders } from './core';
 import { APIError } from './error';
@@ -98,7 +99,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
     async function* iterLines(): AsyncGenerator<string, void, unknown> {
       const lineDecoder = new LineDecoder();
 
-      const iter = readableStreamAsyncIterable<Bytes>(readableStream);
+      const iter = ReadableStreamToAsyncIterable<Bytes>(readableStream);
       for await (const chunk of iter) {
         for (const line of lineDecoder.decode(chunk)) {
           yield line;
@@ -212,7 +213,7 @@ export async function* _iterSSEMessages(
   const sseDecoder = new SSEDecoder();
   const lineDecoder = new LineDecoder();
 
-  const iter = readableStreamAsyncIterable<Bytes>(response.body);
+  const iter = ReadableStreamToAsyncIterable<Bytes>(response.body);
   for await (const sseChunk of iterSSEChunks(iter)) {
     for (const line of lineDecoder.decode(sseChunk)) {
       const sse = sseDecoder.decode(line);
@@ -365,36 +366,3 @@ function partition(str: string, delimiter: string): [string, string, string] {
 
   return [str, '', ''];
 }
-
-/**
- * Most browsers don't yet have async iterable support for ReadableStream,
- * and Node has a very different way of reading bytes from its "ReadableStream".
- *
- * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
- */
-export function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
-  if (stream[Symbol.asyncIterator]) return stream;
-
-  const reader = stream.getReader();
-  return {
-    async next() {
-      try {
-        const result = await reader.read();
-        if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
-        return result;
-      } catch (e) {
-        reader.releaseLock(); // release lock when stream becomes errored
-        throw e;
-      }
-    },
-    async return() {
-      const cancelPromise = reader.cancel();
-      reader.releaseLock();
-      await cancelPromise;
-      return { done: true, value: undefined };
-    },
-    [Symbol.asyncIterator]() {
-      return this;
-    },
-  };
-}
diff --git src/version.ts src/version.ts
index 3f1d4329..0d285762 100644
--- src/version.ts
+++ src/version.ts
@@ -1 +1 @@
-export const VERSION = '0.35.0'; // x-release-please-version
+export const VERSION = '0.36.3'; // x-release-please-version
diff --git tests/api-resources/MessageStream.test.ts tests/api-resources/MessageStream.test.ts
index 0051d397..21407524 100644
--- tests/api-resources/MessageStream.test.ts
+++ tests/api-resources/MessageStream.test.ts
@@ -22,7 +22,7 @@ async function* messageIterable(message: Message): AsyncGenerator<MessageStreamE
     yield {
       type: 'content_block_start',
       content_block:
-        content.type === 'text' ? { type: 'text', text: '' }
+        content.type === 'text' ? { type: 'text', text: '', citations: null }
         : content.type === 'tool_use' ?
           {
             type: 'tool_use',
@@ -145,7 +145,7 @@ describe('MessageStream class', () => {
         type: 'message',
         id: 'msg_01hhptzfxdaeehfxfv070yb6b8',
         role: 'assistant',
-        content: [{ type: 'text', text: 'Hello there!' }],
+        content: [{ type: 'text', text: 'Hello there!', citations: null }],
         model: 'claude-3-opus-20240229',
         stop_reason: 'end_turn',
         stop_sequence: null,
@@ -221,15 +221,15 @@ describe('MessageStream class', () => {
         },
         {
           "args": [
-            "{"type":"content_block_start","content_block":{"type":"text","text":""},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":""}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"content_block_start","content_block":{"type":"text","text":"","citations":null},"index":0}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -243,7 +243,7 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":" ther"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello ther"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello ther","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -257,7 +257,7 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":"e!"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequ,ence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -271,39 +271,39 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_stop","index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
-            "{"type":"text","text":"Hello there!"}",
+            "{"type":"text","text":"Hello there!","citations":null}",
           ],
           "type": "contentBlock",
         },
         {
           "args": [
             "{"type":"message_delta","usage":{"output_tokens":6},"delta":{"stop_reason":"end_turn","stop_sequence":null}}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
             "{"type":"message_stop"}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "message",
         },
         {
           "args": [
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "finalMessage",
         },
@@ -320,6 +320,7 @@ describe('MessageStream class', () => {
       {
         "content": [
           {
+            "citations": null,
             "text": "Hello there!",
             "type": "text",
           },
@@ -356,7 +357,7 @@ describe('MessageStream class', () => {
         type: 'message',
         id: 'msg_01hhptzfxdaeehfxfv070yb6b8',
         role: 'assistant',
-        content: [{ type: 'text', text: 'Hello there!' }],
+        content: [{ type: 'text', text: 'Hello there!', citations: null }],
         model: 'claude-3-opus-20240229',
         stop_reason: 'end_turn',
         stop_sequence: null,
diff --git tests/api-resources/beta/messages/batches.test.ts tests/api-resources/beta/messages/batches.test.ts
index 98d39506..b91258ea 100644
--- tests/api-resources/beta/messages/batches.test.ts
+++ tests/api-resources/beta/messages/batches.test.ts
@@ -44,7 +44,21 @@ describe('resource batches', () => {
             stop_sequences: ['string'],
             stream: false,
             system: [
-              { text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
+              {
+                text: "Today's date is 2024-06-01.",
+                type: 'text',
+                cache_control: { type: 'ephemeral' },
+                citations: [
+                  {
+                    cited_text: 'cited_text',
+                    document_index: 0,
+                    document_title: 'x',
+                    end_char_index: 0,
+                    start_char_index: 0,
+                    type: 'char_location',
+                  },
+                ],
+              },
             ],
             temperature: 1,
             tool_choice: { type: 'auto', disable_parallel_tool_use: true },
@@ -190,14 +204,16 @@ describe('resource batches', () => {
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options instead of params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options instead of params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.beta.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options and params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options and params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.beta.messages.batches.results(
diff --git tests/api-resources/beta/messages/messages.test.ts tests/api-resources/beta/messages/messages.test.ts
index 493de962..f2f6964b 100644
--- tests/api-resources/beta/messages/messages.test.ts
+++ tests/api-resources/beta/messages/messages.test.ts
@@ -32,7 +32,23 @@ describe('resource messages', () => {
       metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
       stop_sequences: ['string'],
       stream: false,
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       temperature: 1,
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
@@ -74,7 +90,23 @@ describe('resource messages', () => {
     const response = await client.beta.messages.countTokens({
       messages: [{ content: 'string', role: 'user' }],
       model: 'string',
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
         {
diff --git tests/api-resources/messages/batches.test.ts tests/api-resources/messages/batches.test.ts
index 4137fa31..c7239648 100644
--- tests/api-resources/messages/batches.test.ts
+++ tests/api-resources/messages/batches.test.ts
@@ -43,7 +43,21 @@ describe('resource batches', () => {
             metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
             stop_sequences: ['string'],
             system: [
-              { text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
+              {
+                text: "Today's date is 2024-06-01.",
+                type: 'text',
+                cache_control: { type: 'ephemeral' },
+                citations: [
+                  {
+                    cited_text: 'cited_text',
+                    document_index: 0,
+                    document_title: 'x',
+                    end_char_index: 0,
+                    start_char_index: 0,
+                    type: 'char_location',
+                  },
+                ],
+              },
             ],
             temperature: 1,
             tool_choice: { type: 'auto', disable_parallel_tool_use: true },
@@ -154,7 +168,8 @@ describe('resource batches', () => {
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options instead of params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options instead of params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
diff --git tests/api-resources/messages/messages.test.ts tests/api-resources/messages/messages.test.ts
index 7b9d6f96..a5b5d328 100644
--- tests/api-resources/messages/messages.test.ts
+++ tests/api-resources/messages/messages.test.ts
@@ -32,7 +32,23 @@ describe('resource messages', () => {
       metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
       stop_sequences: ['string'],
       stream: false,
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       temperature: 1,
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
@@ -72,7 +88,23 @@ describe('resource messages', () => {
     const response = await client.messages.countTokens({
       messages: [{ content: 'string', role: 'user' }],
       model: 'string',
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
         {

Description

This pull request updates various components of the SDK, including the bedrock-sdk and vertex-sdk packages, as well as introducing new message citation types and supporting utilities. The primary motivation for this change includes bug fixes, new feature additions (such as citations), and version bumps to ensure compatibility and utilize the latest updates.

Possible Issues

None identified.

Security Hotspots

None identified.

Changes

Changes

Updated Files and Directories

  • .release-please-manifest.json
    • Bumped the versions of packages.
  • .stats.yml
    • Updated the OpenAPI spec URL.
  • CHANGELOG.md
    • Added a detailed changelog.
  • api.md
    • Added new types related to citations and other new features.
  • package.json
    • Updated version to 0.36.3.
  • packages/bedrock-sdk/CHANGELOG.md
    • Added changelog entries related to recent updates.
  • packages/bedrock-sdk/package.json
    • Updated version to 0.12.4.
  • packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
    • Updated dependency version ranges.
  • packages/bedrock-sdk/src/streaming.ts
    • Updated import of readableStreamAsyncIterable to ReadableStreamToAsyncIterable.
  • packages/vertex-sdk/CHANGELOG.md
    • Added changelog entries for recent updates.
  • packages/vertex-sdk/package.json
    • Updated version to 0.6.4.
  • packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
    • Updated dependency version ranges.
  • src/index.ts
    • Added new citation-related types.
  • src/internal/decoders/jsonl.ts
    • Updated readableStreamAsyncIterable to ReadableStreamToAsyncIterable.
  • src/internal/stream-utils.ts
    • New file to handle stream conversion utilities.
  • src/lib/BetaMessageStream.ts
    • Added handling and events for new citation types.
  • src/lib/MessageStream.ts
    • Added handling and events for new citation types.
  • src/resources/beta/beta.ts
    • Added new citation-related types.
  • src/resources/beta/index.ts
    • Added new citation-related types.
  • src/resources/beta/messages/batches.ts
    • Updated documentation and types.
  • src/resources/beta/messages/index.ts
    • Added new citation-related types.
  • src/resources/beta/messages/messages.ts
    • Added new citation-related types.
  • src/resources/index.ts
    • Added new citation-related types.
  • src/resources/messages/batches.ts
    • Updated documentation and types.
  • src/resources/messages/index.ts
    • Added new citation-related types.
  • src/resources/messages/messages.ts
    • Added new citation-related types.
  • src/streaming.ts
    • Replaced internal stream utility function.
  • src/version.ts
    • Bumped version to 0.36.3.
  • tests/api-resources/MessageStream.test.ts
    • Updated tests to account for new citation fields.
  • tests/api-resources/beta/messages/batches.test.ts
    • Updated tests to account for new citation fields.
  • tests/api-resources/beta/messages/messages.test.ts
    • Updated tests to account for new citation fields.
  • tests/api-resources/messages/batches.test.ts
    • Updated tests to account for new citation fields.
  • tests/api-resources/messages/messages.test.ts
    • Updated tests to account for new citation fields.
sequenceDiagram
    participant PR as Pull Request
    participant SDK as SDK Core
    participant Bedrock as Bedrock SDK
    participant Vertex as Vertex SDK
    participant Resources as Resources
    participant Tests as Tests

    PR->>+SDK: Update version to 0.36.3
    PR->>+SDK: Add new citation-related types
    PR->>+SDK: Update stream-utils.ts
    PR->>+Bedrock: Bump version to 0.12.4
    PR->>+Bedrock: Fix stream import
    PR->>+Vertex: Bump version to 0.6.4
    PR->>+Resources: Update beta and messages resources
    PR->>+Resources: Add new citation-related types
    PR->>+Tests: Update tests for new citation fields
Loading

Copy link

bedrock debug - [puLL-Merge] - anthropics/[email protected]

Diff
diff --git .release-please-manifest.json .release-please-manifest.json
index cb210381..e6222438 100644
--- .release-please-manifest.json
+++ .release-please-manifest.json
@@ -1,5 +1,5 @@
 {
-  ".": "0.35.0",
-  "packages/vertex-sdk": "0.6.3",
-  "packages/bedrock-sdk": "0.12.2"
+  ".": "0.36.3",
+  "packages/vertex-sdk": "0.6.4",
+  "packages/bedrock-sdk": "0.12.4"
 }
diff --git .stats.yml .stats.yml
index 239e17b7..64f8716d 100644
--- .stats.yml
+++ .stats.yml
@@ -1,2 +1,2 @@
 configured_endpoints: 21
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-fd67aea6883f1ee9e46f31a42d3940f0acb1749e787055bd9b9f278b20fa53ec.yml
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/anthropic-f5276eeef7512112e802c85530c51e0a971ee521eebe3a0db309621587b4973d.yml
diff --git CHANGELOG.md CHANGELOG.md
index 499e576c..da99f256 100644
--- CHANGELOG.md
+++ CHANGELOG.md
@@ -1,5 +1,52 @@
 # Changelog
 
+## 0.36.3 (2025-01-27)
+
+Full Changelog: [sdk-v0.36.2...sdk-v0.36.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.2...sdk-v0.36.3)
+
+### Bug Fixes
+
+* **streaming:** accumulate citations ([#675](https://github.com/anthropics/anthropic-sdk-typescript/issues/675)) ([522118f](https://github.com/anthropics/anthropic-sdk-typescript/commit/522118ffeab327e8476f12d9b9fa1f19042ed714))
+
+
+### Chores
+
+* **docs:** updates ([#673](https://github.com/anthropics/anthropic-sdk-typescript/issues/673)) ([751ecd0](https://github.com/anthropics/anthropic-sdk-typescript/commit/751ecd0d44707b21ccb390c81716937fae3d8e35))
+
+## 0.36.2 (2025-01-23)
+
+Full Changelog: [sdk-v0.36.1...sdk-v0.36.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.1...sdk-v0.36.2)
+
+### Bug Fixes
+
+* **bedrock:** update streaming util import ([255c059](https://github.com/anthropics/anthropic-sdk-typescript/commit/255c0599e333e6fae582255e3b0631538b168c69))
+
+## 0.36.1 (2025-01-23)
+
+Full Changelog: [sdk-v0.36.0...sdk-v0.36.1](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.36.0...sdk-v0.36.1)
+
+### Chores
+
+* **tests:** fix types ([9efe3ee](https://github.com/anthropics/anthropic-sdk-typescript/commit/9efe3eebf64bd762a34caf362a1cd1a0f0858f92))
+
+## 0.36.0 (2025-01-23)
+
+Full Changelog: [sdk-v0.35.0...sdk-v0.36.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.35.0...sdk-v0.36.0)
+
+### Features
+
+* **api:** add citations ([#668](https://github.com/anthropics/anthropic-sdk-typescript/issues/668)) ([1fef177](https://github.com/anthropics/anthropic-sdk-typescript/commit/1fef17749adbbeb243480b96c04941be29c0746c))
+* **client:** support results endpoint ([#666](https://github.com/anthropics/anthropic-sdk-typescript/issues/666)) ([db5fffe](https://github.com/anthropics/anthropic-sdk-typescript/commit/db5fffeb38a99a3e9283ebf001fbf767d756162e))
+* **stream:** expose `response` property as well ([b0235c7](https://github.com/anthropics/anthropic-sdk-typescript/commit/b0235c7b3ac174b3c8e670e381b4aa038e61c826))
+
+
+### Chores
+
+* **bedrock:** bump dependency on @anthropic-ai/sdk ([8745ca2](https://github.com/anthropics/anthropic-sdk-typescript/commit/8745ca2160f5af4d89e5732a44e560c5e2787aa8))
+* **internal:** fix import ([628b55e](https://github.com/anthropics/anthropic-sdk-typescript/commit/628b55ef5ff8f0245287ecaea688480a0174e2e9))
+* **internal:** minor restructuring ([#664](https://github.com/anthropics/anthropic-sdk-typescript/issues/664)) ([57aefa7](https://github.com/anthropics/anthropic-sdk-typescript/commit/57aefa73230d54da24d787a89adc277481986d02))
+* **vertex:** bump dependency on @anthropic-ai/sdk ([a1c7fcd](https://github.com/anthropics/anthropic-sdk-typescript/commit/a1c7fcdce081f860cbb1148c3862e3303ddb8a62))
+
 ## 0.35.0 (2025-01-21)
 
 Full Changelog: [sdk-v0.34.0...sdk-v0.35.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/sdk-v0.34.0...sdk-v0.35.0)
diff --git api.md api.md
index 9aed2e92..1a3d66bc 100644
--- api.md
+++ api.md
@@ -22,9 +22,19 @@ Types:
 
 - <code><a href="./src/resources/messages/messages.ts">Base64PDFSource</a></code>
 - <code><a href="./src/resources/messages/messages.ts">CacheControlEphemeral</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationCharLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationCharLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationContentBlockLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationContentBlockLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationPageLocation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationPageLocationParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationsConfigParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">CitationsDelta</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlock</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">ContentBlockSource</a></code>
+- <code><a href="./src/resources/messages/messages.ts">ContentBlockSourceContent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ContentBlockStopEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">DocumentBlockParam</a></code>
@@ -40,6 +50,7 @@ Types:
 - <code><a href="./src/resources/messages/messages.ts">MessageTokensCount</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Metadata</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Model</a></code>
+- <code><a href="./src/resources/messages/messages.ts">PlainTextSource</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">RawContentBlockStopEvent</a></code>
@@ -49,6 +60,8 @@ Types:
 - <code><a href="./src/resources/messages/messages.ts">RawMessageStreamEvent</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextBlock</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextBlockParam</a></code>
+- <code><a href="./src/resources/messages/messages.ts">TextCitation</a></code>
+- <code><a href="./src/resources/messages/messages.ts">TextCitationParam</a></code>
 - <code><a href="./src/resources/messages/messages.ts">TextDelta</a></code>
 - <code><a href="./src/resources/messages/messages.ts">Tool</a></code>
 - <code><a href="./src/resources/messages/messages.ts">ToolChoice</a></code>
@@ -87,7 +100,7 @@ Methods:
 - <code title="get /v1/messages/batches">client.messages.batches.<a href="./src/resources/messages/batches.ts">list</a>({ ...params }) -> MessageBatchesPage</code>
 - <code title="delete /v1/messages/batches/{message_batch_id}">client.messages.batches.<a href="./src/resources/messages/batches.ts">delete</a>(messageBatchId) -> DeletedMessageBatch</code>
 - <code title="post /v1/messages/batches/{message_batch_id}/cancel">client.messages.batches.<a href="./src/resources/messages/batches.ts">cancel</a>(messageBatchId) -> MessageBatch</code>
-- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
+- <code title="get /v1/messages/batches/{message_batch_id}/results">client.messages.batches.<a href="./src/resources/messages/batches.ts">results</a>(messageBatchId) -> JSONLDecoder&lt;MessageBatchIndividualResponse&gt;</code>
 
 # Models
 
@@ -135,8 +148,18 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaBase64PDFSource</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaCacheControlEphemeral</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">BetaCitationContentBlockLocation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationContentBlockLocationParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationPageLocation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationPageLocationParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsConfigParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaCitationsDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSource</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaContentBlockSourceContent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaImageBlockParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaInputJSONDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessage</a></code>
@@ -144,6 +167,7 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMessageTokensCount</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaMetadata</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaPlainTextSource</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockDeltaEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockStartEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawContentBlockStopEvent</a></code>
@@ -153,6 +177,8 @@ Types:
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaRawMessageStreamEvent</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlock</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextBlockParam</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextCitation</a></code>
+- <code><a href="./src/resources/beta/messages/messages.ts">BetaTextCitationParam</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTextDelta</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaTool</a></code>
 - <code><a href="./src/resources/beta/messages/messages.ts">BetaToolBash20241022</a></code>
@@ -194,4 +220,4 @@ Methods:
 - <code title="get /v1/messages/batches?beta=true">client.beta.messages.batches.<a href="./src/resources/beta/messages/batches.ts">list</a>({ ...params }) -> BetaMessageBatchesPage</code>
 - <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>
 - <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>
-- <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 }) -> JSONLDecoder\<MessageBatchIndividualResponse\></code>
+- <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 }) -> JSONLDecoder&lt;BetaMessageBatchIndividualResponse&gt;</code>
diff --git package.json package.json
index aa23123e..6fb9c0c4 100644
--- package.json
+++ package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/sdk",
-  "version": "0.35.0",
+  "version": "0.36.3",
   "description": "The official TypeScript library for the Anthropic API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/bedrock-sdk/CHANGELOG.md packages/bedrock-sdk/CHANGELOG.md
index 12fec54c..4b46a678 100644
--- packages/bedrock-sdk/CHANGELOG.md
+++ packages/bedrock-sdk/CHANGELOG.md
@@ -1,5 +1,21 @@
 # Changelog
 
+## 0.12.4 (2025-01-23)
+
+Full Changelog: [bedrock-sdk-v0.12.3...bedrock-sdk-v0.12.4](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.3...bedrock-sdk-v0.12.4)
+
+### Bug Fixes
+
+* **bedrock:** update streaming util import ([255c059](https://github.com/anthropics/anthropic-sdk-typescript/commit/255c0599e333e6fae582255e3b0631538b168c69))
+
+## 0.12.3 (2025-01-23)
+
+Full Changelog: [bedrock-sdk-v0.12.2...bedrock-sdk-v0.12.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.2...bedrock-sdk-v0.12.3)
+
+### Chores
+
+* **bedrock:** bump dependency on @anthropic-ai/sdk ([8745ca2](https://github.com/anthropics/anthropic-sdk-typescript/commit/8745ca2160f5af4d89e5732a44e560c5e2787aa8))
+
 ## 0.12.2 (2025-01-21)
 
 Full Changelog: [bedrock-sdk-v0.12.1...bedrock-sdk-v0.12.2](https://github.com/anthropics/anthropic-sdk-typescript/compare/bedrock-sdk-v0.12.1...bedrock-sdk-v0.12.2)
diff --git packages/bedrock-sdk/package.json packages/bedrock-sdk/package.json
index 8e7a906d..8236a27d 100644
--- packages/bedrock-sdk/package.json
+++ packages/bedrock-sdk/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/bedrock-sdk",
-  "version": "0.12.2",
+  "version": "0.12.4",
   "description": "The official TypeScript library for the Anthropic Bedrock API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
index 12a41324..aeaa36a3 100644
--- packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
+++ packages/bedrock-sdk/scripts/postprocess-dist-package-json.cjs
@@ -4,8 +4,8 @@ const pkgJson = require('../dist/package.json');
 for (const dep in pkgJson.dependencies) {
   // ensure we point to NPM instead of a local directory
   if (dep === '@anthropic-ai/sdk') {
-    pkgJson.dependencies[dep] = '^0';
+    pkgJson.dependencies[dep] = '>=0.36 <1';
   }
 }
 
-fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
+fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));
diff --git packages/bedrock-sdk/src/streaming.ts packages/bedrock-sdk/src/streaming.ts
index 01f0956b..7a97ee64 100644
--- packages/bedrock-sdk/src/streaming.ts
+++ packages/bedrock-sdk/src/streaming.ts
@@ -2,11 +2,8 @@ import { EventStreamMarshaller } from '@smithy/eventstream-serde-node';
 import { fromBase64, toBase64 } from '@smithy/util-base64';
 import { streamCollector } from '@smithy/fetch-http-handler';
 import { EventStreamSerdeContext, SerdeContext } from '@smithy/types';
-import {
-  Stream as CoreStream,
-  readableStreamAsyncIterable,
-  ServerSentEvent,
-} from '@anthropic-ai/sdk/streaming';
+import { Stream as CoreStream, ServerSentEvent } from '@anthropic-ai/sdk/streaming';
+import { ReadableStreamToAsyncIterable } from '@anthropic-ai/sdk/internal/stream-utils';
 import { AnthropicError } from '@anthropic-ai/sdk/error';
 import { APIError } from '@anthropic-ai/sdk';
 import { createResponseHeaders, safeJSON } from '@anthropic-ai/sdk/core';
@@ -42,7 +39,7 @@ export class Stream<Item> extends CoreStream<Item> {
         throw new AnthropicError(`Attempted to iterate over a response with no body`);
       }
 
-      const responseBodyIter = readableStreamAsyncIterable<Bytes>(response.body);
+      const responseBodyIter = ReadableStreamToAsyncIterable<Bytes>(response.body);
       const eventStream = de_ResponseStream(responseBodyIter, getMinimalSerdeContext());
       for await (const event of eventStream) {
         if (event.chunk && event.chunk.bytes) {
diff --git packages/vertex-sdk/CHANGELOG.md packages/vertex-sdk/CHANGELOG.md
index e01d1d71..9e83b1e8 100644
--- packages/vertex-sdk/CHANGELOG.md
+++ packages/vertex-sdk/CHANGELOG.md
@@ -1,5 +1,13 @@
 # Changelog
 
+## 0.6.4 (2025-01-23)
+
+Full Changelog: [vertex-sdk-v0.6.3...vertex-sdk-v0.6.4](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.3...vertex-sdk-v0.6.4)
+
+### Chores
+
+* **vertex:** bump dependency on @anthropic-ai/sdk ([a1c7fcd](https://github.com/anthropics/anthropic-sdk-typescript/commit/a1c7fcdce081f860cbb1148c3862e3303ddb8a62))
+
 ## 0.6.3 (2025-01-21)
 
 Full Changelog: [vertex-sdk-v0.6.2...vertex-sdk-v0.6.3](https://github.com/anthropics/anthropic-sdk-typescript/compare/vertex-sdk-v0.6.2...vertex-sdk-v0.6.3)
diff --git packages/vertex-sdk/package.json packages/vertex-sdk/package.json
index ae4cf6f9..ac5bda51 100644
--- packages/vertex-sdk/package.json
+++ packages/vertex-sdk/package.json
@@ -1,6 +1,6 @@
 {
   "name": "@anthropic-ai/vertex-sdk",
-  "version": "0.6.3",
+  "version": "0.6.4",
   "description": "The official TypeScript library for the Anthropic Vertex API",
   "author": "Anthropic <[email protected]>",
   "types": "dist/index.d.ts",
diff --git packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
index f8abd4b9..da232fe3 100644
--- packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
+++ packages/vertex-sdk/scripts/postprocess-dist-package-json.cjs
@@ -4,8 +4,8 @@ const pkgJson = require('../dist/package.json');
 for (const dep in pkgJson.dependencies) {
   // ensure we point to NPM instead of a local directory
   if (dep === '@anthropic-ai/sdk') {
-    pkgJson.dependencies[dep] = '>=0.14 <1';
+    pkgJson.dependencies[dep] = '>=0.35 <1';
   }
 }
 
-fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2))
+fs.writeFileSync('dist/package.json', JSON.stringify(pkgJson, null, 2));
diff --git src/index.ts src/index.ts
index 44f6bc2d..0872e7a7 100644
--- src/index.ts
+++ src/index.ts
@@ -33,9 +33,19 @@ import {
 import {
   Base64PDFSource,
   CacheControlEphemeral,
+  CitationCharLocation,
+  CitationCharLocationParam,
+  CitationContentBlockLocation,
+  CitationContentBlockLocationParam,
+  CitationPageLocation,
+  CitationPageLocationParam,
+  CitationsConfigParam,
+  CitationsDelta,
   ContentBlock,
   ContentBlockDeltaEvent,
   ContentBlockParam,
+  ContentBlockSource,
+  ContentBlockSourceContent,
   ContentBlockStartEvent,
   ContentBlockStopEvent,
   DocumentBlockParam,
@@ -57,6 +67,7 @@ import {
   Messages,
   Metadata,
   Model,
+  PlainTextSource,
   RawContentBlockDeltaEvent,
   RawContentBlockStartEvent,
   RawContentBlockStopEvent,
@@ -66,6 +77,8 @@ import {
   RawMessageStreamEvent,
   TextBlock,
   TextBlockParam,
+  TextCitation,
+  TextCitationParam,
   TextDelta,
   Tool,
   ToolChoice,
@@ -322,9 +335,19 @@ export declare namespace Anthropic {
     Messages as Messages,
     type Base64PDFSource as Base64PDFSource,
     type CacheControlEphemeral as CacheControlEphemeral,
+    type CitationCharLocation as CitationCharLocation,
+    type CitationCharLocationParam as CitationCharLocationParam,
+    type CitationContentBlockLocation as CitationContentBlockLocation,
+    type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
+    type CitationPageLocation as CitationPageLocation,
+    type CitationPageLocationParam as CitationPageLocationParam,
+    type CitationsConfigParam as CitationsConfigParam,
+    type CitationsDelta as CitationsDelta,
     type ContentBlock as ContentBlock,
     type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
     type ContentBlockParam as ContentBlockParam,
+    type ContentBlockSource as ContentBlockSource,
+    type ContentBlockSourceContent as ContentBlockSourceContent,
     type ContentBlockStartEvent as ContentBlockStartEvent,
     type ContentBlockStopEvent as ContentBlockStopEvent,
     type DocumentBlockParam as DocumentBlockParam,
@@ -340,6 +363,7 @@ export declare namespace Anthropic {
     type MessageTokensCount as MessageTokensCount,
     type Metadata as Metadata,
     type Model as Model,
+    type PlainTextSource as PlainTextSource,
     type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
     type RawContentBlockStartEvent as RawContentBlockStartEvent,
     type RawContentBlockStopEvent as RawContentBlockStopEvent,
@@ -349,6 +373,8 @@ export declare namespace Anthropic {
     type RawMessageStreamEvent as RawMessageStreamEvent,
     type TextBlock as TextBlock,
     type TextBlockParam as TextBlockParam,
+    type TextCitation as TextCitation,
+    type TextCitationParam as TextCitationParam,
     type TextDelta as TextDelta,
     type Tool as Tool,
     type ToolChoice as ToolChoice,
diff --git src/internal/decoders/jsonl.ts src/internal/decoders/jsonl.ts
index 8d3693d8..15751255 100644
--- src/internal/decoders/jsonl.ts
+++ src/internal/decoders/jsonl.ts
@@ -1,5 +1,5 @@
 import { AnthropicError } from '../../error';
-import { readableStreamAsyncIterable } from '../../streaming';
+import { ReadableStreamToAsyncIterable } from '../stream-utils';
 import { type Response } from '../../_shims/index';
 import { LineDecoder, type Bytes } from './line';
 
@@ -36,6 +36,6 @@ export class JSONLDecoder<T> {
       throw new AnthropicError(`Attempted to iterate over a response with no body`);
     }
 
-    return new JSONLDecoder(readableStreamAsyncIterable<Bytes>(response.body), controller);
+    return new JSONLDecoder(ReadableStreamToAsyncIterable<Bytes>(response.body), controller);
   }
 }
diff --git a/src/internal/stream-utils.ts b/src/internal/stream-utils.ts
new file mode 100644
index 00000000..37f7793c
--- /dev/null
+++ src/internal/stream-utils.ts
@@ -0,0 +1,32 @@
+/**
+ * Most browsers don't yet have async iterable support for ReadableStream,
+ * and Node has a very different way of reading bytes from its "ReadableStream".
+ *
+ * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
+ */
+export function ReadableStreamToAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
+  if (stream[Symbol.asyncIterator]) return stream;
+
+  const reader = stream.getReader();
+  return {
+    async next() {
+      try {
+        const result = await reader.read();
+        if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
+        return result;
+      } catch (e) {
+        reader.releaseLock(); // release lock when stream becomes errored
+        throw e;
+      }
+    },
+    async return() {
+      const cancelPromise = reader.cancel();
+      reader.releaseLock();
+      await cancelPromise;
+      return { done: true, value: undefined };
+    },
+    [Symbol.asyncIterator]() {
+      return this;
+    },
+  };
+}
diff --git src/lib/BetaMessageStream.ts src/lib/BetaMessageStream.ts
index 06fbc46a..5de54f06 100644
--- src/lib/BetaMessageStream.ts
+++ src/lib/BetaMessageStream.ts
@@ -9,6 +9,7 @@ import {
   type MessageCreateParams as BetaMessageCreateParams,
   type MessageCreateParamsBase as BetaMessageCreateParamsBase,
   type BetaTextBlock,
+  type BetaTextCitation,
 } from '@anthropic-ai/sdk/resources/beta/messages/messages';
 import { type ReadableStream, type Response } from '@anthropic-ai/sdk/_shims/index';
 import { Stream } from '@anthropic-ai/sdk/streaming';
@@ -18,6 +19,7 @@ export interface MessageStreamEvents {
   connect: () => void;
   streamEvent: (event: BetaMessageStreamEvent, snapshot: BetaMessage) => void;
   text: (textDelta: string, textSnapshot: string) => void;
+  citation: (citation: BetaTextCitation, citationsSnapshot: BetaTextCitation[]) => void;
   inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
   message: (message: BetaMessage) => void;
   contentBlock: (content: BetaContentBlock) => void;
@@ -55,6 +57,7 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
   #errored = false;
   #aborted = false;
   #catchingPromiseCreated = false;
+  #response: Response | null | undefined;
   #request_id: string | null | undefined;
 
   constructor() {
@@ -76,6 +79,10 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     this.#endPromise.catch(() => {});
   }
 
+  get response(): Response | null | undefined {
+    return this.#response;
+  }
+
   get request_id(): string | null | undefined {
     return this.#request_id;
   }
@@ -183,6 +190,7 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
 
   protected _connected(response: Response | null) {
     if (this.ended) return;
+    this.#response = response;
     this.#request_id = response?.headers.get('request-id');
     this.#resolveConnectedPromise(response);
     this._emit('connect');
@@ -407,12 +415,27 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     switch (event.type) {
       case 'content_block_delta': {
         const content = messageSnapshot.content.at(-1)!;
-        if (event.delta.type === 'text_delta' && content.type === 'text') {
-          this._emit('text', event.delta.text, content.text || '');
-        } else if (event.delta.type === 'input_json_delta' && content.type === 'tool_use') {
-          if (content.input) {
-            this._emit('inputJson', event.delta.partial_json, content.input);
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (content.type === 'text') {
+              this._emit('text', event.delta.text, content.text || '');
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (content.type === 'text') {
+              this._emit('citation', event.delta.citation, content.citations ?? []);
+            }
+            break;
+          }
+          case 'input_json_delta': {
+            if (content.type === 'tool_use' && content.input) {
+              this._emit('inputJson', event.delta.partial_json, content.input);
+            }
+            break;
           }
+          default:
+            checkNever(event.delta);
         }
         break;
       }
@@ -499,24 +522,43 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
         return snapshot;
       case 'content_block_delta': {
         const snapshotContent = snapshot.content.at(event.index);
-        if (snapshotContent?.type === 'text' && event.delta.type === 'text_delta') {
-          snapshotContent.text += event.delta.text;
-        } else if (snapshotContent?.type === 'tool_use' && event.delta.type === 'input_json_delta') {
-          // we need to keep track of the raw JSON string as well so that we can
-          // re-parse it for each delta, for now we just store it as an untyped
-          // non-enumerable property on the snapshot
-          let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
-          jsonBuf += event.delta.partial_json;
-
-          Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
-            value: jsonBuf,
-            enumerable: false,
-            writable: true,
-          });
-
-          if (jsonBuf) {
-            snapshotContent.input = partialParse(jsonBuf);
+
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.text += event.delta.text;
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.citations ??= [];
+              snapshotContent.citations.push(event.delta.citation);
+            }
+            break;
           }
+          case 'input_json_delta': {
+            if (snapshotContent?.type === 'tool_use') {
+              // we need to keep track of the raw JSON string as well so that we can
+              // re-parse it for each delta, for now we just store it as an untyped
+              // non-enumerable property on the snapshot
+              let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
+              jsonBuf += event.delta.partial_json;
+
+              Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
+                value: jsonBuf,
+                enumerable: false,
+                writable: true,
+              });
+
+              if (jsonBuf) {
+                snapshotContent.input = partialParse(jsonBuf);
+              }
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
         return snapshot;
       }
@@ -591,3 +633,6 @@ export class BetaMessageStream implements AsyncIterable<BetaMessageStreamEvent>
     return stream.toReadableStream();
   }
 }
+
+// used to ensure exhaustive case matching without throwing a runtime error
+function checkNever(x: never) {}
diff --git src/lib/MessageStream.ts src/lib/MessageStream.ts
index 65e84b29..4ce3a382 100644
--- src/lib/MessageStream.ts
+++ src/lib/MessageStream.ts
@@ -9,6 +9,7 @@ import {
   type MessageCreateParams,
   type MessageCreateParamsBase,
   type TextBlock,
+  type TextCitation,
 } from '@anthropic-ai/sdk/resources/messages';
 import { type ReadableStream, type Response } from '@anthropic-ai/sdk/_shims/index';
 import { Stream } from '@anthropic-ai/sdk/streaming';
@@ -18,6 +19,7 @@ export interface MessageStreamEvents {
   connect: () => void;
   streamEvent: (event: MessageStreamEvent, snapshot: Message) => void;
   text: (textDelta: string, textSnapshot: string) => void;
+  citation: (citation: TextCitation, citationsSnapshot: TextCitation[]) => void;
   inputJson: (partialJson: string, jsonSnapshot: unknown) => void;
   message: (message: Message) => void;
   contentBlock: (content: ContentBlock) => void;
@@ -55,6 +57,7 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
   #errored = false;
   #aborted = false;
   #catchingPromiseCreated = false;
+  #response: Response | null | undefined;
   #request_id: string | null | undefined;
 
   constructor() {
@@ -76,6 +79,10 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     this.#endPromise.catch(() => {});
   }
 
+  get response(): Response | null | undefined {
+    return this.#response;
+  }
+
   get request_id(): string | null | undefined {
     return this.#request_id;
   }
@@ -183,6 +190,7 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
 
   protected _connected(response: Response | null) {
     if (this.ended) return;
+    this.#response = response;
     this.#request_id = response?.headers.get('request-id');
     this.#resolveConnectedPromise(response);
     this._emit('connect');
@@ -407,12 +415,27 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     switch (event.type) {
       case 'content_block_delta': {
         const content = messageSnapshot.content.at(-1)!;
-        if (event.delta.type === 'text_delta' && content.type === 'text') {
-          this._emit('text', event.delta.text, content.text || '');
-        } else if (event.delta.type === 'input_json_delta' && content.type === 'tool_use') {
-          if (content.input) {
-            this._emit('inputJson', event.delta.partial_json, content.input);
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (content.type === 'text') {
+              this._emit('text', event.delta.text, content.text || '');
+            }
+            break;
+          }
+          case 'citations_delta': {
+            if (content.type === 'text') {
+              this._emit('citation', event.delta.citation, content.citations ?? []);
+            }
+            break;
           }
+          case 'input_json_delta': {
+            if (content.type === 'tool_use' && content.input) {
+              this._emit('inputJson', event.delta.partial_json, content.input);
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
         break;
       }
@@ -499,25 +522,45 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
         return snapshot;
       case 'content_block_delta': {
         const snapshotContent = snapshot.content.at(event.index);
-        if (snapshotContent?.type === 'text' && event.delta.type === 'text_delta') {
-          snapshotContent.text += event.delta.text;
-        } else if (snapshotContent?.type === 'tool_use' && event.delta.type === 'input_json_delta') {
-          // we need to keep track of the raw JSON string as well so that we can
-          // re-parse it for each delta, for now we just store it as an untyped
-          // non-enumerable property on the snapshot
-          let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
-          jsonBuf += event.delta.partial_json;
-
-          Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
-            value: jsonBuf,
-            enumerable: false,
-            writable: true,
-          });
-
-          if (jsonBuf) {
-            snapshotContent.input = partialParse(jsonBuf);
+
+        switch (event.delta.type) {
+          case 'text_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.text += event.delta.text;
+            }
+            break;
           }
+          case 'citations_delta': {
+            if (snapshotContent?.type === 'text') {
+              snapshotContent.citations ??= [];
+              snapshotContent.citations.push(event.delta.citation);
+            }
+            break;
+          }
+          case 'input_json_delta': {
+            if (snapshotContent?.type === 'tool_use') {
+              // we need to keep track of the raw JSON string as well so that we can
+              // re-parse it for each delta, for now we just store it as an untyped
+              // non-enumerable property on the snapshot
+              let jsonBuf = (snapshotContent as any)[JSON_BUF_PROPERTY] || '';
+              jsonBuf += event.delta.partial_json;
+
+              Object.defineProperty(snapshotContent, JSON_BUF_PROPERTY, {
+                value: jsonBuf,
+                enumerable: false,
+                writable: true,
+              });
+
+              if (jsonBuf) {
+                snapshotContent.input = partialParse(jsonBuf);
+              }
+            }
+            break;
+          }
+          default:
+            checkNever(event.delta);
         }
+
         return snapshot;
       }
       case 'content_block_stop':
@@ -591,3 +634,6 @@ export class MessageStream implements AsyncIterable<MessageStreamEvent> {
     return stream.toReadableStream();
   }
 }
+
+// used to ensure exhaustive case matching without throwing a runtime error
+function checkNever(x: never) {}
diff --git src/resources/beta/beta.ts src/resources/beta/beta.ts
index e29a187c..a1f3f0d4 100644
--- src/resources/beta/beta.ts
+++ src/resources/beta/beta.ts
@@ -8,8 +8,18 @@ import {
   BetaBase64PDFBlock,
   BetaBase64PDFSource,
   BetaCacheControlEphemeral,
+  BetaCitationCharLocation,
+  BetaCitationCharLocationParam,
+  BetaCitationContentBlockLocation,
+  BetaCitationContentBlockLocationParam,
+  BetaCitationPageLocation,
+  BetaCitationPageLocationParam,
+  BetaCitationsConfigParam,
+  BetaCitationsDelta,
   BetaContentBlock,
   BetaContentBlockParam,
+  BetaContentBlockSource,
+  BetaContentBlockSourceContent,
   BetaImageBlockParam,
   BetaInputJSONDelta,
   BetaMessage,
@@ -17,6 +27,7 @@ import {
   BetaMessageParam,
   BetaMessageTokensCount,
   BetaMetadata,
+  BetaPlainTextSource,
   BetaRawContentBlockDeltaEvent,
   BetaRawContentBlockStartEvent,
   BetaRawContentBlockStopEvent,
@@ -26,6 +37,8 @@ import {
   BetaRawMessageStreamEvent,
   BetaTextBlock,
   BetaTextBlockParam,
+  BetaTextCitation,
+  BetaTextCitationParam,
   BetaTextDelta,
   BetaTool,
   BetaToolBash20241022,
@@ -163,8 +176,18 @@ export declare namespace Beta {
     type BetaBase64PDFBlock as BetaBase64PDFBlock,
     type BetaBase64PDFSource as BetaBase64PDFSource,
     type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
+    type BetaCitationCharLocation as BetaCitationCharLocation,
+    type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
+    type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
+    type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
+    type BetaCitationPageLocation as BetaCitationPageLocation,
+    type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
+    type BetaCitationsConfigParam as BetaCitationsConfigParam,
+    type BetaCitationsDelta as BetaCitationsDelta,
     type BetaContentBlock as BetaContentBlock,
     type BetaContentBlockParam as BetaContentBlockParam,
+    type BetaContentBlockSource as BetaContentBlockSource,
+    type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
     type BetaImageBlockParam as BetaImageBlockParam,
     type BetaInputJSONDelta as BetaInputJSONDelta,
     type BetaMessage as BetaMessage,
@@ -172,6 +195,7 @@ export declare namespace Beta {
     type BetaMessageParam as BetaMessageParam,
     type BetaMessageTokensCount as BetaMessageTokensCount,
     type BetaMetadata as BetaMetadata,
+    type BetaPlainTextSource as BetaPlainTextSource,
     type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
     type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
     type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
@@ -181,6 +205,8 @@ export declare namespace Beta {
     type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
     type BetaTextBlock as BetaTextBlock,
     type BetaTextBlockParam as BetaTextBlockParam,
+    type BetaTextCitation as BetaTextCitation,
+    type BetaTextCitationParam as BetaTextCitationParam,
     type BetaTextDelta as BetaTextDelta,
     type BetaTool as BetaTool,
     type BetaToolBash20241022 as BetaToolBash20241022,
diff --git src/resources/beta/index.ts src/resources/beta/index.ts
index a68f2327..743f9c42 100644
--- src/resources/beta/index.ts
+++ src/resources/beta/index.ts
@@ -21,8 +21,18 @@ export {
   type BetaBase64PDFBlock,
   type BetaBase64PDFSource,
   type BetaCacheControlEphemeral,
+  type BetaCitationCharLocation,
+  type BetaCitationCharLocationParam,
+  type BetaCitationContentBlockLocation,
+  type BetaCitationContentBlockLocationParam,
+  type BetaCitationPageLocation,
+  type BetaCitationPageLocationParam,
+  type BetaCitationsConfigParam,
+  type BetaCitationsDelta,
   type BetaContentBlock,
   type BetaContentBlockParam,
+  type BetaContentBlockSource,
+  type BetaContentBlockSourceContent,
   type BetaImageBlockParam,
   type BetaInputJSONDelta,
   type BetaMessage,
@@ -30,6 +40,7 @@ export {
   type BetaMessageParam,
   type BetaMessageTokensCount,
   type BetaMetadata,
+  type BetaPlainTextSource,
   type BetaRawContentBlockDeltaEvent,
   type BetaRawContentBlockStartEvent,
   type BetaRawContentBlockStopEvent,
@@ -39,6 +50,8 @@ export {
   type BetaRawMessageStreamEvent,
   type BetaTextBlock,
   type BetaTextBlockParam,
+  type BetaTextCitation,
+  type BetaTextCitationParam,
   type BetaTextDelta,
   type BetaTool,
   type BetaToolBash20241022,
diff --git src/resources/beta/messages/batches.ts src/resources/beta/messages/batches.ts
index 74f4e53b..6370119c 100644
--- src/resources/beta/messages/batches.ts
+++ src/resources/beta/messages/batches.ts
@@ -86,9 +86,10 @@ export class Batches extends APIResource {
   }
 
   /**
-   * This endpoint is idempotent and can be used to poll for Message Batch
-   * completion. To access the results of a Message Batch, make a request to the
-   * `results_url` field in the response.
+   * Delete a Message Batch.
+   *
+   * Message Batches can only be deleted once they've finished processing. If you'd
+   * like to delete an in-progress batch, you must first cancel it.
    */
   delete(
     messageBatchId: string,
@@ -298,6 +299,10 @@ export interface BetaMessageBatchExpiredResult {
   type: 'expired';
 }
 
+/**
+ * This is a single line in the response `.jsonl` file and does not represent the
+ * response as a whole.
+ */
 export interface BetaMessageBatchIndividualResponse {
   /**
    * Developer-provided ID created for each request in a Message Batch. Useful for
diff --git src/resources/beta/messages/index.ts src/resources/beta/messages/index.ts
index eac5d34f..51a0f935 100644
--- src/resources/beta/messages/index.ts
+++ src/resources/beta/messages/index.ts
@@ -24,8 +24,18 @@ export {
   type BetaBase64PDFBlock,
   type BetaBase64PDFSource,
   type BetaCacheControlEphemeral,
+  type BetaCitationCharLocation,
+  type BetaCitationCharLocationParam,
+  type BetaCitationContentBlockLocation,
+  type BetaCitationContentBlockLocationParam,
+  type BetaCitationPageLocation,
+  type BetaCitationPageLocationParam,
+  type BetaCitationsConfigParam,
+  type BetaCitationsDelta,
   type BetaContentBlock,
   type BetaContentBlockParam,
+  type BetaContentBlockSource,
+  type BetaContentBlockSourceContent,
   type BetaImageBlockParam,
   type BetaInputJSONDelta,
   type BetaMessage,
@@ -33,6 +43,7 @@ export {
   type BetaMessageParam,
   type BetaMessageTokensCount,
   type BetaMetadata,
+  type BetaPlainTextSource,
   type BetaRawContentBlockDeltaEvent,
   type BetaRawContentBlockStartEvent,
   type BetaRawContentBlockStopEvent,
@@ -42,6 +53,8 @@ export {
   type BetaRawMessageStreamEvent,
   type BetaTextBlock,
   type BetaTextBlockParam,
+  type BetaTextCitation,
+  type BetaTextCitationParam,
   type BetaTextDelta,
   type BetaTool,
   type BetaToolBash20241022,
diff --git src/resources/beta/messages/messages.ts src/resources/beta/messages/messages.ts
index ecb1d79f..3b35717a 100644
--- src/resources/beta/messages/messages.ts
+++ src/resources/beta/messages/messages.ts
@@ -120,11 +120,17 @@ export class Messages extends APIResource {
 export type BetaMessageStreamParams = MessageCreateParamsBase;
 
 export interface BetaBase64PDFBlock {
-  source: BetaBase64PDFSource;
+  source: BetaBase64PDFSource | BetaPlainTextSource | BetaContentBlockSource;
 
   type: 'document';
 
   cache_control?: BetaCacheControlEphemeral | null;
+
+  citations?: BetaCitationsConfigParam;
+
+  context?: string | null;
+
+  title?: string | null;
 }
 
 export interface BetaBase64PDFSource {
@@ -139,6 +145,100 @@ export interface BetaCacheControlEphemeral {
   type: 'ephemeral';
 }
 
+export interface BetaCitationCharLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface BetaCitationCharLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface BetaCitationContentBlockLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface BetaCitationContentBlockLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface BetaCitationPageLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface BetaCitationPageLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface BetaCitationsConfigParam {
+  enabled?: boolean;
+}
+
+export interface BetaCitationsDelta {
+  citation: BetaCitationCharLocation | BetaCitationPageLocation | BetaCitationContentBlockLocation;
+
+  type: 'citations_delta';
+}
+
 export type BetaContentBlock = BetaTextBlock | BetaToolUseBlock;
 
 export type BetaContentBlockParam =
@@ -148,6 +248,14 @@ export type BetaContentBlockParam =
   | BetaToolResultBlockParam
   | BetaBase64PDFBlock;
 
+export interface BetaContentBlockSource {
+  content: string | Array<BetaContentBlockSourceContent>;
+
+  type: 'content';
+}
+
+export type BetaContentBlockSourceContent = BetaTextBlockParam | BetaImageBlockParam;
+
 export interface BetaImageBlockParam {
   source: BetaImageBlockParam.Source;
 
@@ -309,8 +417,16 @@ export interface BetaMetadata {
   user_id?: string | null;
 }
 
+export interface BetaPlainTextSource {
+  data: string;
+
+  media_type: 'text/plain';
+
+  type: 'text';
+}
+
 export interface BetaRawContentBlockDeltaEvent {
-  delta: BetaTextDelta | BetaInputJSONDelta;
+  delta: BetaTextDelta | BetaInputJSONDelta | BetaCitationsDelta;
 
   index: number;
 
@@ -380,6 +496,15 @@ export type BetaRawMessageStreamEvent =
   | BetaRawContentBlockStopEvent;
 
 export interface BetaTextBlock {
+  /**
+   * Citations supporting the text block.
+   *
+   * The type of citation returned will depend on the type of document being cited.
+   * Citing a PDF results in `page_location`, plain text results in `char_location`,
+   * and content document results in `content_block_location`.
+   */
+  citations: Array<BetaTextCitation> | null;
+
   text: string;
 
   type: 'text';
@@ -391,8 +516,20 @@ export interface BetaTextBlockParam {
   type: 'text';
 
   cache_control?: BetaCacheControlEphemeral | null;
+
+  citations?: Array<BetaTextCitationParam> | null;
 }
 
+export type BetaTextCitation =
+  | BetaCitationCharLocation
+  | BetaCitationPageLocation
+  | BetaCitationContentBlockLocation;
+
+export type BetaTextCitationParam =
+  | BetaCitationCharLocationParam
+  | BetaCitationPageLocationParam
+  | BetaCitationContentBlockLocationParam;
+
 export interface BetaTextDelta {
   text: string;
 
@@ -1110,8 +1247,18 @@ export declare namespace Messages {
     type BetaBase64PDFBlock as BetaBase64PDFBlock,
     type BetaBase64PDFSource as BetaBase64PDFSource,
     type BetaCacheControlEphemeral as BetaCacheControlEphemeral,
+    type BetaCitationCharLocation as BetaCitationCharLocation,
+    type BetaCitationCharLocationParam as BetaCitationCharLocationParam,
+    type BetaCitationContentBlockLocation as BetaCitationContentBlockLocation,
+    type BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
+    type BetaCitationPageLocation as BetaCitationPageLocation,
+    type BetaCitationPageLocationParam as BetaCitationPageLocationParam,
+    type BetaCitationsConfigParam as BetaCitationsConfigParam,
+    type BetaCitationsDelta as BetaCitationsDelta,
     type BetaContentBlock as BetaContentBlock,
     type BetaContentBlockParam as BetaContentBlockParam,
+    type BetaContentBlockSource as BetaContentBlockSource,
+    type BetaContentBlockSourceContent as BetaContentBlockSourceContent,
     type BetaImageBlockParam as BetaImageBlockParam,
     type BetaInputJSONDelta as BetaInputJSONDelta,
     type BetaMessage as BetaMessage,
@@ -1119,6 +1266,7 @@ export declare namespace Messages {
     type BetaMessageParam as BetaMessageParam,
     type BetaMessageTokensCount as BetaMessageTokensCount,
     type BetaMetadata as BetaMetadata,
+    type BetaPlainTextSource as BetaPlainTextSource,
     type BetaRawContentBlockDeltaEvent as BetaRawContentBlockDeltaEvent,
     type BetaRawContentBlockStartEvent as BetaRawContentBlockStartEvent,
     type BetaRawContentBlockStopEvent as BetaRawContentBlockStopEvent,
@@ -1128,6 +1276,8 @@ export declare namespace Messages {
     type BetaRawMessageStreamEvent as BetaRawMessageStreamEvent,
     type BetaTextBlock as BetaTextBlock,
     type BetaTextBlockParam as BetaTextBlockParam,
+    type BetaTextCitation as BetaTextCitation,
+    type BetaTextCitationParam as BetaTextCitationParam,
     type BetaTextDelta as BetaTextDelta,
     type BetaTool as BetaTool,
     type BetaToolBash20241022 as BetaToolBash20241022,
diff --git src/resources/index.ts src/resources/index.ts
index 23366973..3d4b385a 100644
--- src/resources/index.ts
+++ src/resources/index.ts
@@ -27,9 +27,19 @@ export {
   Messages,
   type Base64PDFSource,
   type CacheControlEphemeral,
+  type CitationCharLocation,
+  type CitationCharLocationParam,
+  type CitationContentBlockLocation,
+  type CitationContentBlockLocationParam,
+  type CitationPageLocation,
+  type CitationPageLocationParam,
+  type CitationsConfigParam,
+  type CitationsDelta,
   type ContentBlock,
   type ContentBlockDeltaEvent,
   type ContentBlockParam,
+  type ContentBlockSource,
+  type ContentBlockSourceContent,
   type ContentBlockStartEvent,
   type ContentBlockStopEvent,
   type DocumentBlockParam,
@@ -47,6 +57,7 @@ export {
   type MessageTokensCount,
   type Metadata,
   type Model,
+  type PlainTextSource,
   type RawContentBlockDeltaEvent,
   type RawContentBlockStartEvent,
   type RawContentBlockStopEvent,
@@ -56,6 +67,8 @@ export {
   type RawMessageStreamEvent,
   type TextBlock,
   type TextBlockParam,
+  type TextCitation,
+  type TextCitationParam,
   type TextDelta,
   type Tool,
   type ToolChoice,
diff --git src/resources/messages/batches.ts src/resources/messages/batches.ts
index a6b328e2..46bc64ed 100644
--- src/resources/messages/batches.ts
+++ src/resources/messages/batches.ts
@@ -50,9 +50,10 @@ export class Batches extends APIResource {
   }
 
   /**
-   * This endpoint is idempotent and can be used to poll for Message Batch
-   * completion. To access the results of a Message Batch, make a request to the
-   * `results_url` field in the response.
+   * Delete a Message Batch.
+   *
+   * Message Batches can only be deleted once they've finished processing. If you'd
+   * like to delete an in-progress batch, you must first cancel it.
    */
   delete(messageBatchId: string, options?: Core.RequestOptions): Core.APIPromise<DeletedMessageBatch> {
     return this._client.delete(`/v1/messages/batches/${messageBatchId}`, options);
@@ -206,6 +207,10 @@ export interface MessageBatchExpiredResult {
   type: 'expired';
 }
 
+/**
+ * This is a single line in the response `.jsonl` file and does not represent the
+ * response as a whole.
+ */
 export interface MessageBatchIndividualResponse {
   /**
    * Developer-provided ID created for each request in a Message Batch. Useful for
diff --git src/resources/messages/index.ts src/resources/messages/index.ts
index 1c9178ad..2f7a0a7f 100644
--- src/resources/messages/index.ts
+++ src/resources/messages/index.ts
@@ -19,9 +19,19 @@ export {
   Messages,
   type Base64PDFSource,
   type CacheControlEphemeral,
+  type CitationCharLocation,
+  type CitationCharLocationParam,
+  type CitationContentBlockLocation,
+  type CitationContentBlockLocationParam,
+  type CitationPageLocation,
+  type CitationPageLocationParam,
+  type CitationsConfigParam,
+  type CitationsDelta,
   type ContentBlock,
   type ContentBlockDeltaEvent,
   type ContentBlockParam,
+  type ContentBlockSource,
+  type ContentBlockSourceContent,
   type ContentBlockStartEvent,
   type ContentBlockStopEvent,
   type DocumentBlockParam,
@@ -37,6 +47,7 @@ export {
   type MessageTokensCount,
   type Metadata,
   type Model,
+  type PlainTextSource,
   type RawContentBlockDeltaEvent,
   type RawContentBlockStartEvent,
   type RawContentBlockStopEvent,
@@ -46,6 +57,8 @@ export {
   type RawMessageStreamEvent,
   type TextBlock,
   type TextBlockParam,
+  type TextCitation,
+  type TextCitationParam,
   type TextDelta,
   type Tool,
   type ToolChoice,
diff --git src/resources/messages/messages.ts src/resources/messages/messages.ts
index 12cc9b83..f1b4fb8e 100644
--- src/resources/messages/messages.ts
+++ src/resources/messages/messages.ts
@@ -96,6 +96,100 @@ export interface CacheControlEphemeral {
   type: 'ephemeral';
 }
 
+export interface CitationCharLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface CitationCharLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_char_index: number;
+
+  start_char_index: number;
+
+  type: 'char_location';
+}
+
+export interface CitationContentBlockLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface CitationContentBlockLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_block_index: number;
+
+  start_block_index: number;
+
+  type: 'content_block_location';
+}
+
+export interface CitationPageLocation {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface CitationPageLocationParam {
+  cited_text: string;
+
+  document_index: number;
+
+  document_title: string | null;
+
+  end_page_number: number;
+
+  start_page_number: number;
+
+  type: 'page_location';
+}
+
+export interface CitationsConfigParam {
+  enabled?: boolean;
+}
+
+export interface CitationsDelta {
+  citation: CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
+
+  type: 'citations_delta';
+}
+
 export type ContentBlock = TextBlock | ToolUseBlock;
 
 export type ContentBlockDeltaEvent = RawContentBlockDeltaEvent;
@@ -107,16 +201,30 @@ export type ContentBlockParam =
   | ToolResultBlockParam
   | DocumentBlockParam;
 
+export interface ContentBlockSource {
+  content: string | Array<ContentBlockSourceContent>;
+
+  type: 'content';
+}
+
+export type ContentBlockSourceContent = TextBlockParam | ImageBlockParam;
+
 export type ContentBlockStartEvent = RawContentBlockStartEvent;
 
 export type ContentBlockStopEvent = RawContentBlockStopEvent;
 
 export interface DocumentBlockParam {
-  source: Base64PDFSource;
+  source: Base64PDFSource | PlainTextSource | ContentBlockSource;
 
   type: 'document';
 
   cache_control?: CacheControlEphemeral | null;
+
+  citations?: CitationsConfigParam;
+
+  context?: string | null;
+
+  title?: string | null;
 }
 
 export interface ImageBlockParam {
@@ -322,8 +430,16 @@ const DEPRECATED_MODELS: {
   'claude-2.0': 'July 21st, 2025',
 };
 
+export interface PlainTextSource {
+  data: string;
+
+  media_type: 'text/plain';
+
+  type: 'text';
+}
+
 export interface RawContentBlockDeltaEvent {
-  delta: TextDelta | InputJSONDelta;
+  delta: TextDelta | InputJSONDelta | CitationsDelta;
 
   index: number;
 
@@ -393,6 +509,15 @@ export type RawMessageStreamEvent =
   | RawContentBlockStopEvent;
 
 export interface TextBlock {
+  /**
+   * Citations supporting the text block.
+   *
+   * The type of citation returned will depend on the type of document being cited.
+   * Citing a PDF results in `page_location`, plain text results in `char_location`,
+   * and content document results in `content_block_location`.
+   */
+  citations: Array<TextCitation> | null;
+
   text: string;
 
   type: 'text';
@@ -404,8 +529,17 @@ export interface TextBlockParam {
   type: 'text';
 
   cache_control?: CacheControlEphemeral | null;
+
+  citations?: Array<TextCitationParam> | null;
 }
 
+export type TextCitation = CitationCharLocation | CitationPageLocation | CitationContentBlockLocation;
+
+export type TextCitationParam =
+  | CitationCharLocationParam
+  | CitationPageLocationParam
+  | CitationContentBlockLocationParam;
+
 export interface TextDelta {
   text: string;
 
@@ -1069,9 +1203,19 @@ export declare namespace Messages {
   export {
     type Base64PDFSource as Base64PDFSource,
     type CacheControlEphemeral as CacheControlEphemeral,
+    type CitationCharLocation as CitationCharLocation,
+    type CitationCharLocationParam as CitationCharLocationParam,
+    type CitationContentBlockLocation as CitationContentBlockLocation,
+    type CitationContentBlockLocationParam as CitationContentBlockLocationParam,
+    type CitationPageLocation as CitationPageLocation,
+    type CitationPageLocationParam as CitationPageLocationParam,
+    type CitationsConfigParam as CitationsConfigParam,
+    type CitationsDelta as CitationsDelta,
     type ContentBlock as ContentBlock,
     type ContentBlockDeltaEvent as ContentBlockDeltaEvent,
     type ContentBlockParam as ContentBlockParam,
+    type ContentBlockSource as ContentBlockSource,
+    type ContentBlockSourceContent as ContentBlockSourceContent,
     type ContentBlockStartEvent as ContentBlockStartEvent,
     type ContentBlockStopEvent as ContentBlockStopEvent,
     type DocumentBlockParam as DocumentBlockParam,
@@ -1088,6 +1232,7 @@ export declare namespace Messages {
     type MessageTokensCount as MessageTokensCount,
     type Metadata as Metadata,
     type Model as Model,
+    type PlainTextSource as PlainTextSource,
     type RawContentBlockDeltaEvent as RawContentBlockDeltaEvent,
     type RawContentBlockStartEvent as RawContentBlockStartEvent,
     type RawContentBlockStopEvent as RawContentBlockStopEvent,
@@ -1097,6 +1242,8 @@ export declare namespace Messages {
     type RawMessageStreamEvent as RawMessageStreamEvent,
     type TextBlock as TextBlock,
     type TextBlockParam as TextBlockParam,
+    type TextCitation as TextCitation,
+    type TextCitationParam as TextCitationParam,
     type TextDelta as TextDelta,
     type Tool as Tool,
     type ToolChoice as ToolChoice,
diff --git src/streaming.ts src/streaming.ts
index 2eff6ef9..ad1b78e6 100644
--- src/streaming.ts
+++ src/streaming.ts
@@ -1,6 +1,7 @@
 import { ReadableStream, type Response } from './_shims/index';
 import { AnthropicError } from './error';
 import { LineDecoder } from './internal/decoders/line';
+import { ReadableStreamToAsyncIterable } from './internal/stream-utils';
 
 import { createResponseHeaders } from './core';
 import { APIError } from './error';
@@ -98,7 +99,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
     async function* iterLines(): AsyncGenerator<string, void, unknown> {
       const lineDecoder = new LineDecoder();
 
-      const iter = readableStreamAsyncIterable<Bytes>(readableStream);
+      const iter = ReadableStreamToAsyncIterable<Bytes>(readableStream);
       for await (const chunk of iter) {
         for (const line of lineDecoder.decode(chunk)) {
           yield line;
@@ -212,7 +213,7 @@ export async function* _iterSSEMessages(
   const sseDecoder = new SSEDecoder();
   const lineDecoder = new LineDecoder();
 
-  const iter = readableStreamAsyncIterable<Bytes>(response.body);
+  const iter = ReadableStreamToAsyncIterable<Bytes>(response.body);
   for await (const sseChunk of iterSSEChunks(iter)) {
     for (const line of lineDecoder.decode(sseChunk)) {
       const sse = sseDecoder.decode(line);
@@ -365,36 +366,3 @@ function partition(str: string, delimiter: string): [string, string, string] {
 
   return [str, '', ''];
 }
-
-/**
- * Most browsers don't yet have async iterable support for ReadableStream,
- * and Node has a very different way of reading bytes from its "ReadableStream".
- *
- * This polyfill was pulled from https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
- */
-export function readableStreamAsyncIterable<T>(stream: any): AsyncIterableIterator<T> {
-  if (stream[Symbol.asyncIterator]) return stream;
-
-  const reader = stream.getReader();
-  return {
-    async next() {
-      try {
-        const result = await reader.read();
-        if (result?.done) reader.releaseLock(); // release lock when stream becomes closed
-        return result;
-      } catch (e) {
-        reader.releaseLock(); // release lock when stream becomes errored
-        throw e;
-      }
-    },
-    async return() {
-      const cancelPromise = reader.cancel();
-      reader.releaseLock();
-      await cancelPromise;
-      return { done: true, value: undefined };
-    },
-    [Symbol.asyncIterator]() {
-      return this;
-    },
-  };
-}
diff --git src/version.ts src/version.ts
index 3f1d4329..0d285762 100644
--- src/version.ts
+++ src/version.ts
@@ -1 +1 @@
-export const VERSION = '0.35.0'; // x-release-please-version
+export const VERSION = '0.36.3'; // x-release-please-version
diff --git tests/api-resources/MessageStream.test.ts tests/api-resources/MessageStream.test.ts
index 0051d397..21407524 100644
--- tests/api-resources/MessageStream.test.ts
+++ tests/api-resources/MessageStream.test.ts
@@ -22,7 +22,7 @@ async function* messageIterable(message: Message): AsyncGenerator<MessageStreamE
     yield {
       type: 'content_block_start',
       content_block:
-        content.type === 'text' ? { type: 'text', text: '' }
+        content.type === 'text' ? { type: 'text', text: '', citations: null }
         : content.type === 'tool_use' ?
           {
             type: 'tool_use',
@@ -145,7 +145,7 @@ describe('MessageStream class', () => {
         type: 'message',
         id: 'msg_01hhptzfxdaeehfxfv070yb6b8',
         role: 'assistant',
-        content: [{ type: 'text', text: 'Hello there!' }],
+        content: [{ type: 'text', text: 'Hello there!', citations: null }],
         model: 'claude-3-opus-20240229',
         stop_reason: 'end_turn',
         stop_sequence: null,
@@ -221,15 +221,15 @@ describe('MessageStream class', () => {
         },
         {
           "args": [
-            "{"type":"content_block_start","content_block":{"type":"text","text":""},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":""}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"content_block_start","content_block":{"type":"text","text":"","citations":null},"index":0}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":"Hello"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -243,7 +243,7 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":" ther"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello ther"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello ther","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -257,7 +257,7 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_delta","delta":{"type":"text_delta","text":"e!"},"index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequ,ence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
@@ -271,39 +271,39 @@ describe('MessageStream class', () => {
         {
           "args": [
             "{"type":"content_block_stop","index":0}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":null,"stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
-            "{"type":"text","text":"Hello there!"}",
+            "{"type":"text","text":"Hello there!","citations":null}",
           ],
           "type": "contentBlock",
         },
         {
           "args": [
             "{"type":"message_delta","usage":{"output_tokens":6},"delta":{"stop_reason":"end_turn","stop_sequence":null}}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
             "{"type":"message_stop"}",
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "streamEvent",
         },
         {
           "args": [
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "message",
         },
         {
           "args": [
-            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!"}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
+            "{"type":"message","id":"msg_01hhptzfxdaeehfxfv070yb6b8","role":"assistant","content":[{"type":"text","text":"Hello there!","citations":null}],"model":"claude-3-opus-20240229","stop_reason":"end_turn","stop_sequence":null,"usage":{"output_tokens":6,"input_tokens":10,"cache_creation_input_tokens":null,"cache_read_input_tokens":null}}",
           ],
           "type": "finalMessage",
         },
@@ -320,6 +320,7 @@ describe('MessageStream class', () => {
       {
         "content": [
           {
+            "citations": null,
             "text": "Hello there!",
             "type": "text",
           },
@@ -356,7 +357,7 @@ describe('MessageStream class', () => {
         type: 'message',
         id: 'msg_01hhptzfxdaeehfxfv070yb6b8',
         role: 'assistant',
-        content: [{ type: 'text', text: 'Hello there!' }],
+        content: [{ type: 'text', text: 'Hello there!', citations: null }],
         model: 'claude-3-opus-20240229',
         stop_reason: 'end_turn',
         stop_sequence: null,
diff --git tests/api-resources/beta/messages/batches.test.ts tests/api-resources/beta/messages/batches.test.ts
index 98d39506..b91258ea 100644
--- tests/api-resources/beta/messages/batches.test.ts
+++ tests/api-resources/beta/messages/batches.test.ts
@@ -44,7 +44,21 @@ describe('resource batches', () => {
             stop_sequences: ['string'],
             stream: false,
             system: [
-              { text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
+              {
+                text: "Today's date is 2024-06-01.",
+                type: 'text',
+                cache_control: { type: 'ephemeral' },
+                citations: [
+                  {
+                    cited_text: 'cited_text',
+                    document_index: 0,
+                    document_title: 'x',
+                    end_char_index: 0,
+                    start_char_index: 0,
+                    type: 'char_location',
+                  },
+                ],
+              },
             ],
             temperature: 1,
             tool_choice: { type: 'auto', disable_parallel_tool_use: true },
@@ -190,14 +204,16 @@ describe('resource batches', () => {
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options instead of params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options instead of params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.beta.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options and params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options and params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.beta.messages.batches.results(
diff --git tests/api-resources/beta/messages/messages.test.ts tests/api-resources/beta/messages/messages.test.ts
index 493de962..f2f6964b 100644
--- tests/api-resources/beta/messages/messages.test.ts
+++ tests/api-resources/beta/messages/messages.test.ts
@@ -32,7 +32,23 @@ describe('resource messages', () => {
       metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
       stop_sequences: ['string'],
       stream: false,
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       temperature: 1,
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
@@ -74,7 +90,23 @@ describe('resource messages', () => {
     const response = await client.beta.messages.countTokens({
       messages: [{ content: 'string', role: 'user' }],
       model: 'string',
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
         {
diff --git tests/api-resources/messages/batches.test.ts tests/api-resources/messages/batches.test.ts
index 4137fa31..c7239648 100644
--- tests/api-resources/messages/batches.test.ts
+++ tests/api-resources/messages/batches.test.ts
@@ -43,7 +43,21 @@ describe('resource batches', () => {
             metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
             stop_sequences: ['string'],
             system: [
-              { text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } },
+              {
+                text: "Today's date is 2024-06-01.",
+                type: 'text',
+                cache_control: { type: 'ephemeral' },
+                citations: [
+                  {
+                    cited_text: 'cited_text',
+                    document_index: 0,
+                    document_title: 'x',
+                    end_char_index: 0,
+                    start_char_index: 0,
+                    type: 'char_location',
+                  },
+                ],
+              },
             ],
             temperature: 1,
             tool_choice: { type: 'auto', disable_parallel_tool_use: true },
@@ -154,7 +168,8 @@ describe('resource batches', () => {
     ).rejects.toThrow(Anthropic.NotFoundError);
   });
 
-  test('results: request options instead of params are passed correctly', async () => {
+  // Prism doesn't support JSONL responses yet
+  test.skip('results: request options instead of params are passed correctly', async () => {
     // ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
     await expect(
       client.messages.batches.results('message_batch_id', { path: '/_stainless_unknown_path' }),
diff --git tests/api-resources/messages/messages.test.ts tests/api-resources/messages/messages.test.ts
index 7b9d6f96..a5b5d328 100644
--- tests/api-resources/messages/messages.test.ts
+++ tests/api-resources/messages/messages.test.ts
@@ -32,7 +32,23 @@ describe('resource messages', () => {
       metadata: { user_id: '13803d75-b4b5-4c3e-b2a2-6f21399b021b' },
       stop_sequences: ['string'],
       stream: false,
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       temperature: 1,
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
@@ -72,7 +88,23 @@ describe('resource messages', () => {
     const response = await client.messages.countTokens({
       messages: [{ content: 'string', role: 'user' }],
       model: 'string',
-      system: [{ text: "Today's date is 2024-06-01.", type: 'text', cache_control: { type: 'ephemeral' } }],
+      system: [
+        {
+          text: "Today's date is 2024-06-01.",
+          type: 'text',
+          cache_control: { type: 'ephemeral' },
+          citations: [
+            {
+              cited_text: 'cited_text',
+              document_index: 0,
+              document_title: 'x',
+              end_char_index: 0,
+              start_char_index: 0,
+              type: 'char_location',
+            },
+          ],
+        },
+      ],
       tool_choice: { type: 'auto', disable_parallel_tool_use: true },
       tools: [
         {

Description

This PR primarily adds support for citations in the Anthropic TypeScript SDK and includes various internal improvements. The changes enable the SDK to handle citation responses from the API, expose citation-related types, and enhance streaming functionality.

Changes

Changes

  1. Message Handling:
  • Added new citation-related types and interfaces (CitationCharLocation, CitationContentBlockLocation, CitationPageLocation, etc.)
  • Updated TextBlock to include citations array
  • Added citation support in MessageStream and BetaMessageStream
  1. Streaming Improvements:
  • Moved readableStreamAsyncIterable to a separate utility file as ReadableStreamToAsyncIterable
  • Added response property to Stream class for better access to response metadata
  • Enhanced stream event handling for citations
  1. Documentation & Versioning:
  • Version bumped to 0.36.3
  • Updated changelogs with recent changes
  • Updated API documentation with new citation-related types
  1. Code Organization:
  • Moved stream utilities to a dedicated file
  • Added better type checking with checkNever function
  • Updated test cases to include citation scenarios
  1. Package Dependencies:
  • Updated bedrock-sdk and vertex-sdk dependencies
  • Improved version constraint handling in package.json files

The sequence diagram shows how the new citation functionality is integrated into the existing message streaming flow, with citations being processed alongside text content in the stream.```mermaid
sequenceDiagram
participant Client
participant MessageStream
participant TextBlock
participant CitationHandler
participant ReadableStream

Client->>MessageStream: Create stream
MessageStream->>ReadableStream: Initialize stream
loop Stream Processing
    ReadableStream->>MessageStream: Chunk data
    MessageStream->>TextBlock: Process text content
    alt Has Citations
        TextBlock->>CitationHandler: Process citations
        CitationHandler->>TextBlock: Return formatted citations
    end
    MessageStream->>Client: Emit stream event
end
MessageStream->>Client: Complete stream
</details>

<!-- Generated by anthropic.claude-3-5-sonnet-20241022-v2:0 -->

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants