agents icon indicating copy to clipboard operation
agents copied to clipboard

Can't use Amazon Nova Sonic. I get ImportError: cannot import name 'BedrockRuntimeClient' from 'aws_sdk_bedrock_runtime.client'

Open Kamal-Moha opened this issue 3 months ago • 4 comments

Bug Description

I'm trying to run Amazon Nova Sonic realtime model. I get this error

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/dist-packages/livekit/plugins/aws/__init__.py", line 32, in __getattr__
    from .experimental import realtime
  File "/usr/local/lib/python3.13/dist-packages/livekit/plugins/aws/experimental/realtime/__init__.py", line 1, in <module>
    from .realtime_model import RealtimeModel, RealtimeSession
  File "/usr/local/lib/python3.13/dist-packages/livekit/plugins/aws/experimental/realtime/realtime_model.py", line 18, in <module>
    from aws_sdk_bedrock_runtime.client import (
    ...<2 lines>...
    )

ImportError: cannot import name 'BedrockRuntimeClient' from 'aws_sdk_bedrock_runtime.client' (/usr/local/lib/python3.13/dist-packages/aws_sdk_bedrock_runtime/client.py)

ImportError: The 'realtime' module requires optional dependencies. Please install them with: pip install 'livekit-plugins-aws[realtime]'

Yet I have already installed 'livekit-plugins-aws[realtime]'

Expected Behavior

The nova sonic model should work with this error and the agent should start speaking. All the other realtime models work fine.

Reproduction Steps

Steps to reproduce the behavior:
1. Run the Voice AI Quickstart using Amazon Nova Sonic Realtime model
2. You will get the above error

Operating System

macOs

Models Used

Amazon Nova Sonic RealtimeModel

Package Versions

- Python 3.14
- livekit 1.1.15
- livekit-agents  1.7.1
- livekit-plugins-aws 1.7.1

Session/Room/Call IDs

No response

Proposed Solution


Additional Context

No response

Screenshots and Recordings

Here is a screenshot of my pyproject.toml file

Image

Kamal-Moha avatar Aug 29 '26 22:08 Kamal-Moha

Please assign me this

BUTTERFINGERS7498 avatar Aug 30 '26 22:08 BUTTERFINGERS7498

I checked the current main branch: commit 1c472dd (#7002) updates the Bedrock Runtime imports for aws-sdk-bedrock-runtime 0.10+. The report is using the 1.7.1 wheel, which predates that fix. Could you please cut a patch release containing #7002 and note the supported SDK version in the release notes?

wangyuxy9805-web avatar Aug 31 '26 02:08 wangyuxy9805-web

@wangyuxy9805-web The PR #7002 was merged to main branch. To ensure that I'm using the latest merged code, I cloned the main repo livekit/agents and used that instead.

When I try running the amazon nova sonic model, I get a new error below;

smithy_core.exceptions.UnsupportedTransportError: The configured transport (AIOHTTPClient) does not support duplex (bidirectional) event streaming, which is required by the com.amazonaws.bedrockruntime#InvokeModelWithBidirectionalStream operation. Use a transport that does, such as smithy_http.aio.crt.AWSCRTHTTPClient. Custom transports that support duplex streaming can implement DuplexClientTransport by setting SUPPORTS_DUPLEX_STREAMING to True.

I checked the pyproject.toml and I see that required realtime dependencies are these:

[project.optional-dependencies]
realtime = [
    "aws-sdk-bedrock-runtime>=0.2.0; python_version >= '3.12'",
    "aws-sdk-signers>=0.0.3; python_version >= '3.12'",
    "boto3>1.35.10",
]

Kamal-Moha avatar Sep 01 '26 04:09 Kamal-Moha

@longcw would you consider switching to the capo-bedrock instead? It's more complete, provides a synchronous client, supports Python 3.10, and should generally be more robust

karpetrosyan avatar Nov 06 '26 16:11 karpetrosyan