Skip to content

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?: any;
    readonly payload: {
      [key: string]: any;
    };
  }) => Effect<BetaMessage, AiError>;
  readonly createMessageStream: (options: {
    readonly params?: 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 ReadonlySide<{
  readonly citation: Union<readonly Array<Constraint>>;
  readonly type: Literal<"citations_delta">;
}, "Type"> {
  constructor(...args: [props: ReadonlyMakeIn<{
    readonly citation: Union<readonly Array<Constraint>>;
    readonly type: Literal<"citations_delta">;
  }>, options?: MakeOptions]);
}

Signature

declare class ContentBlockDeltaEvent extends ReadonlySide<{
  readonly delta: Union<readonly Array<Constraint>>;
  readonly index: Int;
  readonly type: Literal<"content_block_delta">;
}, "Type"> {
  constructor(...args: [props: ReadonlyMakeIn<{
    readonly delta: Union<readonly Array<Constraint>>;
    readonly index: Int;
    readonly type: Literal<"content_block_delta">;
  }>, options?: MakeOptions]);
}

Signature

declare class ContentBlockStartEvent extends ReadonlySide<Fields, "Type"> {
  [key: string]: unknown;
  [key: number]: unknown;
  [key: symbol]: unknown;
  constructor(...args: [props?: ReadonlyMakeIn<Fields>, options?: MakeOptions]);
}

Signature

declare class ContentBlockStopEvent extends ReadonlySide<
  {
    readonly index: Int;
    readonly type: Literal<"content_block_stop">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly index: Int;
        readonly type: Literal<"content_block_stop">;
      }>,
      options?: MakeOptions,
    ]
  );
}

ErrorEvent

Added in v1.0.0 Source

Signature

declare class ErrorEvent extends ReadonlySide<
  {
    readonly error: Struct<{
      readonly message: String;
      readonly type: Literal<"invalid_request_error">;
    }>;
    readonly type: Literal<"error">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly error: Struct<{
          readonly message: String;
          readonly type: Literal<"invalid_request_error">;
        }>;
        readonly type: Literal<"error">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Signature

declare class InputJsonContentBlockDelta extends ReadonlySide<
  {
    readonly partial_json: String;
    readonly type: Literal<"input_json_delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly partial_json: String;
        readonly type: Literal<"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 ReadonlySide<
  {
    readonly delta: typeof MessageDelta;
    readonly type: Literal<"message_delta">;
    readonly usage: typeof MessageDeltaUsage;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly delta: typeof MessageDelta;
        readonly type: Literal<"message_delta">;
        readonly usage: typeof 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 ReadonlySide<
  {
    readonly message: typeof BetaMessage;
    readonly type: Literal<"message_start">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly message: typeof BetaMessage;
        readonly type: Literal<"message_start">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Signature

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

Signature

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

PingEvent

Added in v1.0.0 Source

Signature

declare class PingEvent extends ReadonlySide<
  {
    readonly type: Literal<"ping">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly type: Literal<"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 ReadonlySide<
  {
    readonly signature: String;
    readonly type: Literal<"signature_delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly signature: String;
        readonly type: Literal<"signature_delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Signature

declare class TextContentBlockDelta extends ReadonlySide<
  {
    readonly text: String;
    readonly type: Literal<"text_delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly text: String;
        readonly type: Literal<"text_delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}

Signature

declare class ThinkingContentBlockDelta extends ReadonlySide<
  {
    readonly thinking: String;
    readonly type: Literal<"thinking_delta">;
  },
  "Type"
> {
  constructor(
    ...args: [
      props: ReadonlyMakeIn<{
        readonly thinking: String;
        readonly type: Literal<"thinking_delta">;
      }>,
      options?: MakeOptions,
    ]
  );
}