Skip to content
// EFFECT DAYS 2026

AmazonBedrockClient unstable

The AmazonBedrockClient module defines the low-level Effect service used to call the Amazon Bedrock Runtime Converse API. It wraps an HttpClient with AWS Signature Version 4 signing or Bedrock API key authentication, request defaults, response decoding, event stream decoding and error mapping to the unified AiError type.

Mental model

HttpClient.HttpClient provides the transport, and the Digest and Mac services of effect/crypto provide the SHA-256 and HMAC that SigV4 signing runs on. make turns Options into an AmazonBedrockClient service, while layer and layerConfig provide that service as a layer. The service exposes helpers for the converse and converse-stream endpoints.

7 exports Since v4.0.0 Source

Constructors

make

unstable
Since v4.0.0

Creates an Amazon Bedrock client service with the given options.

Details

The client signs with the Digest and Mac services in its context, so the caller chooses their implementation: the WebCrypto layers of effect/crypto, or the layers of a platform package such as NodeCrypto.layer from @effect/platform-node. They are required for every way of authenticating, although a client with an apiKey never calls them. A CryptoError from the Mac service is a defect.

See

  • layer for providing the client as a Layer from explicit options
  • layerConfig for providing the client as a Layer with Config-based settings

Signature

declare const make: (...args: [options: Options]) => Effect

Layers

layer

unstable
Since v4.0.0

Creates a layer for the Amazon Bedrock client with the given options.

See

  • make for constructing the client service effectfully
  • layerConfig for loading client settings from Config

Signature

declare function layer(options: Options): Layer<AmazonBedrockClient, never, HttpClient | Digest | Mac>

Example Providing the transport and the crypto services

import { AmazonBedrockClient } from "@effect/ai-amazon-bedrock"
import { Layer, Redacted } from "effect"
import { Digest, Mac, SecureRandom } from "effect/crypto"
import { FetchHttpClient } from "effect/http"
const BedrockClient = AmazonBedrockClient.layer({
region: "eu-west-1",
accessKeyId: "AKIAIOSFODNN7EXAMPLE",
secretAccessKey: Redacted.make("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY")
}).pipe(
Layer.provide([
FetchHttpClient.layer,
Digest.layerWebCrypto,
Mac.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))
])
)

layerConfig

unstable
Since v4.0.0

Creates a layer for the Amazon Bedrock client, loading credentials and other settings via Effect's Config module.

Details

Each setting defaults to the environment variable that the AWS tools read: AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN and, for a Bedrock API key, AWS_BEARER_TOKEN_BEDROCK. Every one of them is optional; see Options for which of them are used when several are set.

See

  • layer for providing the client from explicit options instead of Config
  • make for constructing the client service effectfully

Signature

declare function layerConfig(options?: {
readonly accessKeyId?: Config<string | undefined>;
readonly apiKey?: Config<Redacted<string> | undefined>;
readonly apiUrl?: Config<string | undefined>;
readonly credentials?: Effect<Credentials, AiError, never>;
readonly region?: Config<string | undefined>;
readonly secretAccessKey?: Config<Redacted<string> | undefined>;
readonly sessionToken?: Config<Redacted<string> | undefined>;
readonly transformClient?: (client: HttpClient) => HttpClient;
}): Layer<AmazonBedrockClient, ConfigError, HttpClient | Digest | Mac>

Models

Credentials

interface unstable
Since v4.0.0

AWS credentials, in the shape of the AWS SDK's AwsCredentialIdentity, so the SDK's credential providers fit without an adapter.

Signature

interface Credentials {
readonly accessKeyId: string;
readonly secretAccessKey: string;
readonly sessionToken?: string;
}

Options

Options

interface unstable
Since v4.0.0

Configuration for creating an Amazon Bedrock client.

Details

The client authenticates in one of three ways, in this order of precedence:

  • apiKey, a Bedrock API key, sent as Authorization: Bearer <key>.
  • credentials, an effect resolved before every request, signed with SigV4. This is where a credential provider such as fromNodeProviderChain() from @aws-sdk/credential-providers plugs in, wrapped in Effect.promise. To avoid resolving credentials on every request, build the layer inside Layer.unwrap and pass the effect that Effect.cachedWithTTL returns.
  • accessKeyId and secretAccessKey, with an optional sessionToken, signed with SigV4.

Without any of them, every request fails with an AuthenticationError of kind MissingKey.

Signature

interface Options {
readonly accessKeyId?: string;
readonly apiKey?: Redacted<string>;
readonly apiUrl?: string;
readonly credentials?: Effect<Credentials, AiError, never>;
readonly region?: string;
readonly secretAccessKey?: Redacted<string>;
readonly sessionToken?: Redacted<string>;
readonly transformClient?: (client: HttpClient) => HttpClient;
}

Services

Since v4.0.0

Service tag for the Amazon Bedrock client.

See

  • make for constructing a client effectfully
  • layer for providing a client from explicit options
  • layerConfig for providing a client from Config

Signature

declare class AmazonBedrockClient extends Shape<"@effect/ai-amazon-bedrock/AmazonBedrockClient", Service, this> {
constructor(_: never);
}

Service

interface unstable
Since v4.0.0

Represents the Amazon Bedrock client service with methods for the Converse API, including regular and streaming message creation.

Signature

interface Service {
readonly client: With<HttpClientError | AiError>;
readonly converse: (request: {
readonly additionalModelRequestFields?: {
[key: string]: unknown;
};
readonly guardrailConfig?: {
readonly guardrailIdentifier: string;
readonly guardrailVersion: string;
readonly streamProcessingMode?: "sync" | "async";
readonly trace?: "enabled" | "disabled" | "enabled_full";
};
readonly inferenceConfig?: {
readonly maxTokens?: number;
readonly stopSequences?: readonly Array<string>;
readonly temperature?: number;
readonly topP?: number;
};
readonly messages: readonly Array<{
[key: string]: unknown;
readonly content: readonly Array<{
[key: string]: unknown;
readonly cachePoint?: {
readonly ttl?: "5m" | "1h";
readonly type: "default";
};
readonly document?: {
[key: string]: unknown;
readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
readonly name: string;
readonly source: {
[key: string]: unknown;
readonly bytes: string;
};
};
readonly image?: {
[key: string]: unknown;
readonly format: "png" | "jpeg" | "gif" | "webp";
readonly source: {
[key: string]: unknown;
readonly bytes: string;
};
};
readonly reasoningContent?: {
[key: string]: unknown;
readonly reasoningText?: {
[key: string]: unknown;
readonly signature?: ... | ...;
readonly text: string;
};
readonly redactedContent?: string;
};
readonly text?: string;
readonly toolResult?: {
[key: string]: unknown;
readonly content: readonly Array<{
[key: string]: unknown;
readonly json?: unknown;
readonly text?: ... | ...;
}>;
readonly status?: "success" | "error";
readonly toolUseId: string;
};
readonly toolUse?: {
[key: string]: unknown;
readonly input: unknown;
readonly name: string;
readonly toolUseId: string;
};
}>;
readonly role: "user" | "assistant";
}>;
readonly modelId: string;
readonly outputConfig?: {
readonly effort?: string;
readonly textFormat?: {
readonly structure: {
readonly jsonSchema: {
readonly description?: string;
readonly name?: string;
readonly schema: string;
};
};
readonly type: "json_schema";
};
};
readonly system?: readonly Array<{
readonly cachePoint?: {
readonly ttl?: "5m" | "1h";
readonly type: "default";
};
readonly text?: string;
}>;
readonly toolConfig?: {
readonly toolChoice?: {
readonly auto: {};
} | {
readonly any: {};
} | {
readonly tool: {
readonly name: string;
};
};
readonly tools: readonly Array<{
readonly cachePoint?: {
readonly ttl?: "5m" | "1h";
readonly type: "default";
};
readonly toolSpec?: {
readonly description?: string;
readonly inputSchema: {
readonly json: {
[key: string]: unknown;
};
};
readonly name: string;
};
}>;
};
}) => Effect<{
[key: string]: unknown;
readonly metrics?: {
[key: string]: unknown;
readonly latencyMs: number;
};
readonly output: {
[key: string]: unknown;
readonly message: {
[key: string]: unknown;
readonly content: readonly Array<{
[key: string]: unknown;
readonly cachePoint?: {
readonly ttl?: "5m" | "1h";
readonly type: "default";
};
readonly document?: {
[key: string]: unknown;
readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
readonly name: string;
readonly source: {
[key: string]: unknown;
readonly bytes: string;
};
};
readonly image?: {
[key: string]: unknown;
readonly format: "png" | "jpeg" | "gif" | "webp";
readonly source: {
[key: string]: unknown;
readonly bytes: string;
};
};
readonly reasoningContent?: {
[key: string]: unknown;
readonly reasoningText?: {
[key: ...]: ...;
readonly signature?: ...;
readonly text: ...;
};
readonly redactedContent?: string;
};
readonly text?: string;
readonly toolResult?: {
[key: string]: unknown;
readonly content: readonly Array<{
[key: ...]: ...;
readonly json?: ...;
readonly text?: ...;
}>;
readonly status?: "success" | "error";
readonly toolUseId: string;
};
readonly toolUse?: {
[key: string]: unknown;
readonly input: unknown;
readonly name: string;
readonly toolUseId: string;
};
}>;
readonly role: "user" | "assistant";
};
};
readonly stopReason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence" | "guardrail_intervened" | "content_filtered" | "malformed_model_output" | "malformed_tool_use" | "model_context_window_exceeded" | string & {};
readonly trace?: unknown;
readonly usage: {
[key: string]: unknown;
readonly cacheReadInputTokens?: number;
readonly cacheWriteInputTokens?: number;
readonly inputTokens: number;
readonly outputTokens: number;
readonly totalTokens: number;
};
}, AiError>;
readonly converseStream: (request: {
readonly additionalModelRequestFields?: {
[key: string]: unknown;
};
readonly guardrailConfig?: {
readonly guardrailIdentifier: string;
readonly guardrailVersion: string;
readonly streamProcessingMode?: "sync" | "async";
readonly trace?: "enabled" | "disabled" | "enabled_full";
};
readonly inferenceConfig?: {
readonly maxTokens?: number;
readonly stopSequences?: readonly Array<string>;
readonly temperature?: number;
readonly topP?: number;
};
readonly messages: readonly Array<{
[key: string]: unknown;
readonly content: readonly Array<{
[key: string]: unknown;
readonly cachePoint?: {
readonly ttl?: "5m" | "1h";
readonly type: "default";
};
readonly document?: {
[key: string]: unknown;
readonly format: "pdf" | "csv" | "doc" | "docx" | "xls" | "xlsx" | "html" | "txt" | "md";
readonly name: string;
readonly source: {
[key: string]: unknown;
readonly bytes: string;
};
};
readonly image?: {
[key: string]: unknown;
readonly format: "png" | "jpeg" | "gif" | "webp";
readonly source: {
[key: string]: unknown;
readonly bytes: string;
};
};
readonly reasoningContent?: {
[key: string]: unknown;
readonly reasoningText?: {
[key: string]: unknown;
readonly signature?: ... | ...;
readonly text: string;
};
readonly redactedContent?: string;
};
readonly text?: string;
readonly toolResult?: {
[key: string]: unknown;
readonly content: readonly Array<{
[key: string]: unknown;
readonly json?: unknown;
readonly text?: ... | ...;
}>;
readonly status?: "success" | "error";
readonly toolUseId: string;
};
readonly toolUse?: {
[key: string]: unknown;
readonly input: unknown;
readonly name: string;
readonly toolUseId: string;
};
}>;
readonly role: "user" | "assistant";
}>;
readonly modelId: string;
readonly outputConfig?: {
readonly effort?: string;
readonly textFormat?: {
readonly structure: {
readonly jsonSchema: {
readonly description?: string;
readonly name?: string;
readonly schema: string;
};
};
readonly type: "json_schema";
};
};
readonly system?: readonly Array<{
readonly cachePoint?: {
readonly ttl?: "5m" | "1h";
readonly type: "default";
};
readonly text?: string;
}>;
readonly toolConfig?: {
readonly toolChoice?: {
readonly auto: {};
} | {
readonly any: {};
} | {
readonly tool: {
readonly name: string;
};
};
readonly tools: readonly Array<{
readonly cachePoint?: {
readonly ttl?: "5m" | "1h";
readonly type: "default";
};
readonly toolSpec?: {
readonly description?: string;
readonly inputSchema: {
readonly json: {
[key: string]: unknown;
};
};
readonly name: string;
};
}>;
};
}) => Stream<UnknownConverseStreamEvent | {
readonly messageStart: {
[key: string]: unknown;
readonly role: "user" | "assistant";
};
} | {
readonly contentBlockStart: {
[key: string]: unknown;
readonly contentBlockIndex: number;
readonly start?: {
[key: string]: unknown;
readonly toolUse?: {
[key: string]: unknown;
readonly name: string;
readonly toolUseId: string;
};
};
};
} | {
readonly contentBlockDelta: {
[key: string]: unknown;
readonly contentBlockIndex: number;
readonly delta: {
[key: string]: unknown;
readonly reasoningContent?: {
[key: string]: unknown;
readonly redactedContent?: string;
readonly signature?: string;
readonly text?: string;
};
readonly text?: string;
readonly toolUse?: {
[key: string]: unknown;
readonly input: string;
};
};
};
} | {
readonly contentBlockStop: {
[key: string]: unknown;
readonly contentBlockIndex: number;
};
} | {
readonly messageStop: {
[key: string]: unknown;
readonly stopReason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence" | "guardrail_intervened" | "content_filtered" | "malformed_model_output" | "malformed_tool_use" | "model_context_window_exceeded" | string & {};
};
} | {
readonly metadata: {
[key: string]: unknown;
readonly metrics?: {
[key: string]: unknown;
readonly latencyMs: number;
};
readonly trace?: unknown;
readonly usage: {
[key: string]: unknown;
readonly cacheReadInputTokens?: number;
readonly cacheWriteInputTokens?: number;
readonly inputTokens: number;
readonly outputTokens: number;
readonly totalTokens: number;
};
};
}, AiError>;
}