npx skills add ...
npx skills add replicate/skills --skill publish-models
Push and publish custom AI models to Replicate, and set up CI/CD for releasing new model versions safely. Use when running cog push, deploying a model to Replicate, releasing a new version, validating a model with cog-safe-push before publishing, configuring a Replicate deployment, setting up GitHub Actions for model releases, or porting a community model to an official one. Trigger on phrases like "push a model to Replicate", "publish a model", "deploy a model", "release a new version", "cog push", "cog-safe-push", "model CI", "r8.im", or "schema compatibility", and when referencing github.com/replicate/cog-safe-push or github.com/replicate/model-ci-template. Covers cog push, the full cog-safe-push config (test cases, fuzz, deployment, official_model), GitHub Actions patterns, multi-model matrix pushes, and post-publish monitoring. Assumes you already have a working Cog project; see build-models if you need to package one first.
npx skills add replicate/skills --skill publish-models
cog push reference: https://cog.run/cli#cog-pushbuild-models if you don't yet).cog login against r8.im (or echo $TOKEN | cog login --token-stdin).replicate.com/{owner}/{name} via the API, web UI, or r8-model CLI.REPLICATE_API_TOKEN set in your environment.cog pushThe simplest path. Build and upload a new version:
Or set image: r8.im/owner/my-model in cog.yaml and run a bare:
Useful flags:
--separate-weights — store weights in a separate layer; faster cold boots and pushes for models with > 1GB of weights.--x-fast — faster pushes during iteration (skips some validation).--secret id=hf,src=$HOME/.hf_token — pass build-time secrets without baking them into image history.cog-safe-push pushes to a private -test model first, checks schema compatibility against the live version, runs prediction comparisons, and fuzzes inputs. Catches breaking changes before they reach users.
Install:
Required env vars:
REPLICATE_API_TOKENANTHROPIC_API_KEY (Claude judges output similarity for stochastic models)Basic usage:
This will:
predict.py with ruff.owner/my-model-test if missing.owner/my-model version.owner/my-model.Drop a cog-safe-push.yaml in your project root (or cog-safe-push-configs/<variant>.yaml for multi-model repos). All five test-case checker types in one example:
Test case checkers are mutually exclusive: pick exactly one of match_prompt, match_url, error_contains, jq_query, or exact_string per case. Use compare_outputs: false for any stochastic model (diffusion, LLMs); the default true is brittle.
Two paths, depending on how much glue you want.
Add a concurrency: block so PR builds cancel each other while main-branch pushes queue:
For Replicate-style multi-model repos, drop in:
The reusable workflow expects:
cog-safe-push-configs/<model>.yaml — one per model variant.script/select-model — bash file with if/elif [[ "$MODEL" == "..." ]] blocks listing valid model names.COG_TOKEN, REPLICATE_API_TOKEN, ANTHROPIC_API_KEY.Pattern from replicate/cog-flux: one repo, N variants, push them in parallel.
When you maintain a proxy that wraps a third-party API, you push to a private wrapper first, then update the public-facing official model card. Pattern from replicate/cog-official-template:
Set official_model: owner/name in the config so --push-official-model knows where to publish.
Add a deployment block to cog-safe-push.yaml to create or update a Replicate deployment automatically on each push:
Scaling defaults: CPU deployments scale 1-20 instances, GPU deployments scale 0-2. Adjust manually via the API or web UI when needed.
Run an hourly canary that exercises the registry path. Pattern from replicate/cog-pagerduty-check:
Worth doing for any production-critical model, especially when revenue depends on the registry being up.
--ignore-schema-compatibility is the opt-out.test_hardware so test pushes are reproducible.--no-push for dry runs in PR CI; full push on merge to main or on version tags.compare_outputs: false for stochastic models. Use match_prompt: for image/video outputs (VLM judgment), match_url: for binary outputs you control, jq_query: for JSON, error_contains: for negative tests.REPLICATE_API_TOKEN or ANTHROPIC_API_KEY. Use repo secrets.--separate-weights.