cayu.providers.bedrock
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
bedrock_billing_identity
Section titled “bedrock_billing_identity”from cayu.providers import bedrock_billing_identityBuild Bedrock evidence inside the provider-specific adapter boundary.
bedrock_billing_identity(*, invoked_model: str, source_region: str | None, resource_type: BedrockResourceType, profile_scope: BedrockProfileScope | None=None, requested_service_tier: str='default', effective_service_tier: str | None=None) -> BillingIdentityRelease source · Runtime guarantees · Capability guides
bedrock_converse_stream_events
Section titled “bedrock_converse_stream_events”from cayu.providers import bedrock_converse_stream_eventsasync bedrock_converse_stream_events(raw_events: AsyncIterator[Mapping[str, Any]]) -> AsyncIterator[ModelStreamEvent]Release source · Runtime guarantees · Capability guides
BedrockAPIError
Section titled “BedrockAPIError”from cayu.providers import BedrockAPIErrorAmazon Bedrock request or stream failure with provider-neutral fields.
Bases: BedrockError, ModelProviderError.
init (method)
Section titled “init (method)”BedrockAPIError.__init__(message: str, *, status_code: int | None=None, error_type: str | None=None, error_code: str | None=None, request_id: str | None=None, retryable: bool | None=None, retry_after_s: float | None=None, response_body: str | None=None) -> Noneerror_payload_fields (method)
Section titled “error_payload_fields (method)”BedrockAPIError.error_payload_fields() -> dict[str, Any]JSON-safe structured fields for model stream error payloads.
Key naming mirrors runtime context-overflow event payloads: the
provider’s own error identity uses the provider_error_* prefix so
it cannot collide with the Python-exception error_type key.
Release source · Runtime guarantees · Capability guides
BedrockContextOverflowError
Section titled “BedrockContextOverflowError”from cayu.providers import BedrockContextOverflowErrorBedrock rejected a request because it exceeded the model context.
Bases: BedrockAPIError, ModelContextOverflowError.
init (method)
Section titled “init (method)”BedrockContextOverflowError.__init__(message: str, *, status_code: int | None=None, error_type: str | None=None, error_code: str | None=None, request_id: str | None=None, response_body: str | None=None) -> Noneerror_payload_fields (method)
Section titled “error_payload_fields (method)”BedrockContextOverflowError.error_payload_fields() -> dict[str, Any]JSON-safe structured fields for model stream error payloads.
Key naming mirrors runtime context-overflow event payloads: the
provider’s own error identity uses the provider_error_* prefix so
it cannot collide with the Python-exception error_type key.
Release source · Runtime guarantees · Capability guides
BedrockError
Section titled “BedrockError”from cayu.providers import BedrockErrorBase error for Amazon Bedrock provider failures.
Bases: RuntimeError.
This type’s implementation and inherited behavior are available in the linked release source.
Release source · Runtime guarantees · Capability guides
BedrockProtocolError
Section titled “BedrockProtocolError”from cayu.providers import BedrockProtocolErrorBedrock returned a stream that violates the Converse contract.
Bases: BedrockError.
This type’s implementation and inherited behavior are available in the linked release source.
Release source · Runtime guarantees · Capability guides
BedrockProvider
Section titled “BedrockProvider”from cayu.providers import BedrockProviderAmazon Bedrock Converse adapter for Cayu’s provider-neutral runtime.
Bases: ModelProvider.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
name |
class attribute |
'bedrock' |
billing_provider_name |
class attribute |
'bedrock' |
usage_dialect |
class attribute |
UsageDialect.ANTHROPIC |
supports_native_structured_output |
bool |
False |
prepare_auxiliary_request (method)
Section titled “prepare_auxiliary_request (method)”BedrockProvider.prepare_auxiliary_request(request: ModelRequest, *, max_output_tokens: int) -> ModelRequeststream_deadlines (property)
Section titled “stream_deadlines (property)”BedrockProvider.stream_deadlines() -> ProviderStreamDeadlinesruntime_stream (method)
Section titled “runtime_stream (method)”BedrockProvider.runtime_stream(request: ModelRequest) -> AsyncIterator[ModelStreamEvent]Open the governed model-attempt stream.
Runtime, application, example, and conformance callers must use this
entrance so normalized semantic and absolute deadlines also guard
opaque custom providers. Transparent provider wrappers must override
this entrance and delegate to the wrapped provider’s runtime_stream;
forwarding only the raw stream hook would add an opaque outer guard
that cannot trust terminal evidence accepted by the wrapped adapter.
execution_profile_identity (property)
Section titled “execution_profile_identity (property)”BedrockProvider.execution_profile_identity() -> ExecutionProfileBehaviorIdentity | NoneOptional application-versioned identity for opaque adapter behavior.
provider_operation_mode (property)
Section titled “provider_operation_mode (property)”BedrockProvider.provider_operation_mode() -> ProviderOperationModeExplicit dispatch mode; capability support alone never enables it.
provider_operations (property)
Section titled “provider_operations (property)”BedrockProvider.provider_operations() -> ProviderOperationAdapter | NoneOptional reconnectable-operation adapter.
Returning None preserves the ordinary synchronous stream path.
Providers opt in explicitly by returning a composed adapter.
context_pressure_profile (property)
Section titled “context_pressure_profile (property)”BedrockProvider.context_pressure_profile() -> ModelContextPressureProfilerequest_cache_policy (method)
Section titled “request_cache_policy (method)”BedrockProvider.request_cache_policy(request: ModelRequest) -> CachePolicy | NoneDescribe the effective provider-visible cache breakpoints, when known.
Implementations must be deterministic, side-effect free, and perform no I/O.
request_cache_projection (method)
Section titled “request_cache_projection (method)”BedrockProvider.request_cache_projection(request: ModelRequest) -> RequestCacheProjection | NoneProject the effective cache policy and provider-selected prefix.
Providers whose message preparation can filter or normalize content should override this hook and return the exact ephemeral prefix through the marker they applied. The default preserves compatibility with policy-only provider extensions and lets the runtime derive a provider-neutral prefix. Implementations must be deterministic, side-effect free, and perform no I/O.
request_footprint_options (method)
Section titled “request_footprint_options (method)”BedrockProvider.request_footprint_options(request: ModelRequest) -> dict[str, Any]request_fingerprint_options (method)
Section titled “request_fingerprint_options (method)”BedrockProvider.request_fingerprint_options(request: ModelRequest) -> dict[str, Any]preflight_model_target (method)
Section titled “preflight_model_target (method)”BedrockProvider.preflight_model_target(*, model: str) -> NoneReject an unavailable provider/model target before runtime mutation.
This side-effect-free hook is called during initial-run admission before the session is created and again immediately before provider dispatch. Ordinary providers need no override. Applications may use it for credential-free inspection placeholders whose live execution must fail with a concrete setup diagnostic.
preflight_thinking (method)
Section titled “preflight_thinking (method)”BedrockProvider.preflight_thinking(*, model: str, thinking: ThinkingConfig | None) -> Nonepreflight_portable_messages (method)
Section titled “preflight_portable_messages (method)”BedrockProvider.preflight_portable_messages(*, model: str, messages: list[Message], tools: list[dict[str, Any]]) -> Nonepreflight_hosted_tools (method)
Section titled “preflight_hosted_tools (method)”BedrockProvider.preflight_hosted_tools(*, model: str, hosted_tools: tuple[OpenAIWebSearch, ...], options: dict[str, Any]) -> NoneReject provider-hosted authority this adapter cannot honor.
This hook is side-effect free and is called before a new session is created. The conservative default rejects every hosted tool so custom providers cannot silently omit registered execution authority.
supports_targeted_tool_projection (method)
Section titled “supports_targeted_tool_projection (method)”BedrockProvider.supports_targeted_tool_projection(*, model: str, protocol: str) -> boolReport an explicitly established provider/model projection capability.
The conservative default is unsupported. Implementations must not infer support from a model-name pattern because provider aliases and compatible endpoints can expose different wire contracts under the same model name.
preflight_targeted_tool_projection (method)
Section titled “preflight_targeted_tool_projection (method)”BedrockProvider.preflight_targeted_tool_projection(*, model: str, protocol: str) -> NoneReject targeted-tool authority that this provider cannot project.
supports_tool_discovery_projection (method)
Section titled “supports_tool_discovery_projection (method)”BedrockProvider.supports_tool_discovery_projection(*, model: str, protocol: str) -> boolReport an explicitly established provider/model discovery capability.
preflight_tool_discovery_projection (method)
Section titled “preflight_tool_discovery_projection (method)”BedrockProvider.preflight_tool_discovery_projection(*, model: str, protocol: str) -> NoneReject discovery authority that this provider cannot project.
billing_identity_for_request (method)
Section titled “billing_identity_for_request (method)”async BedrockProvider.billing_identity_for_request(request: ModelRequest) -> BillingIdentitybilling_identity_for_completion (method)
Section titled “billing_identity_for_completion (method)”BedrockProvider.billing_identity_for_completion(identity: BillingIdentity | None, payload: dict[str, Any]) -> BillingIdentity | Nonepreflight_native_structured_output_schema (method)
Section titled “preflight_native_structured_output_schema (method)”BedrockProvider.preflight_native_structured_output_schema(json_schema: dict[str, Any]) -> NoneOptionally reject a NATIVE structured-output schema this adapter’s provider API would refuse, before any model request is made.
The runtime calls this at every entrance (after the
supports_native_structured_output check, before any session is
created or transitioned) with a caller-owned copy of the schema;
implementations must not mutate it. Adapters should raise
NativeStructuredOutputSchemaInvalid with a path-specific message.
The default accepts everything: adapters without provider-specific
schema rules stay source-compatible.
count_input_tokens (method)
Section titled “count_input_tokens (method)”async BedrockProvider.count_input_tokens(request: ModelRequest) -> InputTokenCountResult | Nonestream (method)
Section titled “stream (method)”async BedrockProvider.stream(request: ModelRequest) -> AsyncIterator[ModelStreamEvent]init (method)
Section titled “init (method)”BedrockProvider.__init__(*, region_name: str | None=None, profile_name: str | None=None, endpoint_url: str | None=None, client: Any | None=None, name: str='bedrock', max_tokens: int=DEFAULT_BEDROCK_MAX_TOKENS, stream_deadlines: ProviderStreamDeadlines | None=None, stream_close_timeout_s: float=DEFAULT_BEDROCK_STREAM_CLOSE_TIMEOUT_SECONDS) -> Noneaclose (method)
Section titled “aclose (method)”async BedrockProvider.aclose() -> NoneRelease source · Runtime guarantees · Capability guides
build_bedrock_converse_payload
Section titled “build_bedrock_converse_payload”from cayu.providers import build_bedrock_converse_payloadbuild_bedrock_converse_payload(request: ModelRequest, *, default_max_tokens: int=DEFAULT_BEDROCK_MAX_TOKENS) -> dict[str, Any]Release source · Runtime guarantees · Capability guides
completed_bedrock_billing_identity
Section titled “completed_bedrock_billing_identity”from cayu.providers import completed_bedrock_billing_identityAttach Bedrock completion evidence inside the provider adapter boundary.
completed_bedrock_billing_identity(requested: BillingIdentity, *, effective_service_tier: str) -> BillingIdentity