agentsclimarketplace

Replicate handler

Skill ComeOnOliver/skillshub/skills/aiskillstore/marketplace/aayushbaniya2006/replicate-handler

Integrate with Replicate AI for running models (image generation, LLMs, etc.).From its SKILL.md

Install
npx -y skills add ComeOnOliver/skillshub --skill replicate-handler

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

2.0 KB, 464 tokens by cl100k_base, as published. Nobody here has run it

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.

What ships with it

21.6 KB alongside SKILL.md

GitHub clipped this repository’s file list, so this is at least 2 files and may be more.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.