Back to list
aiskillstore

replicate-handler

by aiskillstore

Security-audited skills for Claude, Codex & Claude Code. One-click install, quality verified.

102🍴 3📅 Jan 23, 2026

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.

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.

// 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 for the full type definitions of the Replicate SDK.

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

+5
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon