agentsclimarketplace

Replicate handler

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

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

Install
npx -y skills add aiskillstore/marketplace --skill replicate-handler

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

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

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: 2 files

34.2 KB alongside SKILL.md

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.