This project demonstrates how to use Replicate APIs with polling in a Next.js application deployed on Vercel. It's built using the T3 Stack and showcases image generation using Stable Diffusion XL (SDXL).
For a detailed guide on how this project works and how to implement polling with Replicate APIs, check out the tutorial:
Using Replicate APIs in Vercel Without Timeouts: A Guide to Polling
- Image generation using SDXL via Replicate API
- Polling mechanism to handle long-running tasks
- Next.js with App Router
- TypeScript for type safety
- Tailwind CSS for styling
- Clone the repository
- Install dependencies:
npm install
- Set up your environment variables:
- Create a
.env
file in the root directory - Add your Replicate API token:
REPLICATE_API_TOKEN=your_token_here
- Run the development server:
npm run dev
src/app/_components/generate_form.tsx
: Form component for image generationsrc/app/_components/image_generator.tsx
: Main component handling image generation and pollingsrc/app/api/predictions/route.ts
: API route for starting predictionssrc/app/api/predictions/[id]/route.ts
: API route for checking prediction statussrc/app/page.tsx
: Main page componentsrc/app/layout.tsx
: Root layout component
This project is designed to be deployed on Vercel. Make sure to set up your environment variables in your Vercel project settings. Follow our deployment guides for Vercel, Netlify and Docker for more information.
This project is open source and available under the MIT License.