Docs
- Cog reference: https://cog.run/llms.txt
cog pushreference: https://cog.run/cli#cog-push- cog-safe-push: https://github.com/replicate/cog-safe-push
- Model CI template: https://github.com/replicate/model-ci-template
- Continuous deployment guide: https://replicate.com/docs/guides/continuous-model-deployment
When to use this skill
- You have a working Cog project (see
build-modelsif you don't yet). - You want to publish a private or public model on Replicate.
- You're releasing a new version of an existing model and want to avoid breaking changes.
- You're setting up CI/CD for model releases.
Prerequisites
- Cog installed and
cog loginagainstr8.im(orecho $TOKEN | cog login --token-stdin). - A model created at
replicate.com/{owner}/{name}via the API, web UI, orr8-modelCLI. REPLICATE_API_TOKENset in your environment.
Plain cog push
The 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 (recommended for any model with users)
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:
- Lint
predict.pywith ruff. - Create a private test model
owner/my-model-testif missing. - Push the local Cog model to the test model.
- Lint the schema (descriptions, defaults, etc.).
- Check schema compatibility against the live
owner/my-modelversion. - Run prediction comparisons between live and test versions.
- Fuzz the test model with AI-generated inputs.
- If everything passes, push to
owner/my-model.
cog-safe-push.yaml schema
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.
CI/CD: GitHub Actions
Two paths, depending on how much glue you want.
Path A: roll your own
Add a concurrency: block so PR builds cancel each other while main-branch pushes queue:
Path B: reusable workflow from model-ci-template
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 withif/elif [[ "$MODEL" == "..." ]]blocks listing valid model names.- Secrets:
COG_TOKEN,REPLICATE_API_TOKEN,ANTHROPIC_API_KEY.
Multi-model matrix pushes
Pattern from replicate/cog-flux: one repo, N variants, push them in parallel.
Two-pass push for proxy / official models
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.
Deployments
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.
Monitoring published models
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.
Guidelines
- Don't break schema compatibility unless you mean to. cog-safe-push catches it;
--ignore-schema-compatibilityis the opt-out. - Pin
test_hardwareso test pushes are reproducible. - Use
--no-pushfor dry runs in PR CI; full push on merge to main or on version tags. - Push from CI rather than laptops once you have users.
- Use
compare_outputs: falsefor stochastic models. Usematch_prompt:for image/video outputs (VLM judgment),match_url:for binary outputs you control,jq_query:for JSON,error_contains:for negative tests. - Never commit
REPLICATE_API_TOKENorANTHROPIC_API_KEY. Use repo secrets. - For models with weights > 1GB, push with
--separate-weights.
Production references
- https://github.com/replicate/cog-safe-push — the tool itself, plus its config schema.
- https://github.com/replicate/model-ci-template — reusable GitHub Actions workflow.
- https://github.com/replicate/cog-official-template — proxy/official model template.
- https://github.com/replicate/cog-flux/blob/main/.github/workflows/push.yaml — matrix push across FLUX variants.
- https://github.com/replicate/cog-comfyui/blob/main/.github/workflows/ci.yaml — ComfyUI model CI with custom-node install step.
- https://github.com/replicate/cog-pagerduty-check — hourly canary pattern.


