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:
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.
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.
PRODIA_TOKEN=your_development_key_here
Run the wrangler CLI to start the process of setting your production token.
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.
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.