Welcome to the documentation for the awssagemakerruntime library. This library provides functionality for interacting with the AWS SageMaker Runtime API.
If you are new to the AWS SageMaker Runtime API, it is a service that enables you to run inference (predict) on models created and trained with Amazon SageMaker. With this library, you can easily make API calls and process the responses.
Installation
To install the awssagemakerruntime library, you can use a package manager like Cocoapods or Carthage, or manually integrate it into your project. Below are the steps for each method:
Cocoapods
To install using Cocoapods, add the following line to your Podfile:
pod 'AWSSageMakerRuntime'
Then run the command below:
pod install
Carthage
To install using Carthage, add the following line to your Cartfile:
github "awslabs/aws-sdk-ios-sagemakerruntime"
Then run the command below:
carthage update --platform iOS
Manual Integration
If you prefer to manually integrate the library, you can download the latest version from the AWS GitHub repository. Once downloaded, add the following files to your project:
- AWSRuntimeSageMaker.framework
- AWSS3TransferUtility.framework
- libz.tbd
- libresolv.tbd
You also need to ensure that your project includes the necessary frameworks:
- AWSS3.framework
- AWSMobileClient.framework
- AWSNetworking.framework
- AWSCore.framework
- AWSLambda.framework
Usage
With the awssagemakerruntime library installed in your project, you can start using it to make API calls to the AWS SageMaker Runtime API. Below is a basic example:
// Import the library
import AWSSageMakerRuntime
// Create a configuration object with your AWS credentials
let defaultServiceConfiguration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: AWSStaticCredentialsProvider(accessKey: "YOUR_ACCESS_KEY", secretKey: "YOUR_SECRET_KEY"))
// Set the configuration
AWSSageMakerRuntime.register(with: defaultServiceConfiguration!, forKey: "defaultKey")
// Create a request object
let invokeRequest = AWSSageMakerRuntimeInvokeURLRequest()
invokeRequest.endpointUrl = "https://runtime.sagemaker.us-east-1.amazonaws.com/endpoints/endpoint-name/invocations"
invokeRequest.httpMethod = "POST"
invokeRequest.contentType = "application/x-protobuf"
invokeRequest.body = Data()
// Invoke the request asynchronously
AWSSageMakerRuntime(forKey: "defaultKey").invoke(invokeRequest).continueWith { (response) -> Any? in
if let error = response.error {
print("Error: \(error)")
}
if let data = response.result?.body {
// Process the response data
}
return nil
}
In the example above, make sure to replace “YOUR_ACCESS_KEY” and “YOUR_SECRET_KEY” with your actual AWS access key and secret key.
Additional Resources
For more details and advanced usage examples, refer to the official Amazon SageMaker documentation and the GitHub repository for the awssagemakerruntime library.