Skip to content

Template app using Cloudflare Workers, Hono, and Replicate to generate images using Flux Schnell

Notifications You must be signed in to change notification settings

replicate/getting-started-cloudflare-workers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting started with Cloudflare Workers and Replicate

This is a template for a simple web app using Cloudflare Workers, Hono, and Replicate to generate images using Flux Schnell, a fast and high-quality open-source image generation model.

🍿 Watch the 60-second demo on YouTube


screenshot

Stack

  • Cloudflare Workers is a serverless platform for building web applications. You can run "serverless" functions in a Node.js-like environment, plus serve static web pages and assets.
  • Hono is a minimalist web framework for building serverless applications. It's built and maintained by Cloudflare.
  • Replicate is a platform for building and running machine learning models.
  • Flux Schnell is a fast and high-quality open-source image generation model, made by the original creators of Stable Diffusion.

Prerequisites

  • Node.js - You'll need a recent version of Node.js installed to run the app locally.
  • Cloudflare account - You'll need a Cloudflare account to deploy the app.
  • Replicate account - You'll need a Replicate account to run the Flux Schnell model.

Getting started

To create a new Cloudflare Workers project using this repo as a template, run this command:

npm create cloudflare@latest -- cloudflare-replicate-demo --template replicate/getting-started-cloudflare-workers

This will run you through an interactive series of prompts to create a new project, create a Git repository, install dependencies, and optionally deploy it to Cloudflare.

Development

To run the app locally, create a Replicate API token and copy it to a .dev.vars file.

Install your dependencies:

npm install

Run local server:

npm run dev

Hit the b key to open the server in your browser.

Deployment

To deploy your app to Cloudflare, you'll need to upload your Replicate API token as a Cloudflare secret:

npx wrangler secret put REPLICATE_API_TOKEN

Then, deploy your app:

npm run deploy

About

Template app using Cloudflare Workers, Hono, and Replicate to generate images using Flux Schnell

Resources

Stars

Watchers

Forks