Use this file to discover all available pages before exploring further.
By the end of this tutorial you’ll have a deployable Next.js 15 application that takes a text prompt, calls the Livepeer AI network through a server action, and displays the generated image alongside a history of past generations. The path uses Next.js 15’s App Router and server actions, the @livepeer/ai TypeScript SDK, and the free Cloud Community Gateway from the .This is the Persona 1 builder activation moment: the AI Jobs Quickstart proved the API call works; this tutorial proves it ships. Replace the community gateway with a paid one when you deploy to users.
No API key needed for development. The community gateway accepts unauthenticated POSTs for experimentation; production deployments use a paid gateway with a Bearer token.
The server action runs server-side, which means the gateway call happens on your Next.js host instead of the browser. This keeps any future API key out of client-side bundles and centralises retry logic.
The 'use server' directive at the top marks every export as a server action. Client components can import and call generateImage as if it were a local function; Next.js handles the network round trip.
The action validates the prompt, calls the gateway, and returns a typed result. Validation runs server-side, which means client-side bypass isn’t possible.
useFormStatus reads the submission state of the parent form, which gives the button a pending flag without any extra wiring. The MODELS array maps to the warm models verified in the reference.
The gallery holds generation history in client state. For production, swap the in-memory state for a database or local storage.Save as src/app/components/Gallery.tsx:
unoptimized on the <Image> component skips Next.js’s image optimisation, which is necessary because the gateway returns URLs Next.js can’t proxy through its own _next/image endpoint without remote-pattern configuration.To allow Next.js optimisation instead, add the gateway host to next.config.ts:
The community gateway is shaped for experimentation. Production deployments need four changes.One. Switch to a paid gateway. Set LIVEPEER_GATEWAY_URL to a paid gateway endpoint and add LIVEPEER_API_KEY to the environment. Update the SDK initialisation to pass the key in the auth header.Two. Rate-limit per user. Server actions run on your Next.js host; a malicious client can submit the form in a tight loop. Add a per-IP or per-session limit using a Redis backend or a serverless rate-limit library.Three. Cache and persist. Generation costs money. Cache results by (prompt, modelId, seed) and persist gallery state in a database so users keep their history across sessions.Four. Move large images out of the response path. The gateway returns a hosted URL; download and rehost on your own CDN for control over availability and retention.Full hardening guidance in .
The package needs Node 20 or later for the fetch polyfill it relies on. Confirm node --version and upgrade if needed.
`Gateway call failed: No orchestrator available`
No orchestrator on the network has capacity for the requested model right now. Retry, or fall back to the other warm model from the MODELS array.
Image renders broken in the gallery
Either unoptimized is missing from <Image>, or the gateway host is missing from next.config.tsremotePatterns. Pick one path.
Server action returns 405 in production
Server actions need a runtime that supports them. Vercel, Cloudflare, and Node servers all work; static-only hosts (GitHub Pages, plain S3) don’t. Deploy to a runtime host.
Cold-start delay on first request
The first request to a cold model triggers a 30-second to multi-minute load. Add a loading state in the UI and consider warming the model on app start by sending a dummy request.
You have a deployed Next.js app generating images through Livepeer AI. The same server action pattern works for all nine batch pipelines; swap the endpoint and request body to add image-to-video, audio-to-text, or any other pipeline.
Build the "AI Image Generation App" tutorial as a Next.js App Router project. Create a new app with TypeScript, Tailwind, ESLint, and src/app, install @livepeer/ai, add LIVEPEER_GATEWAY_URL=https://dream-gateway.livepeer.cloud to .env.local, and implement a server action that calls the Livepeer text-to-image endpoint with model_id "SG161222/RealVisXL_V4.0_Lightning". Build a prompt form, client gallery, and page composition exactly as a runnable app. Include error handling for empty prompts, gateway failures, and missing images. Run npm run dev and verify http://localhost:3000 can generate and display an image. Do not require a Livepeer Studio API key for development; keep any production key server-side only.