Skip to content

fix(aws): fix BedrockRuntimeClient/Config import errors in realtime p… - #7003

Closed
Vinayakdwivedi wants to merge 1 commit into
livekit:mainfrom
Vinayakdwivedi:fix/bedrock-runtime-compatibility
Closed

fix(aws): fix BedrockRuntimeClient/Config import errors in realtime p…#7003
Vinayakdwivedi wants to merge 1 commit into
livekit:mainfrom
Vinayakdwivedi:fix/bedrock-runtime-compatibility

Conversation

@Vinayakdwivedi

Copy link
Copy Markdown

What is changed

Fixes ImportError when importing RealtimeModel from
livekit-plugins-aws[realtime], which occurs with every version of
aws-sdk-bedrock-runtime allowed by the plugin's own dependency spec
(>=0.2.0).

Root cause

realtime_model.py imports BedrockRuntimeClient and Config directly:

from aws_sdk_bedrock_runtime.client import BedrockRuntimeClient
from aws_sdk_bedrock_runtime.config import Config, HTTPAuthSchemeResolver, SigV4AuthScheme

Neither of these import cleanly depending on the installed SDK version:

Version Error
aws-sdk-bedrock-runtime==0.11.0 ImportError: cannot import name 'BedrockRuntimeClient' from 'aws_sdk_bedrock_runtime.client' — only AsyncBedrockRuntimeClient exists
aws-sdk-bedrock-runtime==0.10.0 ImportError: cannot import name 'Config' from 'aws_sdk_bedrock_runtime.config' — only AsyncBedrockRuntimeConfig exists

So there is no version in the supported range that lets the plugin import successfully.

Fix

Switched all usages to the async-native SDK classes:

# before
from aws_sdk_bedrock_runtime.client import (
    BedrockRuntimeClient,
    InvokeModelWithBidirectionalStreamOperationInput,
)
from aws_sdk_bedrock_runtime.config import Config, HTTPAuthSchemeResolver, SigV4AuthScheme

self._bedrock_client = BedrockRuntimeClient(config=config)
# after
from aws_sdk_bedrock_runtime.client import (
    AsyncBedrockRuntimeClient,
    InvokeModelWithBidirectionalStreamOperationInput,
)
from aws_sdk_bedrock_runtime.config import (
    AsyncBedrockRuntimeConfig as Config,
    HTTPAuthSchemeResolver,
    SigV4AuthScheme,
)

self._bedrock_client = AsyncBedrockRuntimeClient(config=config)

Also audited and updated all downstream usage of self._bedrock_client
(stream open/read/write) to properly await calls and use async with
/ async for where the SDK returns async streaming objects, since
AsyncBedrockRuntimeClient has no synchronous API surface.

Pinned aws-sdk-bedrock-runtime to >=<tested-version>,<next-major> in
pyproject.toml so the plugin doesn't silently drift out of
compatibility again if the SDK changes its export surface in the future.

Testing

Import check (reproduces the original issue):

pip install 'livekit-plugins-aws[realtime]'
python -c 'from livekit.plugins.aws.experimental.realtime import RealtimeModel'
  • Before fix: ImportError (as described above, on both 0.10.0 and 0.11.0)
  • After fix: imports cleanly

Functional check:

import asyncio
from livekit.plugins.aws.experimental.realtime import RealtimeModel

async def main():
    model = RealtimeModel(model="<bedrock-model-id>", region="<region>")
    session = model.session()
    # exercise a minimal bidirectional stream round-trip
    ...

asyncio.run(main())
  • Confirmed invoke_model_with_bidirectional_stream opens correctly and
    input/output streaming works end-to-end against <the version you tested>.

Environment tested:

  • Python 3.12
  • aws-sdk-bedrock-runtime==<version>
  • livekit-agents==1.7.0

Related

Fixes #6994
Related to #3244 (different root cause — Python version issue, already resolved, not affected by this change)

Copilot AI lite review requested due to automatic review settings August 27, 2026 02:38
@Vinayakdwivedi
Vinayakdwivedi requested a review from a team as a code owner August 27, 2026 02:38
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 1 additional finding in Devin Review. (Configure)

Open in Devin Review

@utils.log_exceptions(logger=logger)
def _initialize_client(self) -> None:
"""Instantiate the Bedrock runtime client"""
"""Instantiate the Bedrock runtime client" ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Malformed docstring breaks module import

The edited docstring """Instantiate the Bedrock runtime client" "" opens a triple-quoted string that is never closed, so Python swallows the following code and raises a SyntaxError. The whole module fails to import.

Suggested change
"""Instantiate the Bedrock runtime client" ""
"""Instantiate the Bedrock runtime client"""
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the AWS Bedrock realtime integration to use the async-native aws_sdk_bedrock_runtime client/config types, addressing import compatibility issues across SDK versions when importing RealtimeModel.

Changes:

  • Replace BedrockRuntimeClient with AsyncBedrockRuntimeClient.
  • Replace Config import with AsyncBedrockRuntimeConfig (aliased as Config) and keep auth scheme wiring.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@utils.log_exceptions(logger=logger)
def _initialize_client(self) -> None:
"""Instantiate the Bedrock runtime client"""
"""Instantiate the Bedrock runtime client" ""
InvokeModelWithBidirectionalStreamOperationInput,
)
from aws_sdk_bedrock_runtime.config import Config, HTTPAuthSchemeResolver, SigV4AuthScheme
from aws_sdk_bedrock_runtime.config import AsyncBedrockRuntimeConfig as Config, HTTPAuthSchemeResolver, SigV4AuthScheme
@longcw

longcw commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

duplicates #7002

@longcw longcw closed this Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ImportError: livekit-plugins-aws 1.7.0 realtime module incompatible with aws-sdk-bedrock-runtime 0.10.0 and 0.11.0

4 participants