Skip to content

Conversation

@SamRemis
Copy link
Contributor

This PR adds a new client for the Amazon SageMaker Runtime HTTP2 service.

Summary

Add support for the Amazon SageMaker Runtime HTTP2 service by adding the latest Smithy model and code-generating a new client package (aws-sdk-sagemaker-runtime-http2).

Changes

Testing

  • Change into the transcribe directory: cd clients/aws-sdk-sagemaker-runtime-http2
  • Create a virtual environment:uv venv -p 3.14
  • Activate the virtual environment: source .venv/bin/activate
  • Install the client with uv pip install .
  • Copy AWS creds to my environment (I'm using the EnvironmentCredentialsResolver)
  • Run the following example:
import asyncio

from aws_sdk_sagemaker_runtime_http2.client import SageMakerRuntimeHTTP2Client
from aws_sdk_sagemaker_runtime_http2.config import Config
from aws_sdk_sagemaker_runtime_http2.models import (
    InvokeEndpointWithBidirectionalStreamInput,
    RequestPayloadPart,
    RequestStreamEventPayloadPart,
)
from smithy_aws_core.identity import EnvironmentCredentialsResolver


async def main():
    config = Config(
        endpoint_uri="https://runtime.sagemaker.us-west-2.amazonaws.com:8443",
        region="us-west-2",
        aws_credentials_identity_resolver=EnvironmentCredentialsResolver(),
    )

    client = SageMakerRuntimeHTTP2Client(config=config)
    stream = await client.invoke_endpoint_with_bidirectional_stream(
        InvokeEndpointWithBidirectionalStreamInput(endpoint_name="<bidi-testing-ep>")
    )

    for word in ["lorem", "ipsum", "dolor", "sit", "amet"]:
        payload = RequestPayloadPart(
            bytes_=word.encode("utf-8"), data_type="UTF8", completion_state="COMPLETE"
        )
        event = RequestStreamEventPayloadPart(value=payload)
        await stream.input_stream.send(event)
        await asyncio.sleep(1)

    await stream.input_stream.close()

    output = await stream.await_output()
    output_stream = output[1]

    try:
        while True:
            result = await asyncio.wait_for(output_stream.receive(), timeout=5.0)
            if result is None:
                break
            if result.value and result.value.bytes_:
                print(result.value.bytes_.decode("utf-8"))
    except TimeoutError:
        print("Stream timeout - no more data")


asyncio.run(main())

---

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@SamRemis SamRemis requested a review from a team as a code owner November 21, 2025 22:57
@jonathan343 jonathan343 changed the title Release: Amazon Transcribe Streaming Client Release: SageMaker Runtime HTTP2 Client Nov 21, 2025
Copy link
Contributor

@nateprewitt nateprewitt left a comment

Choose a reason for hiding this comment

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

I think we have two clients published here. Let's remove aws-sdk-bedrock-runtime. We should also update the commit to be Release: SageMaker Runtime HTTP2 Client instead of Release: Transcribe Streaming Client.


### Documentation

<p> The Amazon SageMaker AI runtime HTTP/2 API. </p>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we deleted our README when you did the resync. Can we update that?

@@ -0,0 +1,3 @@
# Code generated by smithy-python-codegen DO NOT EDIT.

__version__: str = "0.1.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an generator issue? We have version here and in the pyproject.toml. I thought this was supposed to be pulled into the other dynamically.

@SamRemis SamRemis force-pushed the release-sagemaker-runtime-http2 branch from 616d763 to 2be0176 Compare November 21, 2025 23:20
@SamRemis SamRemis changed the title Release: SageMaker Runtime HTTP2 Client Release: aws-sdk-sagemaker-runtime v0.1.0 Nov 22, 2025
@SamRemis SamRemis changed the title Release: aws-sdk-sagemaker-runtime v0.1.0 Release: aws-sdk-sagemaker-runtime-http2 v0.1.0 Nov 22, 2025
@SamRemis SamRemis merged commit 12a0f8b into awslabs:develop Nov 22, 2025
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.

2 participants