abstrakt
Models
Featured
Sora 2 Pro
Featured

Sora 2 Pro

OpenAI's most advanced video generation model with photorealistic output and complex scene understanding.

Veo 3.1
New

Veo 3.1

Google DeepMind's flagship video model with exceptional motion consistency and cinematic quality.

Kling 2.6
Popular

Kling 2.6

Latest Kling model with enhanced character consistency, longer duration support, and improved physics.

Active

100+ AI Models

Access the best AI models from multiple providers through one unified API. Switch models without changing code.

Browse all models
Tools
Featured
AI Image Generator
Popular

AI Image Generator

Create stunning images from text descriptions using FLUX, Stable Diffusion, and more.

Text to Video
New

Text to Video

Transform your ideas into cinematic AI videos with Sora, Veo, and Kling models.

Text to Speech

Text to Speech

Convert text to natural-sounding speech with 30+ voices and emotional expression.

Active

20+ AI Tools

Ready-to-use tools for image, video, and audio generation. No code required — just upload and create.

Explore all tools
Tutorials
Featured
Build Your First AI App
Start Here

Build Your First AI App

Your first AI generation in 5 minutes. Set up your API key and create your first image.

Text-to-Image Masterclass

Text-to-Image Masterclass

Master prompting techniques, model selection, and advanced settings for stunning results.

Text-to-Video Fundamentals

Text-to-Video Fundamentals

Learn to create cinematic AI videos with proper motion, pacing, and storytelling.

Active

Learn AI Generation

Step-by-step guides to master AI image, video, and audio creation. From beginner to advanced.

View all tutorials
Sandbox
Docs
TutorialsAdvancedBuilding AI Features with Next.js 16 and Abstrakt
IntermediateUpdated Jan 19, 2026

Building AI Features with Next.js 16 and Abstrakt

Learn how to integrate Abstrakt's AI capabilities into your Next.js 16 application with Server Components, Server Actions, and streaming.

ML
Marcus Lee
Developer Advocate
15 min read

Introduction

Next.js 16 brings powerful features for building AI applications: Server Components for secure API calls, Server Actions for form handling, and streaming for real-time updates.

Setup

npm install next@16 react@19 react-dom@19

Create .env.local:

ABSTRAKT_API_KEY=abs_your_api_key_here

API Client

typescript
// lib/abstrakt.ts
export async function generateImage(prompt: string) {
  const response = await fetch('https://api.abstrakt.one/v1/models/flux-schnell/run', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.ABSTRAKT_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ input: { prompt } }),
  });
  return response.json();
}

Server Components

tsx
// app/generate/page.tsx
export default async function GeneratePage({ searchParams }) {
  if (!searchParams.prompt) return <PromptForm />;
  
  const result = await generateImage(searchParams.prompt);
  return <img src={result.result.images[0].url} alt={searchParams.prompt} />;
}

Server Actions

tsx
// app/actions.ts
'use server'
export async function generateAction(formData: FormData) {
  const prompt = formData.get('prompt') as string;
  const result = await generateImage(prompt);
  return { imageUrl: result.result.images[0].url };
}

// Form component
'use client'
export function GenerateForm() {
  const [state, action, pending] = useActionState(generateAction, null);
  return (
    <form action={action}>
      <input name="prompt" disabled={pending} />
      <button disabled={pending}>{pending ? 'Generating...' : 'Generate'}</button>
      {state?.imageUrl && <img src={state.imageUrl} />}
    </form>
  );
}

Streaming with Suspense

tsx
import { Suspense } from 'react';

export default function Page({ searchParams }) {
  return (
    <Suspense fallback={<div className="animate-pulse" />}>
      <GeneratedImage prompt={searchParams.prompt} />
    </Suspense>
  );
}

Webhook Handler

typescript
// app/api/webhooks/abstrakt/route.ts
export async function POST(request: NextRequest) {
  const body = await request.text();
  const signature = request.headers.get('x-abstrakt-signature');
  
  // Verify signature and process webhook
  const payload = JSON.parse(body);
  if (payload.event === 'job.completed') {
    await handleJobCompleted(payload);
  }
  return NextResponse.json({ received: true });
}
#nextjs#react#server-components#streaming
PreviousMigrating from OpenAI/Replicate to AbstraktNextTesting AI-Powered Features: A Practical Guide
On This Page
  • Introduction
  • Setup
  • API Client
  • Server Components
  • Server Actions
  • Streaming with Suspense
  • Webhook Handler
Related Guides
Node.js Integration

Master async patterns for AI generation in Node.js applications.

Webhook Configuration

Handle async AI jobs with webhook callbacks.

Building an AI SaaS Product from Scratch

Build a complete AI-powered SaaS application step by step.

Was this page helpful?

abstrakt
abstrakt

The unified abstraction layer for the next generation of AI applications. Build faster with any model.

Start Here+
  • Quickstart
  • Get API Key
  • Try Playground
  • View Pricing
Image Tools+
  • AI Image Generator
  • Image to Image
  • Remove Background
  • Image Upscaler
  • Object Remover
  • Style Transfer
  • Image Enhancer
  • AI Art Generator
Video Tools+
  • Text to Video
  • Image to Video
  • AI Video Generator
  • Video Upscaler
  • Video Enhancer
  • Frame Interpolation
Audio Tools+
  • Text to Speech
  • Speech to Text
  • AI Music Generator
  • Voice Cloning
  • Audio Enhancer
  • Sound Effects
Tutorials+
  • Getting Started
  • Image Generation
  • Video Generation
  • Audio Generation
  • Advanced Topics
  • AI Glossary
  • All Tutorials
Models+
  • FLUX Schnell
  • FLUX Dev
  • Fast SDXL
  • Stable Diffusion 3
  • MiniMax Video
  • Kling AI
  • Ideogram
  • More Models
Company+
  • About Us
  • Pricing
  • Documentation
  • Tutorials
  • Blog
  • Contact
  • Changelog
  • Status
  • Careers
  • Privacy Policy
  • Terms of Service
  • Cookie Policy

Image Tools

  • AI Image Generator
  • Image to Image
  • Remove Background
  • Image Upscaler
  • Object Remover
  • Style Transfer
  • Image Enhancer
  • AI Art Generator

Video Tools

  • Text to Video
  • Image to Video
  • AI Video Generator
  • Video Upscaler
  • Video Enhancer
  • Frame Interpolation

Audio Tools

  • Text to Speech
  • Speech to Text
  • AI Music Generator
  • Voice Cloning
  • Audio Enhancer
  • Sound Effects

Tutorials

  • Getting Started
  • Image Generation
  • Video Generation
  • Audio Generation
  • Advanced Topics
  • AI Glossary
  • All Tutorials

Start Here

  • Quickstart
  • Get API Key
  • Try Playground
  • View Pricing

Models

  • FLUX Schnell
  • FLUX Dev
  • Fast SDXL
  • Stable Diffusion 3
  • MiniMax Video
  • Kling AI
  • Ideogram
  • More Models

Company

  • About Us
  • Pricing
  • Documentation
  • Tutorials
  • Blog
  • Contact
  • Changelog
  • Status
  • Careers
  • Privacy Policy
  • Terms of Service
  • Cookie Policy
abstrakt

The unified abstraction layer for the next generation of AI applications.

© 2026 abstrakt. All rights reserved.

SYS.ONLINE|API.ACTIVE|v1.2.0