1import type * as sagemaker from "@distilled.cloud/aws/sagemaker-runtime";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4
5/**
6 * The `InvokeEndpointWithResponseStream` request with the binding-injected
7 * `EndpointName` made optional: it defaults to the first bound endpoint name
8 * and may be overridden per call with any of the bound endpoint names.
9 *
10 * `Body` is the raw, model-specific inference payload — there is no
11 * auto-marshalling. The response `Body` is an event `Stream` whose
12 * `PayloadPart` events carry raw model-specific bytes.
13 */
14export interface InvokeEndpointWithResponseStreamRequest extends Omit<
15 sagemaker.InvokeEndpointWithResponseStreamInput,
16 "EndpointName"
17> {
18 /**
19 * The endpoint to run inference on for this call. Must be one of the
20 * endpoint names the binding was created with.
21 * @default the first bound endpoint name
22 */
23 EndpointName?: string;
24}
25
26/**
27 * Runtime binding for `sagemaker:InvokeEndpointWithResponseStream` — the
28 * streaming variant of {@link InvokeEndpoint}. The inference response arrives
29 * incrementally as an event `Stream` of `PayloadPart` events carrying raw
30 * model-specific bytes; the container behind the endpoint must support
31 * inference streaming.
32 *
33 * The binding takes one or more endpoint names and grants the function
34 * `sagemaker:InvokeEndpoint` (the IAM action the streaming operation
35 * authorizes against) scoped to exactly those endpoint ARNs.
36 *
37 * ### Streaming an Endpoint Response
38 * **Example:** Aggregate Streamed Payload Parts
39 * ```typescript
40 * // init
41 * const invokeStream = yield* AWS.SageMakerRuntime.InvokeEndpointWithResponseStream(
42 * "my-streaming-endpoint",
43 * );
44 *
45 * // runtime — Body is the raw payload the container expects
46 * const result = yield* invokeStream({
47 * ContentType: "application/json",
48 * Body: JSON.stringify({ inputs: "Say hello." }),
49 * });
50 * const events = yield* Stream.runCollect(result.Body);
51 * // each PayloadPart's Bytes is a model-specific chunk
52 * ```
53 *
54 * @binding
55 */
56export interface InvokeEndpointWithResponseStream extends Binding.Service<
57 InvokeEndpointWithResponseStream,
58 "AWS.SageMakerRuntime.InvokeEndpointWithResponseStream",
59 (
60 endpoint: string,
61 ...additionalEndpoints: string[]
62 ) => Effect.Effect<
63 (
64 request: InvokeEndpointWithResponseStreamRequest,
65 ) => Effect.Effect<
66 sagemaker.InvokeEndpointWithResponseStreamOutput,
67 sagemaker.InvokeEndpointWithResponseStreamError
68 >
69 >
70> {}
71export const InvokeEndpointWithResponseStream =
72 Binding.Service<InvokeEndpointWithResponseStream>(
73 "AWS.SageMakerRuntime.InvokeEndpointWithResponseStream",
74 );