| 1 | import type * as sagemaker from "@distilled.cloud/aws/sagemaker-runtime"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | |
| 5 | /** |
| 6 | * The `InvokeEndpoint` request with the binding-injected `EndpointName` made |
| 7 | * optional: it defaults to the first bound endpoint name and may be |
| 8 | * overridden per call with any of the bound endpoint names (IAM is scoped to |
| 9 | * exactly those). |
| 10 | * |
| 11 | * `Body` is the raw, model-specific inference payload (the container behind |
| 12 | * the endpoint decides the shape) — there is no auto-marshalling. Set |
| 13 | * `ContentType`/`Accept` to match your container's serializer. |
| 14 | */ |
| 15 | export interface InvokeEndpointRequest extends Omit< |
| 16 | sagemaker.InvokeEndpointInput, |
| 17 | "EndpointName" |
| 18 | > { |
| 19 | /** |
| 20 | * The endpoint to run inference on for this call. Must be one of the |
| 21 | * endpoint names the binding was created with. |
| 22 | * @default the first bound endpoint name |
| 23 | */ |
| 24 | EndpointName?: string; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * Runtime binding for `sagemaker:InvokeEndpoint` — run real-time inference |
| 29 | * against a deployed SageMaker endpoint with a model-native request body. |
| 30 | * |
| 31 | * SageMaker Runtime is a pure pay-per-call data-plane API: the endpoint |
| 32 | * itself is provisioned out of band (a deployed SageMaker model/endpoint — |
| 33 | * costly to keep running). The binding takes one or more endpoint names and |
| 34 | * grants the function `sagemaker:InvokeEndpoint` scoped to exactly those |
| 35 | * endpoint ARNs. Pass the request/response bodies as raw bytes — the |
| 36 | * container behind the endpoint owns the payload shape, no marshalling. |
| 37 | * |
| 38 | * ### Invoking an Endpoint |
| 39 | * **Example:** Invoke a Real-Time Endpoint |
| 40 | * ```typescript |
| 41 | * // init |
| 42 | * const invokeEndpoint = yield* AWS.SageMakerRuntime.InvokeEndpoint( |
| 43 | * "my-model-endpoint", |
| 44 | * ); |
| 45 | * |
| 46 | * // runtime — Body is the raw payload the container expects |
| 47 | * const result = yield* invokeEndpoint({ |
| 48 | * ContentType: "application/json", |
| 49 | * Accept: "application/json", |
| 50 | * Body: JSON.stringify({ instances: [[1, 2, 3, 4]] }), |
| 51 | * }); |
| 52 | * const raw = new TextDecoder().decode(result.Body); |
| 53 | * ``` |
| 54 | * |
| 55 | * @binding |
| 56 | */ |
| 57 | export interface InvokeEndpoint extends Binding.Service< |
| 58 | InvokeEndpoint, |
| 59 | "AWS.SageMakerRuntime.InvokeEndpoint", |
| 60 | ( |
| 61 | endpoint: string, |
| 62 | ...additionalEndpoints: string[] |
| 63 | ) => Effect.Effect< |
| 64 | ( |
| 65 | request: InvokeEndpointRequest, |
| 66 | ) => Effect.Effect< |
| 67 | sagemaker.InvokeEndpointOutput, |
| 68 | sagemaker.InvokeEndpointError |
| 69 | > |
| 70 | > |
| 71 | > {} |
| 72 | export const InvokeEndpoint = Binding.Service<InvokeEndpoint>( |
| 73 | "AWS.SageMakerRuntime.InvokeEndpoint", |
| 74 | ); |