Skip to content
Replicate: Run Models

Replicate: Run ModelsSkill

Added to Onei
Apache-2.0
Repository Docs

Summary

Replicate's official skill for running models via its API — predictions, polling, Prefer: wait, webhooks with signature validation, streaming and file handling.

Features

  • Fetch and validate against each model's OpenAPI schema before calling it
  • Three output paths: poll, Prefer: wait (fast models only), or webhook
  • Webhook signature validation and event filtering
  • SSE streaming for language models
  • Concurrency, prediction lifetime, and the one-hour expiry on output URLs

Install This Skill

Add this skill to your favorite AI agent in a few steps.

Any AI agent

This skill is plain instructions — it works with any assistant that accepts custom instructions or system prompts.

  1. Copy the skill content with the button below.
  2. Paste it into your agent's instruction file or system prompt (for example AGENTS.md, .cursorrules, or a custom instructions field).
  3. Ask the agent to apply the skill whenever the task matches.

Skill Content

Markdown Content

Copy this content and use it with your preferred AI agent

---
name: run-models
description: Run AI models on Replicate via predictions, webhooks, and streaming.
---

## Docs

- Reference: <https://replicate.com/docs/llms.txt>
- OpenAPI schema: <https://api.replicate.com/openapi.json>
- MCP server: <https://mcp.replicate.com>
- Per-model docs: `https://replicate.com/{owner}/{model}/llms.txt`
- Set `Accept: text/markdown` when requesting docs pages for Markdown responses.

## Workflow

1. **Choose the right model** - Search with the API or ask the user.
2. **Get model metadata** - Fetch input and output schema via API.
3. **Create prediction** - POST to /v1/predictions.
4. **Poll for results** - GET prediction until status is "succeeded".
5. **Return output** - Usually URLs to generated content.

## Three ways to get output

1. Create a prediction, store its id from the response, and poll until completion.
2. Set a `Prefer: wait` header when creating a prediction for a blocking synchronous response. Only recommended for very fast models. Max 60 seconds.
3. Set an HTTPS webhook URL when creating a prediction, and Replicate will POST to that URL when the prediction completes.

## Guidelines

- Use the `POST /v1/predictions` endpoint, as it supports both official and community models.
- Every model has its own OpenAPI schema. Always fetch and check model schemas to make sure you're setting valid inputs. Even popular models change their schemas.
- Validate input parameters against schema constraints (`minimum`, `maximum`, `enum` values). Don't generate values that violate them.
- When unsure about a parameter value, use the model's default example or omit the optional parameter.
- Don't set optional inputs unless you have a reason to. Stick to the required inputs and let the model's defaults do the work.
- Use HTTPS URLs for file inputs whenever possible. You can also send base64-encoded files, but they should be avoided.
- Fire off multiple predictions concurrently. Don't wait for one to finish before starting the next.
- Output file URLs expire after 1 hour, so back them up if you need to keep them, using a service like Cloudflare R2.
- Webhooks are a good mechanism for receiving and storing prediction output.

## Predictions

- A prediction goes through these states: `starting` -> `processing` -> `succeeded` / `failed` / `canceled`.
- Official models use `owner/name` format. Community models require `owner/name:version_id`.
- The `POST /v1/predictions` endpoint handles both.

## Webhooks

- Set `webhook` to an HTTPS URL when creating a prediction. Replicate POSTs the full prediction object when it completes.
- Filter events with `webhook_events_filter`: `start`, `output`, `logs`, `completed`.
- Validate webhook signatures using the `Webhook-ID`, `Webhook-Timestamp`, and `Webhook-Signature` headers. Get the signing secret from `GET /v1/webhooks/default/secret`.

## Prediction lifetime

- Set `lifetime` to auto-cancel predictions that run too long (e.g. `30s`, `5m`, `1h`). Measured from creation time.

## Streaming

- Language models that support streaming include a `stream` URL in the response. Use SSE to receive incremental output.

## File handling

- Prefer HTTPS URLs for file inputs. Output URLs from one prediction can be passed directly as file inputs to the next model.
- Output file URLs expire after 1 hour. Download and store them immediately if you need to keep them.

## Multi-model workflows

- Chain models by passing output URLs as file inputs to the next model.
- Start all independent predictions in parallel, then collect results.
- Output URLs are valid for 1 hour, which is enough for pipeline steps.

Usage Instructions

Learn how to use this skill with different AI agents.

Generic Instructions

Works with any agent supporting the Agent Skills standard — Claude Code, OpenCode, OpenAI Codex and others:

npx skills add replicate/skills

This installs all seven Replicate skills; the agent picks run-models when the task is executing a model. Set REPLICATE_API_TOKEN in the environment before use.

Description

One of seven official skills published by Replicate for building on its model API. This is the execution half: how to actually get output out of a model.

Replicate hosts thousands of image, video, audio and language models behind one prediction API, and the failure modes are consistent enough to be worth writing down. This skill encodes them. Always fetch the model's own OpenAPI schema before building inputs — every model has its own, popular models change theirs, and violating a minimum, maximum or enum constraint is the most common way a call fails. Don't set optional inputs without a reason; the defaults are usually the tuned ones.

It covers the three ways to collect output and when each is right: create-and-poll for anything slow, a Prefer: wait header for a blocking response from fast models only (60-second ceiling), and an HTTPS webhook for production. The webhook section is the part most integrations get wrong, and the skill spells out the signature validation using the Webhook-ID, Webhook-Timestamp and Webhook-Signature headers against the secret from GET /v1/webhooks/default/secret.

Also here: the prediction state machine (startingprocessingsucceeded/failed/canceled), the owner/name versus owner/name:version_id distinction between official and community models, lifetime for auto-cancelling runaway predictions, SSE streaming for language models, and the operational detail that bites people in production — output file URLs expire after one hour, so back them up to your own storage if you need to keep them.

The sibling skills in the same repository cover finding models, comparing them on cost and quality, packaging your own with Cog, publishing them, and prompting image and video models.

Related Skills

New

Build crash-safe AI agents on AgentKit and step.ai — durable tool calls, human-in-the-loop approval, realtime progress, and when not to reach for an agent loop at all.

2 views

Inngest's durable-execution playbook as an agent skill — steps and memoisation, event and cron triggers, idempotency, cancellation, retries and non-retriable errors.

2 views
New

Temporal's official skill for building durable workflows — SDK patterns across seven languages, plus the determinism rules that decide whether a workflow survives a replay.

6 views
Browse all skills →