Skip links
Adobe Firefly Large Action Model, LAM, Adobe, Firefly

Integrating Adobe Firefly with Large Action Models: A Step-by-Step Guide

Adobe Firefly is a powerful tool that enables creative content generation through its generative AI capabilities.

Introduction

Adobe Firefly is a powerful tool that enables creative content generation through its generative AI capabilities. By integrating it with Large Action Models (LAMs), companies can automate and enhance their content creation processes. This guide will take you through the steps to build a Large Action Model and integrate Adobe Firefly API into your workflow.

Prerequisites

Before starting, ensure you have the following:

  • Firefly API credentials (client_id and client_secret)
  • Node.js or Python installed on your machine
  • Basic familiarity with JavaScript or Python

1. Set Up Your Environment

First, set up your development environment.

  1. Create a new script file named firefly.js or firefly.py.
  2. Set your client_id and client_secret as environment variables:
export CLIENT_ID=YOURIDHERE
export CLIENT_SECRET=YOURSECRETHERE
Bash

2. Authentication

To use the Firefly API, you need to authenticate with Adobe’s servers.

  1. Initialize variables using environment variables:
const CLIENT_ID = process.env.CLIENT_ID;
const CLIENT_SECRET = process.env.CLIENT_SECRET;
JavaScript

 

  1. Initialize variables using environment variables:
async function getAccessToken(id, secret) {
  const params = new URLSearchParams();
  params.append('grant_type', 'client_credentials');
  params.append('client_id', id);
  params.append('client_secret', secret);
  params.append('scope', 'openid,AdobeID,session,additional_info,read_organizations,firefly_api,ff_apis');

  let resp = await fetch('https://ims-na1.adobelogin.com/ims/token/v3', {
    method: 'POST',
    body: params
  });
  let data = await resp.json();
  return data.access_token;
}
let token = await getAccessToken(CLIENT_ID, CLIENT_SECRET);
JavaScript

3. Generate an Image with a Prompt

  1. Create a function to call the Firefly Generate Images API:
async function generateImage(prompt, id, token) {
  let body = {
    "numVariations": 4,
    prompt
  }
  let req = await fetch('https://firefly-api.adobe.io/v3/images/generate', {
    method: 'POST',
    headers: {
      'X-Api-Key': id,
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(body)
  });
  return await req.json();
}
JavaScript

2.Execute the API call:

let prompt = 'a cat dancing on a rainbow';
let result = await generateImage(prompt, CLIENT_ID, token);
console.log(JSON.stringify(result, null, '\t'));
JavaScript

4. Download Generated Images

1. Import required modules:

import fs from 'fs';
import { Readable } from 'stream';
import { finished } from 'stream/promises';
JavaScript

2.Create a function to download files:

async function downloadFile(url, filePath) {
  let res = await fetch(url);
  const body = Readable.fromWeb(res.body);
  const download_write_stream = fs.createWriteStream(filePath);
  return await finished(body.pipe(download_write_stream));
}
JavaScript

3.Iterate over results and save images:

for(let output of result.outputs) {
  let fileName = `./${output.seed}.jpg`;
  await downloadFile(output.image.url, fileName);
}
JavaScript

5. Complete Implementation

Combine all the code snippets into a single script file. For Node.js, use the .mjs extension or ensure you have “type”: “module” in your package.json.

6. Run Your Implementation

Execute your script to generate and download images based on your prompt.

node firefly.mjs
Bash

Use Case: Personalized Marketing Campaigns

Scenario

A company wants to create personalized marketing campaigns targeting different customer segments. The goal is to generate unique and engaging visual content for each segment.

Implementation

1.Data Analysis: Use Large Action Models to analyze customer data and segment it based on demographics and preferences.

2.Content Generation: Use Adobe Firefly to create tailored advertisements for each segment.

3.Automation: Integrate LAMs to automate the distribution of these advertisements across various channels.

4.Performance Monitoring: Use LAMs to track the performance of the ads and provide insights for optimization.

Benefits

Increased Engagement: Personalized content resonates more with the target audience, leading to higher engagement.

Efficiency: Automating content creation and distribution saves time and resources.

Improved ROI: Targeted advertisements result in a higher return on investment.

Conclusion

Integrating Adobe Firefly into your company’s workflow can revolutionize your content creation processes. By leveraging Large Action Models, you can automate and enhance these processes, delivering personalized and engaging content to your audience. Follow this guide to build your first implementation and explore further possibilities to maximize the benefits of Adobe Firefly and LAMs.

By following the steps outlined in this blog and exploring the use case, you can successfully integrate Adobe Firefly and unlock its full potential to drive your company’s success.

🍪 This website uses cookies to improve your web experience.