Skip to content
Effect Days 2026 Get your ticket

AnthropicClient

23 exports Added in v1.0.0 Source

Constructors

make

Added in v1.0.0 Source

Signature

declare const make: (options: {
readonly anthropicVersion?: string;
readonly apiKey?: Redacted.Redacted;
readonly apiUrl?: string;
readonly organizationId?: Redacted.Redacted;
readonly projectId?: Redacted.Redacted;
readonly transformClient?: (client: HttpClient.HttpClient) => HttpClient.HttpClient;
}) => Effect.Effect<Service, never, HttpClient.HttpClient | Scope.Scope>

Context

Signature

declare class AnthropicClient extends any {
constructor();
}

Layers

layer

Added in v1.0.0 Source

Signature

declare function layer(options: {
readonly anthropicVersion?: string;
readonly apiKey?: Redacted<string>;
readonly apiUrl?: string;
readonly transformClient?: (client: HttpClient) => HttpClient;
}): Layer<AnthropicClient, never, HttpClient>

layerConfig

Added in v1.0.0 Source

Signature

declare function layerConfig(options: {
readonly anthropicVersion?: Config<string | undefined>;
readonly apiKey?: Config<Redacted<string> | undefined>;
readonly apiUrl?: Config<string | undefined>;
readonly transformClient?: (client: HttpClient) => HttpClient;
}): Layer<AnthropicClient, ConfigError, HttpClient>

Models

MessageStreamEvent type

Added in v1.0.0 Source

Signature

type MessageStreamEvent = typeof MessageStreamEvent.Type

Service interface

Added in v1.0.0 Source

Represents the interface that the AnthropicClient service provides.

This service abstracts the complexity of communicating with Anthropic's API, providing both high-level text generation methods and low-level HTTP access for advanced use cases.

Signature

interface Service {
readonly client: Client;
readonly createMessage: (options: {
readonly params?: {
[key: string]: any;
};
readonly payload: {
[key: string]: any;
};
}) => Effect<BetaMessage, AiError>;
readonly createMessageStream: (options: {
readonly params?: {
[key: string]: any;
};
readonly payload: Omit<typeof Generated.BetaCreateMessageParams.Encoded, "stream">;
}) => Stream<unknown, AiError>;
readonly streamRequest: <A, I, R>(request: HttpClientRequest, schema: any) => Stream<A, AiError, R>;
}

Schemas

Signature

declare class CitationsDelta extends {
readonly citation: unknown;
readonly type: "citations_delta";
} {
constructor(...args: [props: {
readonly citation: unknown;
readonly type: "citations_delta";
}, options?: MakeOptions]);
}

Signature

declare class ContentBlockDeltaEvent extends {
readonly delta: unknown;
readonly index: number;
readonly type: "content_block_delta";
} {
constructor(...args: [props: {
readonly delta: unknown;
readonly index: number;
readonly type: "content_block_delta";
}, options?: MakeOptions]);
}

Signature

declare class ContentBlockStartEvent extends {
readonly content_block: unknown;
readonly index: number;
readonly type: "content_block_start";
} {
constructor(...args: [props: {
readonly content_block: unknown;
readonly index: number;
readonly type: "content_block_start";
}, options?: MakeOptions]);
}

Signature

declare class ContentBlockStopEvent extends {
readonly index: number;
readonly type: "content_block_stop";
} {
constructor(...args: [props: {
readonly index: number;
readonly type: "content_block_stop";
}, options?: MakeOptions]);
}

ErrorEvent

Added in v1.0.0 Source

Signature

declare class ErrorEvent extends {
readonly error: {
readonly message: string;
readonly type: "invalid_request_error";
};
readonly type: "error";
} {
constructor(...args: [props: {
readonly error: {
readonly message: string;
readonly type: "invalid_request_error";
};
readonly type: "error";
}, options?: MakeOptions]);
}

Signature

declare class InputJsonContentBlockDelta extends {
readonly partial_json: string;
readonly type: "input_json_delta";
} {
constructor(...args: [props: {
readonly partial_json: string;
readonly type: "input_json_delta";
}, options?: MakeOptions]);
}

MessageDelta

Added in v1.0.0 Source

Signature

declare class MessageDelta extends {
[key: string]: any;
} {
[key: string]: any;
constructor(...args: [props?: {
[key: string]: any;
}, options?: MakeOptions]);
}

Signature

declare class MessageDeltaEvent extends {
readonly delta: MessageDelta;
readonly type: "message_delta";
readonly usage: MessageDeltaUsage;
} {
constructor(...args: [props: {
readonly delta: MessageDelta;
readonly type: "message_delta";
readonly usage: MessageDeltaUsage;
}, options?: MakeOptions]);
}

Signature

declare class MessageDeltaUsage extends {
[key: string]: any;
} {
[key: string]: any;
constructor(...args: [props?: {
[key: string]: any;
}, options?: MakeOptions]);
}

Signature

declare class MessageStartEvent extends {
readonly message: BetaMessage;
readonly type: "message_start";
} {
constructor(...args: [props: {
readonly message: BetaMessage;
readonly type: "message_start";
}, options?: MakeOptions]);
}

Signature

declare class MessageStopEvent extends {
readonly type: "message_stop";
} {
constructor(...args: [props: {
readonly type: "message_stop";
}, options?: MakeOptions]);
}

Signature

declare const MessageStreamEvent: Union<readonly Array<Constraint>>

PingEvent

Added in v1.0.0 Source

Signature

declare class PingEvent extends {
readonly type: "ping";
} {
constructor(...args: [props: {
readonly type: "ping";
}, options?: MakeOptions]);
}

Signature

declare class ServerToolUsage extends {
[key: string]: any;
} {
[key: string]: any;
constructor(...args: [props?: {
[key: string]: any;
}, options?: MakeOptions]);
}

Signature

declare class SignatureContentBlockDelta extends {
readonly signature: string;
readonly type: "signature_delta";
} {
constructor(...args: [props: {
readonly signature: string;
readonly type: "signature_delta";
}, options?: MakeOptions]);
}

Signature

declare class TextContentBlockDelta extends {
readonly text: string;
readonly type: "text_delta";
} {
constructor(...args: [props: {
readonly text: string;
readonly type: "text_delta";
}, options?: MakeOptions]);
}

Signature

declare class ThinkingContentBlockDelta extends {
readonly thinking: string;
readonly type: "thinking_delta";
} {
constructor(...args: [props: {
readonly thinking: string;
readonly type: "thinking_delta";
}, options?: MakeOptions]);
}