Skip to content
Back to skills

Replicate Handler

ASecurity

Integrate with Replicate AI for running models (image generation, LLMs, etc.).

  • 416 stars
  • 0 votes
  • 1 copy
  • 3 views
  • Added February 7, 2026
ai-agentstypescriptapi

Works with

  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 3 files and shows the line behind each finding

Scanned February 12, 2026

npx -y skills add aiskillstore/marketplace --skill replicate-handler --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Replicate Handler?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Replicate Handler
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/aiskillstore-replicate-handler/badge)](https://www.skillsdirectory.com/skills/aiskillstore-replicate-handler)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: replicate-handler
description: Integrate with Replicate AI for running models (image generation, LLMs, etc.).
---

# Replicate Handler

## Setup

1.  **Install**: `npm install replicate`
2.  **Environment**: Add `REPLICATE_API_TOKEN` to `.env` (and `.env.local`).

## Usage Patterns

### 1. Quick Run (Short Tasks)
For models that complete quickly (seconds), use `replicate.run`.

```typescript
import Replicate from "replicate";

const replicate = new Replicate({
  auth: process.env.REPLICATE_API_TOKEN,
});

// Run a model
const output = await replicate.run(
  "owner/model:version",
  {
    input: {
      prompt: "..."
    }
  }
);
```

### 2. Long-Running Tasks (with Inngest)
For tasks that might timeout (video generation, large models), use Inngest's `step.sleep` to poll for completion.

```typescript
// In an Inngest function
export const generateVideo = inngest.createFunction(
  { id: "generate-video" },
  { event: "video.generate" },
  async ({ event, step }) => {
    
    // 1. Create Prediction
    const prediction = await step.run("create-prediction", async () => {
      return await replicate.predictions.create({
        version: "model-version-hash",
        input: { prompt: event.data.prompt }
      });
    });

    let status = prediction.status;
    let result = prediction;

    // 2. Poll for Completion
    while (status !== "succeeded" && status !== "failed" && status !== "canceled") {
      // Sleep for 5s (Inngest handles this without consuming server time)
      await step.sleep("wait-for-model", "5s");

      // Check status
      result = await step.run("check-status", async () => {
        return await replicate.predictions.get(prediction.id);
      });
      status = result.status;
    }

    // 3. Handle Result
    if (status === "failed") {
      throw new Error(`Replicate failed: ${result.error}`);
    }
    
    return result.output;
  }
);
```

## Types Reference
See [reference.md](reference.md) for the full type definitions of the Replicate SDK.

Files in this skill

  • SKILL.md2 KB
  • reference.md11.4 KB
  • skill-report.json10.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…