Amazon Bedrock is used to build an AI-powered chat and image features in Swift for iOS app using serverless resources AWS Lambda and API Gateway for the backend.
The mobile application is built using Swift and integrates the models amazon.titan-image-generator-v1 and ai21.j2-mid-v1.
The serverless backend processing is done using AWS Lambda with TypeScript, while Amazon API Gateway is used for communication and monitoring.
The AI-powered iOS chat app is built using Xcode version 15 and the sample application has included features such as RESTful APIs and Amazon CloudWatch Logs.
To access Amazon Bedrock, the user must log in to an AWS Console, go to Amazon Bedrock, and in the left navigation click on Model access.
The Text Lambda is responsible for importing the client-bedrock-runtime package and adding the modelID.
The Image Lambda is responsible for sending a prompt to the Lambda and processing the response, which is then sent back to the mobile app for display.
The app includes several components: ChatMessage, APIService, BedrockView and App Entry Point.
The API calls may incur a small cost and the use of a token is essential for securing the API.
The source code for this project is available on GitHub for the backend and the iOS app.