diff --git a/api.md b/api.md
index 12150d07..b6da31bc 100644
--- a/api.md
+++ b/api.md
@@ -16,6 +16,13 @@ Types:
- MessageStartEvent
- MessageStopEvent
- MessageStreamEvent
+- RawContentBlockDeltaEvent
+- RawContentBlockStartEvent
+- RawContentBlockStopEvent
+- RawMessageDeltaEvent
+- RawMessageStartEvent
+- RawMessageStopEvent
+- RawMessageStreamEvent
- TextBlock
- TextBlockParam
- TextDelta
@@ -35,6 +42,9 @@ Methods:
Types:
- InputJsonDelta
+- RawToolsBetaContentBlockDeltaEvent
+- RawToolsBetaContentBlockStartEvent
+- RawToolsBetaMessageStreamEvent
- Tool
- ToolResultBlockParam
- ToolUseBlock
diff --git a/src/index.ts b/src/index.ts
index 481f800f..ea5552cc 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -249,6 +249,13 @@ export namespace Anthropic {
export import MessageStartEvent = API.MessageStartEvent;
export import MessageStopEvent = API.MessageStopEvent;
export import MessageStreamEvent = API.MessageStreamEvent;
+ export import RawContentBlockDeltaEvent = API.RawContentBlockDeltaEvent;
+ export import RawContentBlockStartEvent = API.RawContentBlockStartEvent;
+ export import RawContentBlockStopEvent = API.RawContentBlockStopEvent;
+ export import RawMessageDeltaEvent = API.RawMessageDeltaEvent;
+ export import RawMessageStartEvent = API.RawMessageStartEvent;
+ export import RawMessageStopEvent = API.RawMessageStopEvent;
+ export import RawMessageStreamEvent = API.RawMessageStreamEvent;
export import TextBlock = API.TextBlock;
export import TextBlockParam = API.TextBlockParam;
export import TextDelta = API.TextDelta;
diff --git a/src/resources/beta/tools/index.ts b/src/resources/beta/tools/index.ts
index fb831369..7a43efaa 100644
--- a/src/resources/beta/tools/index.ts
+++ b/src/resources/beta/tools/index.ts
@@ -2,6 +2,9 @@
export {
InputJsonDelta,
+ RawToolsBetaContentBlockDeltaEvent,
+ RawToolsBetaContentBlockStartEvent,
+ RawToolsBetaMessageStreamEvent,
Tool,
ToolResultBlockParam,
ToolUseBlock,
diff --git a/src/resources/beta/tools/messages.ts b/src/resources/beta/tools/messages.ts
index 8be4ba82..31269911 100644
--- a/src/resources/beta/tools/messages.ts
+++ b/src/resources/beta/tools/messages.ts
@@ -23,22 +23,22 @@ export class Messages extends APIResource {
create(
body: MessageCreateParamsStreaming,
options?: Core.RequestOptions,
- ): APIPromise>;
+ ): APIPromise>;
create(
body: MessageCreateParamsBase,
options?: Core.RequestOptions,
- ): APIPromise | ToolsBetaMessage>;
+ ): APIPromise | ToolsBetaMessage>;
create(
body: MessageCreateParams,
options?: Core.RequestOptions,
- ): APIPromise | APIPromise> {
+ ): APIPromise | APIPromise> {
return this._client.post('/v1/messages?beta=tools', {
body,
timeout: 600000,
...options,
headers: { 'anthropic-beta': 'tools-2024-05-16', ...options?.headers },
stream: body.stream ?? false,
- }) as APIPromise | APIPromise>;
+ }) as APIPromise | APIPromise>;
}
/**
@@ -55,6 +55,30 @@ export interface InputJsonDelta {
type: 'input_json_delta';
}
+export interface RawToolsBetaContentBlockDeltaEvent {
+ delta: MessagesAPI.TextDelta | InputJsonDelta;
+
+ index: number;
+
+ type: 'content_block_delta';
+}
+
+export interface RawToolsBetaContentBlockStartEvent {
+ content_block: MessagesAPI.TextBlock | ToolUseBlock;
+
+ index: number;
+
+ type: 'content_block_start';
+}
+
+export type RawToolsBetaMessageStreamEvent =
+ | MessagesAPI.RawMessageStartEvent
+ | MessagesAPI.RawMessageDeltaEvent
+ | MessagesAPI.RawMessageStopEvent
+ | RawToolsBetaContentBlockStartEvent
+ | RawToolsBetaContentBlockDeltaEvent
+ | MessagesAPI.RawContentBlockStopEvent;
+
export interface Tool {
/**
* [JSON schema](https://json-schema.org/) for this tool's input.
@@ -124,21 +148,9 @@ export interface ToolUseBlockParam {
export type ToolsBetaContentBlock = MessagesAPI.TextBlock | ToolUseBlock;
-export interface ToolsBetaContentBlockDeltaEvent {
- delta: MessagesAPI.TextDelta | InputJsonDelta;
-
- index: number;
-
- type: 'content_block_delta';
-}
+export type ToolsBetaContentBlockDeltaEvent = RawToolsBetaContentBlockDeltaEvent;
-export interface ToolsBetaContentBlockStartEvent {
- content_block: MessagesAPI.TextBlock | ToolUseBlock;
-
- index: number;
-
- type: 'content_block_start';
-}
+export type ToolsBetaContentBlockStartEvent = RawToolsBetaContentBlockStartEvent;
export interface ToolsBetaMessage {
/**
@@ -253,13 +265,7 @@ export interface ToolsBetaMessageParam {
role: 'user' | 'assistant';
}
-export type ToolsBetaMessageStreamEvent =
- | MessagesAPI.MessageStartEvent
- | MessagesAPI.MessageDeltaEvent
- | MessagesAPI.MessageStopEvent
- | ToolsBetaContentBlockStartEvent
- | ToolsBetaContentBlockDeltaEvent
- | MessagesAPI.ContentBlockStopEvent;
+export type ToolsBetaMessageStreamEvent = RawToolsBetaMessageStreamEvent;
export type MessageCreateParams = MessageCreateParamsNonStreaming | MessageCreateParamsStreaming;
@@ -890,6 +896,9 @@ export namespace MessageStreamParams {
export namespace Messages {
export import InputJsonDelta = ToolsMessagesAPI.InputJsonDelta;
+ export import RawToolsBetaContentBlockDeltaEvent = ToolsMessagesAPI.RawToolsBetaContentBlockDeltaEvent;
+ export import RawToolsBetaContentBlockStartEvent = ToolsMessagesAPI.RawToolsBetaContentBlockStartEvent;
+ export import RawToolsBetaMessageStreamEvent = ToolsMessagesAPI.RawToolsBetaMessageStreamEvent;
export import Tool = ToolsMessagesAPI.Tool;
export import ToolResultBlockParam = ToolsMessagesAPI.ToolResultBlockParam;
export import ToolUseBlock = ToolsMessagesAPI.ToolUseBlock;
diff --git a/src/resources/beta/tools/tools.ts b/src/resources/beta/tools/tools.ts
index f3bd8009..6522ce69 100644
--- a/src/resources/beta/tools/tools.ts
+++ b/src/resources/beta/tools/tools.ts
@@ -10,6 +10,9 @@ export class Tools extends APIResource {
export namespace Tools {
export import Messages = MessagesAPI.Messages;
export import InputJsonDelta = MessagesAPI.InputJsonDelta;
+ export import RawToolsBetaContentBlockDeltaEvent = MessagesAPI.RawToolsBetaContentBlockDeltaEvent;
+ export import RawToolsBetaContentBlockStartEvent = MessagesAPI.RawToolsBetaContentBlockStartEvent;
+ export import RawToolsBetaMessageStreamEvent = MessagesAPI.RawToolsBetaMessageStreamEvent;
export import Tool = MessagesAPI.Tool;
export import ToolResultBlockParam = MessagesAPI.ToolResultBlockParam;
export import ToolUseBlock = MessagesAPI.ToolUseBlock;
diff --git a/src/resources/index.ts b/src/resources/index.ts
index 360cb01e..8a2302f3 100644
--- a/src/resources/index.ts
+++ b/src/resources/index.ts
@@ -21,6 +21,13 @@ export {
MessageStartEvent,
MessageStopEvent,
MessageStreamEvent,
+ RawContentBlockDeltaEvent,
+ RawContentBlockStartEvent,
+ RawContentBlockStopEvent,
+ RawMessageDeltaEvent,
+ RawMessageStartEvent,
+ RawMessageStopEvent,
+ RawMessageStreamEvent,
TextBlock,
TextBlockParam,
TextDelta,
diff --git a/src/resources/messages.ts b/src/resources/messages.ts
index 9fa36f14..439e3bdc 100644
--- a/src/resources/messages.ts
+++ b/src/resources/messages.ts
@@ -22,21 +22,21 @@ export class Messages extends APIResource {
create(
body: MessageCreateParamsStreaming,
options?: Core.RequestOptions,
- ): APIPromise>;
+ ): APIPromise>;
create(
body: MessageCreateParamsBase,
options?: Core.RequestOptions,
- ): APIPromise | Message>;
+ ): APIPromise | Message>;
create(
body: MessageCreateParams,
options?: Core.RequestOptions,
- ): APIPromise | APIPromise> {
+ ): APIPromise | APIPromise> {
return this._client.post('/v1/messages', {
body,
timeout: 600000,
...options,
stream: body.stream ?? false,
- }) as APIPromise | APIPromise>;
+ }) as APIPromise | APIPromise>;
}
/**
@@ -49,27 +49,11 @@ export class Messages extends APIResource {
export type ContentBlock = TextBlock;
-export interface ContentBlockDeltaEvent {
- delta: TextDelta;
+export type ContentBlockDeltaEvent = RawContentBlockDeltaEvent;
- index: number;
+export type ContentBlockStartEvent = RawContentBlockStartEvent;
- type: 'content_block_delta';
-}
-
-export interface ContentBlockStartEvent {
- content_block: TextBlock;
-
- index: number;
-
- type: 'content_block_start';
-}
-
-export interface ContentBlockStopEvent {
- index: number;
-
- type: 'content_block_stop';
-}
+export type ContentBlockStopEvent = RawContentBlockStopEvent;
export interface ImageBlockParam {
source: ImageBlockParam.Source;
@@ -189,8 +173,51 @@ export interface Message {
usage: Usage;
}
-export interface MessageDeltaEvent {
- delta: MessageDeltaEvent.Delta;
+export type MessageDeltaEvent = RawMessageDeltaEvent;
+
+export interface MessageDeltaUsage {
+ /**
+ * The cumulative number of output tokens which were used.
+ */
+ output_tokens: number;
+}
+
+export interface MessageParam {
+ content: string | Array;
+
+ role: 'user' | 'assistant';
+}
+
+export type MessageStartEvent = RawMessageStartEvent;
+
+export type MessageStopEvent = RawMessageStopEvent;
+
+export type MessageStreamEvent = RawMessageStreamEvent;
+
+export interface RawContentBlockDeltaEvent {
+ delta: TextDelta;
+
+ index: number;
+
+ type: 'content_block_delta';
+}
+
+export interface RawContentBlockStartEvent {
+ content_block: TextBlock;
+
+ index: number;
+
+ type: 'content_block_start';
+}
+
+export interface RawContentBlockStopEvent {
+ index: number;
+
+ type: 'content_block_stop';
+}
+
+export interface RawMessageDeltaEvent {
+ delta: RawMessageDeltaEvent.Delta;
type: 'message_delta';
@@ -211,7 +238,7 @@ export interface MessageDeltaEvent {
usage: MessageDeltaUsage;
}
-export namespace MessageDeltaEvent {
+export namespace RawMessageDeltaEvent {
export interface Delta {
stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | null;
@@ -219,36 +246,23 @@ export namespace MessageDeltaEvent {
}
}
-export interface MessageDeltaUsage {
- /**
- * The cumulative number of output tokens which were used.
- */
- output_tokens: number;
-}
-
-export interface MessageParam {
- content: string | Array;
-
- role: 'user' | 'assistant';
-}
-
-export interface MessageStartEvent {
+export interface RawMessageStartEvent {
message: Message;
type: 'message_start';
}
-export interface MessageStopEvent {
+export interface RawMessageStopEvent {
type: 'message_stop';
}
-export type MessageStreamEvent =
- | MessageStartEvent
- | MessageDeltaEvent
- | MessageStopEvent
- | ContentBlockStartEvent
- | ContentBlockDeltaEvent
- | ContentBlockStopEvent;
+export type RawMessageStreamEvent =
+ | RawMessageStartEvent
+ | RawMessageDeltaEvent
+ | RawMessageStopEvent
+ | RawContentBlockStartEvent
+ | RawContentBlockDeltaEvent
+ | RawContentBlockStopEvent;
export interface TextBlock {
text: string;
@@ -718,6 +732,13 @@ export namespace Messages {
export import MessageStartEvent = MessagesAPI.MessageStartEvent;
export import MessageStopEvent = MessagesAPI.MessageStopEvent;
export import MessageStreamEvent = MessagesAPI.MessageStreamEvent;
+ export import RawContentBlockDeltaEvent = MessagesAPI.RawContentBlockDeltaEvent;
+ export import RawContentBlockStartEvent = MessagesAPI.RawContentBlockStartEvent;
+ export import RawContentBlockStopEvent = MessagesAPI.RawContentBlockStopEvent;
+ export import RawMessageDeltaEvent = MessagesAPI.RawMessageDeltaEvent;
+ export import RawMessageStartEvent = MessagesAPI.RawMessageStartEvent;
+ export import RawMessageStopEvent = MessagesAPI.RawMessageStopEvent;
+ export import RawMessageStreamEvent = MessagesAPI.RawMessageStreamEvent;
export import TextBlock = MessagesAPI.TextBlock;
export import TextBlockParam = MessagesAPI.TextBlockParam;
export import TextDelta = MessagesAPI.TextDelta;