TerminalSkills/skills

replicate

Run machine learning models in the cloud via API.

View source

How to use

  1. Copy the installation command and review the source package before installing it in your own agent environment.
  2. Check the source document for required tools, credentials and supported hosts.
  3. Describe your input and desired deliverable; review the output against the source material.
npx skills add https://github.com/TerminalSkills/skills --skill replicate

Before you start

  • Installation does not include a model subscription, API allowance or permission to access your files.
  • Repository stars and installation counts describe activity, not an independent quality or security test.
Original skill document

Rendered from the source repository. Headings, examples, code, tables, links, and referenced images are preserved.

Replicate

Overview

Replicate runs open-source and proprietary models behind one HTTP API: image, video, audio and language models, billed per second of compute (or per output for some official models). You call owner/name for official models, or owner/name:version to pin a community model to an exact version. You can also fine-tune supported models (such as FLUX) and publish your own models packaged with Cog. Clients: replicate on PyPI (1.0.x) and npm (1.x). Model IDs, versions and input fields vary per model, so open the model's API tab on replicate.com before copying inputs.

Instructions

Install and authenticate

bash
pip install replicate          # Python 3.8+
npm install replicate          # Node 18+
export REPLICATE_API_TOKEN="r8_your_token_from_replicate_com_account"

Create tokens at replicate.com/account/api-tokens and keep them in the environment, never in source.

Run a model

Since replicate 1.0.0, run() returns FileOutput objects instead of URL strings for models that output files. Use .read(), iterate the object, or .url; use_file_output=False restores plain URLs.

python
import replicate

outputs = replicate.run(
    "black-forest-labs/flux-schnell",
    input={"prompt": "A futuristic cityscape at sunset, digital art", "num_outputs": 1},
)
for i, image in enumerate(outputs):
    with open(f"city_{i}.webp", "wb") as f:
        f.write(image.read())
    print(image.url)

run() first asks the API to hold the request for up to 60 seconds (wait=1..60; wait=False skips this), then keeps polling until the prediction ends, and raises replicate.exceptions.ModelError if the prediction fails; e.prediction.logs shows why.

typescript
import Replicate from "replicate";
import { writeFile } from "node:fs/promises";

const replicate = new Replicate(); // reads REPLICATE_API_TOKEN
const [image] = await replicate.run("black-forest-labs/flux-schnell", {
  input: { prompt: "A watercolor painting of a robot" },
});
await writeFile("robot.webp", image);

Language models and streaming

python
for event in replicate.stream(
    "meta/meta-llama-3-70b-instruct",
    input={"prompt": "Explain machine learning to a 5-year-old", "max_tokens": 500, "temperature": 0.7},
):
    print(str(event), end="", flush=True)

Language-model input names differ between models (max_tokens vs max_new_tokens, system_prompt); read the model page. Older models such as Llama 2 may be unavailable.

Background predictions and polling

python
import time, replicate

prediction = replicate.predictions.create(
    model="black-forest-labs/flux-schnell",     # official model: no version needed
    input={"prompt": "A cat in space"},
)
while prediction.status not in ("succeeded", "failed", "canceled"):
    time.sleep(2)
    prediction.reload()
if prediction.status == "succeeded":
    print(prediction.output)       # list of URLs when read from the prediction object
else:
    print(prediction.error)

For community models pass version="<64-character version id>" instead of model=. Cancel with prediction.cancel().

Webhooks

python
prediction = replicate.predictions.create(
    model="black-forest-labs/flux-schnell",
    input={"prompt": "A mountain landscape"},
    webhook="https://hooks.shopfront.dev/replicate",
    webhook_events_filter=["completed"],   # start | output | logs | completed
)

Verify every delivery: Replicate signs it with webhook-id, webhook-timestamp and webhook-signature headers. Sign {id}.{timestamp}.{raw body} with the base64 part of the whsec_... key returned by GET https://api.replicate.com/v1/webhooks/default/secret, compare in constant time, and reject old timestamps. The Python client has replicate.webhooks.validate, and the Node client validateWebhook, for this.

Fine-tuning FLUX

SDXL fine-tuning inputs from older guides no longer apply; the supported route is the FLUX trainer.

python
import replicate

trainer = replicate.models.get("replicate/fast-flux-trainer")
training = replicate.trainings.create(
    model="replicate/fast-flux-trainer",
    version=trainer.latest_version.id,
    destination="jdoe/mug-style-flux",           # model you own; create it first at replicate.com/create
    input={
        "input_images": "https://assets.jdoe-studio.com/mug-photos.zip",   # zip of training images (the guide uses about 20)
        "trigger_word": "MUGSTYLE",   # made-up string, not a real word
        "lora_type": "style",         # or "subject"
        "training_steps": 1000,
    },
)
training.reload()
print(training.status)

When it succeeds, run jdoe/mug-style-flux with a prompt containing the trigger word. Training is billed per second on H100s, typically a couple of dollars.

Deploy a custom model with Cog

Install Cog with Homebrew (brew install replicate/tap/cog) or from the release page with its checksum verified, and have Docker running.

yaml
# cog.yaml
build:
  python_version: "3.12"
  python_packages:
    - torch==2.3.1
    - transformers==4.44.0
  gpu: true
predict: "predict.py:Predictor"
python
# predict.py
from cog import BasePredictor, Input

class Predictor(BasePredictor):
    def setup(self):
        """Load weights once per container start."""
        from transformers import pipeline
        self.pipe = pipeline("text-generation", model="./model", device=0)

    def predict(
        self,
        prompt: str = Input(description="Input text"),
        max_tokens: int = Input(description="Tokens to generate", default=100, ge=1, le=1000),
    ) -> str:
        return self.pipe(prompt, max_new_tokens=max_tokens)[0]["generated_text"]
bash
cog predict -i prompt="Write a product tagline for a ceramic mug"   # test locally
cog login                                                          # paste your API token
cog push r8.im/jdoe/mug-writer                                     # create the model page first

Examples

Example 1: Generate and save product shots

Request: "Make 4 product photos of a ceramic mug and save them."

python
outputs = replicate.run("black-forest-labs/flux-schnell",
    input={"prompt": "Ceramic coffee mug on oak table, soft morning light", "num_outputs": 4})
for i, img in enumerate(outputs):
    open(f"mug_{i}.webp", "wb").write(img.read())

Result: four mug_0.webp to mug_3.webp files in the working directory; the run is billed per image.

Example 2: Get notified instead of polling

Request: "Start a render and call my server when it finishes."

Use the webhook snippet above. Result: create() returns at once with status starting; Replicate POSTs the final prediction JSON (status succeeded, output URLs) to your endpoint, which should verify the signature and return 2xx.

Guidelines

  • Inputs, outputs and logs of API predictions are deleted after an hour by default; download what you need to keep.
  • Pin owner/name:version for community models so a new model version cannot change your output; official models change without a version pin.
  • Cold starts: a model that has not run recently can take tens of seconds to boot. Use deployments for always-warm capacity.
  • Check prediction.error and logs on failure; do not retry blindly, since failed input validation fails every time.
  • Token handling: keep it in REPLICATE_API_TOKEN; the Cog predict.py can read secrets from inputs, not from files in the image.
  • Do not send private or regulated data to public models without reading Replicate's data-retention page.
from this repository

More skills

All skills
TerminalSkills
Community

3dsmax-rendering

Scripts and configures production rendering in Autodesk 3ds Max with the V-Ray and Corona renderers: output size and files, render elements, denoising, light mix, batch and command-line rendering, and network rendering. Use when a user asks to set up a production render, render several cameras in one batch, render from the command line or on a render farm, add render passes for compositing, or cut render time for archviz and product shots.

installs
0
GitHub stars
180
Updated
Oct 25
TerminalSkills
Community

3dsmax-scripting

Covers scripting Autodesk 3ds Max, the 3D modeling and rendering application, with MAXScript and Python (pymxs): scene manipulation, object creation, material assignment, camera and light setup, batch operations, and file I/O. Use when tasks involve automating repetitive 3ds Max workflows, batch processing scenes, running scripts headless with 3dsmaxbatch, creating custom tools, or scripting scene setup for archviz, product visualization, or VFX.

installs
0
GitHub stars
180
Updated
Oct 25
TerminalSkills
Community

3proxy

3proxy is a small open-source proxy server that runs HTTP/HTTPS, SOCKS4/5, SNI and TCP/UDP port-mapping proxies from one config file. Use when a user asks to set up an HTTP or SOCKS5 proxy, add proxy users and passwords, write 3proxy access rules, chain or rotate upstream (parent) proxies, limit bandwidth, connections or monthly traffic per user, run 3proxy in Docker, or fix a 3proxy.cfg that will not start.

installs
0
GitHub stars
180
Updated
Oct 25
TerminalSkills
Community

a2a-protocol

Builds Agent2Agent (A2A) servers and clients, the open protocol (originally from Google, now under the Linux Foundation) that lets AI agents from different frameworks call each other. Use when the user wants to create an A2A-compliant agent, build an Agent Card, implement task management, connect agents across frameworks, set up agent discovery, handle streaming responses, implement push notifications, or orchestrate multi-agent workflows. Trigger words: a2a, agent to agent, agent2agent, a2a pro

installs
0
GitHub stars
180
Updated
Oct 25