You will need to install Node.js on your machine, version 10 or higher. Important - Installing Node.js will also install npm, the package manager for Node.js.
Using Homebrew:
brew install node
$ node --version
v18.18.1
$ npm --version
9.8.1
- Visual Studio Code - VSCode is our preferred IDE
- WebStorm
- Sublime
- iTerm
Introduction to Cloudinary's Generative AI Transformations
- Run code from root directory, like so:
node <file_name.js >
-
If you don't have one already, create a free Cloudinary account at: https://www.cloudinary.com/signup.
-
Navigate to your Product Environment Settings. Then click API Keys. Copy the
CLOUDINARY_URL
into your clipboard (see yellow arrow pointing to a clipboard).
-
Create a
.env
file in the root of the project. Paste the CLOUDINARY_URL environment variable into your.env
file. -
After you've copy and pasted the provided format, substitute your actual values for the placeholders.
-
Example of a copied CLOUDINARY_URL:
CLOUDINARY_URL=cloudinary://<your_api_key>:<your_api_secret>@jen-brissman
-
Your own cloud name will be automatically copied for you, so just replace <your_api_key> with your API Key and <your_api_secret> with your API Secret.
-
There should be one line of code in your .env file, which should look like this:
CLOUDINARY_URL=cloudinary://YOUR_API_KEY:YOUR_API_SECRET@YOUR_CLOUD_NAME
-
Doing this step properly is essential, as it will let Cloudinary know who you are and provide access to your cloud.
-
Note: Keep your API Secret private. Treat it like a password. You can always regenerate a new API Key if you'd like.
npm i
(You will be using the cloudinary
and the dotenv
libraries.)
node testCredentials.js
The output should look like this:
your Cloud Name
your API Key
- Your API_SECRET is part of your CLOUDINARY_URL
- Remember to always keep your API_SECRET a secret!
- This is why we programmed testCredentials.js to only output your cloud name and API Key (no need to keep these two credentials private)
In order to upload all of the assets associated with these code examples and assign the correct Public ID to each, run this file:
node upload.js
Now you're ready to get started!