Registry /
type-stubs / mypy-boto3-lexv2-runtime
Install & Compatibility
Where this runs
tested against v1.43.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.608s · 53.3MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 5.7s · import 0.565s · 54MB
52MB installed
● package 52MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
LexRuntimeV2Client
✓ from mypy_boto3_lexv2_runtime.client import LexRuntimeV2Client
For explicit type annotations of the boto3 LexRuntimeV2 client.
RecognizeTextRequestTypeDef
✓ from mypy_boto3_lexv2_runtime.type_defs import RecognizeTextRequestTypeDef
For explicit type annotations of the request dictionary for `recognize_text`.
RecognizeTextResponseTypeDef
✓ from mypy_boto3_lexv2_runtime.type_defs import RecognizeTextResponseTypeDef
For explicit type annotations of the response dictionary from `recognize_text`.
This quickstart demonstrates how to initialize a `boto3` LexRuntimeV2 client and perform a `recognize_text` operation with explicit type annotations provided by `mypy-boto3-lexv2-runtime`. It includes `TYPE_CHECKING` guards for runtime performance and `mypy` compatibility, as well as placeholders for necessary AWS LexV2 bot parameters.
import boto3
from typing import TYPE_CHECKING, cast
import os
if TYPE_CHECKING:
from mypy_boto3_lexv2_runtime.client import LexRuntimeV2Client
from mypy_boto3_lexv2_runtime.type_defs import RecognizeTextRequestTypeDef, RecognizeTextResponseTypeDef
# Instantiate boto3 client (type-checked by mypy-boto3-lexv2-runtime)
# Credentials handled automatically by boto3, e.g., via AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY env vars
# or IAM roles.
client = boto3.client("lexv2-runtime")
if TYPE_CHECKING:
client = cast(LexRuntimeV2Client, client)
# Example Lex V2 Runtime operation: recognize_text
# Replace with your actual bot_id, bot_alias_id, locale_id
bot_id = os.environ.get('LEX_BOT_ID', 'YOUR_BOT_ID')
bot_alias_id = os.environ.get('LEX_BOT_ALIAS_ID', 'YOUR_BOT_ALIAS_ID')
locale_id = os.environ.get('LEX_LOCALE_ID', 'en_US')
session_id = 'test_session_id_123'
request_params: RecognizeTextRequestTypeDef = {
'botId': bot_id,
'botAliasId': bot_alias_id,
'localeId': locale_id,
'sessionId': session_id,
'text': 'Hello, I need to book a flight.'
}
try:
response: RecognizeTextResponseTypeDef = client.recognize_text(**request_params)
print("Lex V2 Response:", response)
if response.get('messages'):
print("Bot message:", response['messages'][0]['content'])
except Exception as e:
print(f"Error calling Lex V2: {e}")
# To run mypy: mypy your_script_name.py
Debug
Known issues
breakingPython 3.8 support has been removed. `mypy-boto3-builder` versions 8.12.0 and later (which generated `mypy-boto3-lexv2-runtime` 1.42.3) require Python 3.9 or newer.fixUpgrade your Python environment to 3.9 or higher.
affects: mypy-boto3-builder >= 8.12.0, mypy-boto3-lexv2-runtime >= 1.42.3
breakingBreaking changes to `TypeDef` naming conventions occurred in `mypy-boto3-builder` 8.9.0. Specifically, argument TypeDefs may have shorter names (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`), and `Extra` postfixes moved to the end.fixUpdate your explicit type annotations to match the new `TypeDef` naming conventions if you were affected by these changes. Consult the `mypy_boto3` documentation for the correct TypeDef names.
affects: mypy-boto3-builder >= 8.9.0 (affecting generated stubs for mypy-boto3-lexv2-runtime versions generated by this builder version)
gotchaThese packages provide *only* type stubs. For your Python code to run and interact with AWS services, you must also install the `boto3` library.fixEnsure `boto3` is installed in your environment: `pip install boto3`.
affects: All versions
gotchaFor full IDE auto-completion and static analysis with `mypy`, explicit type annotations for `boto3.client()` calls are often necessary, as Python's type inference might not correctly resolve the specific client type from overloaded `boto3.client` signatures. Using `if TYPE_CHECKING:` with `cast` is a recommended pattern.fixAdd explicit type hints, e.g., `from mypy_boto3_lexv2_runtime.client import LexRuntimeV2Client; client: LexRuntimeV2Client = boto3.client('lexv2-runtime')` or use `cast` within `TYPE_CHECKING` blocks. affects: All versions
gotchaThe version of `mypy-boto3-lexv2-runtime` (e.g., 1.42.3) is typically synchronized with the version of `boto3` it provides types for, not with the `mypy-boto3-builder` version that generated it. This can sometimes cause confusion when correlating releases.fixWhen troubleshooting or upgrading, refer to the `mypy-boto3` documentation for the specific `boto3` version compatibility of each stub package.
affects: All versions
Upgrade
Version history
1.43.0latest on PyPI · released Apr 29, 2026
Audit
Dependencies
boto3requiredRuntime dependency required for the type stubs to be functional. This package only provides types, not the AWS SDK itself.