Registry /
type-stubs / mypy-boto3-sagemaker-runtime
Install & Compatibility
Where this runs
tested against v1.43.68 · 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.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 116.4MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 5.9s · import 0.000s · 114MB
114MB installed
● package 114MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
SagemakerRuntimeClient
✓ from mypy_boto3_sagemaker_runtime.client import SagemakerRuntimeClient
The primary type for the SageMaker Runtime service client.
InvokeEndpointInputRequestTypeDef
✓ from mypy_boto3_sagemaker_runtime.type_defs import InvokeEndpointInputRequestTypeDef
Type definition for the input parameters of the InvokeEndpoint operation.
InvokeEndpointOutputTypeDef
✓ from mypy_boto3_sagemaker_runtime.type_defs import InvokeEndpointOutputTypeDef
Type definition for the output of the InvokeEndpoint operation.
Demonstrates how to obtain a type-hinted SageMaker Runtime client and use it to invoke an endpoint. It highlights the use of `SagemakerRuntimeClient` for the client and `InvokeEndpointOutputTypeDef` for the operation's response, ensuring type safety throughout the interaction.
import boto3
from mypy_boto3_sagemaker_runtime.client import SagemakerRuntimeClient
from mypy_boto3_sagemaker_runtime.type_defs import InvokeEndpointOutputTypeDef
import os
# Get a type-hinted SageMaker Runtime client
client: SagemakerRuntimeClient = boto3.client("sagemaker-runtime")
# Example: Invoke a SageMaker endpoint
# For a real use case, replace 'your-endpoint-name' with an actual endpoint
# and 'application/json' with the correct ContentType for your model.
endpoint_name = os.environ.get("SAGEMAKER_ENDPOINT_NAME", "your-endpoint-name")
content_type = "application/json"
body = b'{"instances": [[1.0, 2.0, 3.0]]}' # Example JSON payload
try:
# The response object is type-hinted by InvokeEndpointOutputTypeDef
response: InvokeEndpointOutputTypeDef = client.invoke_endpoint(
EndpointName=endpoint_name,
ContentType=content_type,
Body=body
)
# The 'Body' key in the response is a StreamingBody object
response_body = response['Body'].read().decode('utf-8')
print(f"Successfully invoked endpoint '{endpoint_name}'.")
print(f"Response Status Code: {response['ResponseMetadata']['HTTPStatusCode']}")
print(f"Response Body: {response_body}")
except client.exceptions.ValidationError as e:
print(f"Validation error: {e}")
print("Please ensure 'SAGEMAKER_ENDPOINT_NAME' environment variable is set to a valid endpoint, and 'Body' matches its expected format.")
except Exception as e:
print(f"An unexpected error occurred: {e}")
print("This might happen if the endpoint does not exist or credentials are not configured.")
Upgrade
Version history
1.43.68latest on PyPI · released Aug 10, 2026
Audit
Dependencies
boto3requiredProvides the runtime functionality that these stubs type-hint.
mypyoptionalThe static type checker that utilizes these stubs.