Predictions

Replicate-compatible async predictions for image/video/text generation and more

Overview

The Predictions API provides async execution for models from Replicate, a platform for running ML models in the cloud. Our gateway uses 100% Replicate-compatible format, so you can use the official Replicate SDK or plain HTTP.

Authentication: API Key or OAuth token
Required Scopes (OAuth): ai:images (for image models), ai:predictions (general)

Replicate hosts thousands of open-source ML models including:

  • Image Generation - Flux, Stable Diffusion, DALL-E
  • Video Generation - Stable Video, AnimateDiff
  • Image Enhancement - Upscaling, restoration, editing
  • Text-to-Speech - Voice generation
  • Custom Models - Community-built models

Use Predictions for models that:

  • Take 10+ seconds to run
  • Generate images, videos, or audio
  • Need async execution (start now, check later)

For fast chat models (< 1 second), use the Chat API instead.

How It Works

Async Flow:

  1. Create → Get prediction ID immediately
  2. Poll → Check status every few seconds
  3. Complete → Get output when status === "succeeded"

Create Prediction

Start an async prediction.

Endpoint: POST /api/v1/predictions

import Replicate from 'replicate'
 
const replicate = new Replicate({
  auth: 'YOUR_API_KEY',
  baseUrl: 'https://hypery.ai/api/v1'
})
 
const prediction = await replicate.predictions.create({
  model: 'black-forest-labs/flux-schnell',
  input: {
    prompt: 'a cat wearing sunglasses'
  }
})
 
console.log(prediction.id)

Response:

{
  "id": "abc123",
  "status": "starting"
}

Get Prediction

Check if it's done.

Endpoint: GET /api/v1/predictions/:id

const prediction = await replicate.predictions.get('abc123')
 
console.log(prediction.status)   // "processing" or "succeeded"
console.log(prediction.output)   // Image URL when done

Response (succeeded):

{
  "id": "abc123",
  "status": "succeeded",
  "output": ["https://...image.jpg"],
  "metrics": {
    "predict_time": 12.5
  }
}

Output Fields

FieldTypeDescription
idstringPrediction identifier
statusstringCurrent status (see status values below)
outputarray | nullGenerated images (URLs) when succeeded
errorstring | nullError message when failed
metricsobjectPerformance data (predict_time in seconds)
created_atstringWhen prediction was created
started_atstring | nullWhen processing started
completed_atstring | nullWhen prediction finished

Wait for Completion

Poll until done (with the SDK, this is automatic).

// SDK handles polling automatically
const output = await replicate.run(
  'black-forest-labs/flux-schnell',
  { input: { prompt: 'a sunset' } }
)
 
console.log(output[0])  // Image URL

The Replicate SDK automatically polls for you. With fetch/requests, you need to poll manually.


Input Options

Customize your generation:

OptionTypeDefaultDescription
promptstringRequiredWhat to generate
widthnumber1024Image width
heightnumber1024Image height
num_outputsnumber1How many images (1-4)

Example:

{
  "input": {
    "prompt": "a sunset",
    "width": 1024,
    "height": 768,
    "num_outputs": 2
  }
}

Status Values

StatusMeaningNext Step
startingQueuedKeep polling
processingRunningKeep polling
succeededDone ✓Get output
failedError ✗Check error

SDK Setup

Install the Replicate SDK:

npm install replicate

Configure it to use Hypery:

import Replicate from 'replicate'
 
const replicate = new Replicate({
  auth: process.env.GATEWAY_API_KEY,
  baseUrl: 'https://hypery.ai/api/v1'
})

Common Errors

CodeErrorFix
401UnauthorizedCheck API key
429Out of creditsAdd credits
400Invalid modelCheck model name

Next Steps