aws_sdk_sagemakerruntime/client/
invoke_endpoint.rs

1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2impl super::Client {
3    /// Constructs a fluent builder for the [`InvokeEndpoint`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder) operation.
4    ///
5    /// - The fluent builder is configurable:
6    ///   - [`endpoint_name(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::endpoint_name) / [`set_endpoint_name(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_endpoint_name):<br>required: **true**<br><p>The name of the endpoint that you specified when you created the endpoint using the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/API_CreateEndpoint.html">CreateEndpoint</a> API.</p><br>
7    ///   - [`body(Blob)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::body) / [`set_body(Option<Blob>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_body):<br>required: **true**<br><p>Provides input data, in the format specified in the <code>ContentType</code> request header. Amazon SageMaker passes all of the data in the body to the model.</p> <p>For information about the format of the request body, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common Data Formats-Inference</a>.</p><br>
8    ///   - [`content_type(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::content_type) / [`set_content_type(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_content_type):<br>required: **false**<br><p>The MIME type of the input data in the request body.</p><br>
9    ///   - [`accept(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::accept) / [`set_accept(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_accept):<br>required: **false**<br><p>The desired MIME type of the inference response from the model container.</p><br>
10    ///   - [`custom_attributes(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::custom_attributes) / [`set_custom_attributes(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_custom_attributes):<br>required: **false**<br><p>Provides additional information about a request for an inference submitted to a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to provide an ID that you can use to track a request or to provide other metadata that a service endpoint was programmed to process. The value must consist of no more than 1024 visible US-ASCII characters as specified in <a href="https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1).</p> <p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID:</code> in your post-processing function.</p> <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK.</p><br>
11    ///   - [`target_model(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::target_model) / [`set_target_model(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_target_model):<br>required: **false**<br><p>The model to request for inference when invoking a multi-model endpoint.</p><br>
12    ///   - [`target_variant(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::target_variant) / [`set_target_variant(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_target_variant):<br>required: **false**<br><p>Specify the production variant to send the inference request to when invoking an endpoint that is running two or more variants. Note that this parameter overrides the default behavior for the endpoint, which is to distribute the invocation traffic based on the variant weights.</p> <p>For information about how to use variant targeting to perform a/b testing, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-ab-testing.html">Test models in production</a></p><br>
13    ///   - [`target_container_hostname(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::target_container_hostname) / [`set_target_container_hostname(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_target_container_hostname):<br>required: **false**<br><p>If the endpoint hosts multiple containers and is configured to use direct invocation, this parameter specifies the host name of the container to invoke.</p><br>
14    ///   - [`inference_id(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::inference_id) / [`set_inference_id(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_inference_id):<br>required: **false**<br><p>If you provide a value, it is added to the captured data when you enable data capture on the endpoint. For information about data capture, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/model-monitor-data-capture.html">Capture Data</a>.</p><br>
15    ///   - [`enable_explanations(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::enable_explanations) / [`set_enable_explanations(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_enable_explanations):<br>required: **false**<br><p>An optional JMESPath expression used to override the <code>EnableExplanations</code> parameter of the <code>ClarifyExplainerConfig</code> API. See the <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-create-endpoint.html#clarify-online-explainability-create-endpoint-enable">EnableExplanations</a> section in the developer guide for more information.</p><br>
16    ///   - [`inference_component_name(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::inference_component_name) / [`set_inference_component_name(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_inference_component_name):<br>required: **false**<br><p>If the endpoint hosts one or more inference components, this parameter specifies the name of inference component to invoke.</p><br>
17    ///   - [`session_id(impl Into<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::session_id) / [`set_session_id(Option<String>)`](crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::set_session_id):<br>required: **false**<br><p>Creates a stateful session or identifies an existing one. You can do one of the following:</p> <ul>  <li>   <p>Create a stateful session by specifying the value <code>NEW_SESSION</code>.</p></li>  <li>   <p>Send your request to an existing stateful session by specifying the ID of that session.</p></li> </ul> <p>With a stateful session, you can send multiple requests to a stateful model. When you create a session with a stateful model, the model must create the session ID and set the expiration time. The model must also provide that information in the response to your request. You can get the ID and timestamp from the <code>NewSessionId</code> response parameter. For any subsequent request where you specify that session ID, SageMaker routes the request to the same instance that supports the session.</p><br>
18    /// - On success, responds with [`InvokeEndpointOutput`](crate::operation::invoke_endpoint::InvokeEndpointOutput) with field(s):
19    ///   - [`body(Option<Blob>)`](crate::operation::invoke_endpoint::InvokeEndpointOutput::body): <p>Includes the inference provided by the model.</p> <p>For information about the format of the response body, see <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html">Common Data Formats-Inference</a>.</p> <p>If the explainer is activated, the body includes the explanations provided by the model. For more information, see the <b>Response section</b> under <a href="https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-online-explainability-invoke-endpoint.html#clarify-online-explainability-response">Invoke the Endpoint</a> in the Developer Guide.</p>
20    ///   - [`content_type(Option<String>)`](crate::operation::invoke_endpoint::InvokeEndpointOutput::content_type): <p>The MIME type of the inference returned from the model container.</p>
21    ///   - [`invoked_production_variant(Option<String>)`](crate::operation::invoke_endpoint::InvokeEndpointOutput::invoked_production_variant): <p>Identifies the production variant that was invoked.</p>
22    ///   - [`custom_attributes(Option<String>)`](crate::operation::invoke_endpoint::InvokeEndpointOutput::custom_attributes): <p>Provides additional information in the response about the inference returned by a model hosted at an Amazon SageMaker endpoint. The information is an opaque value that is forwarded verbatim. You could use this value, for example, to return an ID received in the <code>CustomAttributes</code> header of a request or other metadata that a service endpoint was programmed to produce. The value must consist of no more than 1024 visible US-ASCII characters as specified in <a href="https://tools.ietf.org/html/rfc7230#section-3.2.6">Section 3.3.6. Field Value Components</a> of the Hypertext Transfer Protocol (HTTP/1.1). If the customer wants the custom attribute returned, the model must set the custom attribute to be included on the way back.</p> <p>The code in your model is responsible for setting or updating any custom attributes in the response. If your code does not set this value in the response, an empty value is returned. For example, if a custom attribute represents the trace ID, your model can prepend the custom attribute with <code>Trace ID:</code> in your post-processing function.</p> <p>This feature is currently supported in the Amazon Web Services SDKs but not in the Amazon SageMaker Python SDK.</p>
23    ///   - [`new_session_id(Option<String>)`](crate::operation::invoke_endpoint::InvokeEndpointOutput::new_session_id): <p>If you created a stateful session with your request, the ID and expiration time that the model assigns to that session.</p>
24    ///   - [`closed_session_id(Option<String>)`](crate::operation::invoke_endpoint::InvokeEndpointOutput::closed_session_id): <p>If you closed a stateful session with your request, the ID of that session.</p>
25    /// - On failure, responds with [`SdkError<InvokeEndpointError>`](crate::operation::invoke_endpoint::InvokeEndpointError)
26    pub fn invoke_endpoint(&self) -> crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder {
27        crate::operation::invoke_endpoint::builders::InvokeEndpointFluentBuilder::new(self.handle.clone())
28    }
29}