Skip to content

Cloudflare Workers

We make it easy to start using Prodia and Cloudflare Workers with easy templates that work directly with npm create cloudflare.

Image Generation

Create a new project using the image generation template:

Terminal window
npm create cloudflare@latest -- image-generation-worker \
--template https://github.com/prodialabs/cloudflare/image-generation-template \
--no-deploy \
--no-git

Change into the project directory.

Terminal window
cd image-generation-worker

Go to your API Dashboard and create a token called Image Generation Worker (Development). We’ll make another one for production in the next step.

Copy the key and paste it into .dev.vars in the following format.

.dev.vars
PRODIA_TOKEN=your_development_key_here

Run the wrangler CLI to start the process of setting your production token.

Terminal window
npx wrangler secret put PRODIA_TOKEN
# ? Enter a secret value: ›

Now go back into your API Dashboard and create a token called Image Generation Worker (Production).

Paste that token into the prompt and press enter.

It will ask if you want to create your worker at the same time. Press enter.

? There doesn't seem to be a Worker called "image-generation-worker". Do you want to create a new Worker with that name and add secrets to it? › (Y/n)

Now you can deploy your worker.

Terminal window
npm run deploy

It will show a link to your deployed worker. Copy and paste it into your browser.

You should see a mountain landscape. Refresh the page to see a different image.