{"id":3137,"library":"mypy-boto3-sagemaker-runtime","title":"mypy-boto3-sagemaker-runtime Type Stubs","description":"This package provides type annotations for the `boto3` SageMaker Runtime service, generated by `mypy-boto3-builder`. It ensures type safety and autocompletion for `boto3.client('sagemaker-runtime')` operations in your Python projects. The library is actively maintained, with frequent releases that align closely with `boto3` and `botocore` updates.","status":"active","version":"1.42.54","language":"en","source_language":"en","source_url":"https://github.com/youtype/mypy_boto3_builder","tags":["aws","boto3","sagemaker","runtime","types","mypy","stubs"],"install":[{"cmd":"pip install mypy-boto3-sagemaker-runtime boto3 mypy","lang":"bash","label":"Install with boto3 and mypy"}],"dependencies":[{"reason":"Provides the runtime functionality that these stubs type-hint.","package":"boto3","optional":false},{"reason":"The static type checker that utilizes these stubs.","package":"mypy","optional":true}],"imports":[{"note":"The primary type for the SageMaker Runtime service client.","symbol":"SagemakerRuntimeClient","correct":"from mypy_boto3_sagemaker_runtime.client import SagemakerRuntimeClient"},{"note":"Type definition for the input parameters of the InvokeEndpoint operation.","symbol":"InvokeEndpointInputRequestTypeDef","correct":"from mypy_boto3_sagemaker_runtime.type_defs import InvokeEndpointInputRequestTypeDef"},{"note":"Type definition for the output of the InvokeEndpoint operation.","symbol":"InvokeEndpointOutputTypeDef","correct":"from mypy_boto3_sagemaker_runtime.type_defs import InvokeEndpointOutputTypeDef"}],"quickstart":{"code":"import boto3\nfrom mypy_boto3_sagemaker_runtime.client import SagemakerRuntimeClient\nfrom mypy_boto3_sagemaker_runtime.type_defs import InvokeEndpointOutputTypeDef\nimport os\n\n# Get a type-hinted SageMaker Runtime client\nclient: SagemakerRuntimeClient = boto3.client(\"sagemaker-runtime\")\n\n# Example: Invoke a SageMaker endpoint\n# For a real use case, replace 'your-endpoint-name' with an actual endpoint\n# and 'application/json' with the correct ContentType for your model.\nendpoint_name = os.environ.get(\"SAGEMAKER_ENDPOINT_NAME\", \"your-endpoint-name\")\ncontent_type = \"application/json\"\nbody = b'{\"instances\": [[1.0, 2.0, 3.0]]}' # Example JSON payload\n\ntry:\n    # The response object is type-hinted by InvokeEndpointOutputTypeDef\n    response: InvokeEndpointOutputTypeDef = client.invoke_endpoint(\n        EndpointName=endpoint_name,\n        ContentType=content_type,\n        Body=body\n    )\n\n    # The 'Body' key in the response is a StreamingBody object\n    response_body = response['Body'].read().decode('utf-8')\n    print(f\"Successfully invoked endpoint '{endpoint_name}'.\")\n    print(f\"Response Status Code: {response['ResponseMetadata']['HTTPStatusCode']}\")\n    print(f\"Response Body: {response_body}\")\n\nexcept client.exceptions.ValidationError as e:\n    print(f\"Validation error: {e}\")\n    print(\"Please ensure 'SAGEMAKER_ENDPOINT_NAME' environment variable is set to a valid endpoint, and 'Body' matches its expected format.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n    print(\"This might happen if the endpoint does not exist or credentials are not configured.\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to version 3.9 or higher.","message":"Python 3.8 support was removed in `mypy-boto3-builder` version 8.12.0 (and consequently for generated stub packages like this one). Projects using Python 3.8 will need to upgrade to Python 3.9+ to use newer versions of these stubs.","severity":"breaking","affected_versions":">=8.12.0"},{"fix":"Review your imports of specific `TypeDef` classes and update their names according to the new, often shorter, conventions. Refer to the `type_defs.pyi` file in the installed package for accurate names.","message":"Type definition naming conventions were changed in `mypy-boto3-builder` version 8.9.0. This might affect direct imports of specific `TypeDef` classes if they previously had redundant suffixes (e.g., `CreateDistributionRequestRequestTypeDef` became `CreateDistributionRequestTypeDef`).","severity":"breaking","affected_versions":">=8.9.0"},{"fix":"Ensure `boto3` is installed in your environment: `pip install boto3`.","message":"This package provides only type stubs. It does not include the `boto3` runtime library itself. `boto3` must be installed separately for your code to run.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Keep your `mypy-boto3-sagemaker-runtime` package version in sync with your `boto3` installation. The package version typically reflects the `boto3` version it types for (e.g., `mypy-boto3-sagemaker-runtime==1.x.y` for `boto3==1.x.y`).","message":"Type stubs are generated against specific `boto3` and `botocore` versions. Mismatches between your installed `mypy-boto3-sagemaker-runtime` version and your `boto3`/`botocore` version can lead to incorrect type hints or `mypy` errors, even if the runtime code functions correctly.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}