Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Cohere ai Cohere python BedrockClientV2 Init

From Leeroopedia
Property Value
Type Implementation
Domain Client Initialization, AWS Bedrock, Pydantic Models
Source Cohere Python SDK
Last Updated 2026-02-15
Implements Principle:Cohere_ai_Cohere_python_Bedrock_Client_Initialization

Overview

Concrete constructor for the AWS Bedrock-specific Cohere client with SigV4 authentication hooks.

Description

BedrockClientV2 extends AwsClientV2, which initializes ClientV2 with a custom httpx.Client configured with event hooks from get_event_hooks(service="bedrock"). The service="bedrock" parameter selects Bedrock-specific URL rewriting.

Code Reference

  • src/cohere/bedrock_client.py Lines L31-49 (BedrockClientV2)
  • src/cohere/aws_client.py Lines L48-76 (AwsClientV2)

Signature

class BedrockClientV2(AwsClientV2):
    def __init__(
        self,
        *,
        aws_access_key: typing.Optional[str] = None,
        aws_secret_key: typing.Optional[str] = None,
        aws_session_token: typing.Optional[str] = None,
        aws_region: typing.Optional[str] = None,
        timeout: typing.Optional[float] = None,
    ):

Import

from cohere import BedrockClientV2

Inputs

  • aws_access_key (Optional[str]) — AWS access key ID
  • aws_secret_key (Optional[str]) — AWS secret access key
  • aws_session_token (Optional[str]) — AWS session token for temporary credentials
  • aws_region (Optional[str]) — AWS region (e.g., "us-east-1")
  • timeout (Optional[float]) — Request timeout in seconds

Outputs

  • Configured BedrockClientV2 with all standard SDK methods routing through Bedrock

Example

from cohere import BedrockClientV2, UserChatMessageV2

bedrock = BedrockClientV2(aws_region="us-east-1")

# Same API as direct Cohere client
response = bedrock.chat(
    model="cohere.command-r-plus-v1:0",
    messages=[UserChatMessageV2(content="Hello from Bedrock!")],
)
print(response.message.content[0].text)

Related

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment