0 Create Image Using AI In Rock Shared by Brian Davis, ONE&ALL Church one year ago 13.0 Communications, General Intermediate In this recipe we'll step through the process to add AI image generation to Rock RMS using a workflow. This is a fairly simple workflow that sends an API call to Stability AI which is the same system used in DreamStudio.This recipe is a starting point to show how AI image generation is possible. In the future the recipe will be updated to improve the interface and add functionality to allow upscaling and image variation. Images are currently stored as base64 in the database as a workflow attribute, but updates could be made to store the images in a cloud storage provider.Step 1 : Set Up Stability AI AccountVisit https://platform.stability.ai/account/keysSet Up An Account When PromptedIf redirected after login return to https://platform.stability.ai/account/keysClick on the "Copy to clipboard" button to copy your API KeyStep 2: Import The Workflow Into RockHead over to [YourAdminSite]/admin/power-tools/workflow-import and import the attached workflow. The workflow can also be accessed and downloaded from Github here. Or download the workflow using the button at the bottom of this page. You can find more details about importing a workflow into Rock here.Step 3: Secure your WorkflowSince the workflow will allow access to using your API key I would recommend securing the workflow to only be accessible to a specific group of people that you are comfortable spending tokens. Navigate to the imported workflow and click the padlock to set security.Step 3: Add API Key to WorkflowNavigate to the imported workflow and click "Edit". Find the Action named Send Request to Stability and add your API Key into the first line, replacing the text PLACEAPIKEYHERE and then save your workflow. Save the workflow.Step 4: Run The WorkflowRun the workflow and create your first image!At the time that this recipe was published Stability provides new accounts with 25 free credits which is enough to create about 10 images. Further credits can be purchased at https://platform.stability.ai/account/credits and the overall cost of creating images works out to about 2.5 cents per image.Step 5: Securing Your API Key (Optional)If you would prefer to not store your API Key in the workflow is it possible to store this key in a secured Global attribute instead. I'll detail the method of configuring that attribute and then adding the code to the shortcode to access the attribute value. Special thanks Leah Jennings, Kevin Rutledge and Michael Allen in the RocketChat #API channel for the insights on how to best implement this.Navigate to [YourInternalApplicationRoot]/admin/general/global-attributesClick the "+" Sign at the top right of the list to add a new attributeConfigure the attribute as shown below and click Save. Critical field are listed below.Field Type: Encrypted TextPassword Field: TrueSecure the attribute by clicking the Padlock next to the new attribute and setting the View permissions to Rock Admins only.Click on the attribute and enter your OpenAI Key into the password protected field.Copy the Attribute Id shown on the far left (Highlighted above)Return to your shortcode and replace the {%- assign key = 'YOURAPIKEYPLACEAPIKEYHERE' %} code with:{%- attributevalue where:'AttributeId == YOURATTRIBUTEID' limit:'1' securityenabled:'false' -%} {%- assign key = attributevalue.Value | Decrypt -%} {%- endattributevalue -%}Ensure that 'Rock Entity' is checked in your Enabled Lava Commands in the Lava Run action.The attribute is now stored in an encrypted attribute that can only be accessed by Rock Admins or those with the ability to run entity calls. Download File