How to beginner · 3 min read

How to push model to Replicate

Quick answer
To push a model to Replicate, use the replicate Python package and run replicate.push() with your model directory or Dockerfile. Authenticate by setting the REPLICATE_API_TOKEN environment variable before pushing your model.

PREREQUISITES

  • Python 3.8+
  • Replicate API token (set as REPLICATE_API_TOKEN environment variable)
  • pip install replicate

Setup

Install the official replicate Python package and set your API token as an environment variable for authentication.

bash
pip install replicate
output
Collecting replicate
  Downloading replicate-0.10.0-py3-none-any.whl (20 kB)
Installing collected packages: replicate
Successfully installed replicate-0.10.0

Step by step

Use the replicate package to push your model directory or Dockerfile to Replicate. Below is a complete example pushing a local model folder.

python
import os
import replicate

# Ensure your Replicate API token is set in the environment
# export REPLICATE_API_TOKEN="your_token_here"

# Path to your model directory containing Dockerfile and model files
model_path = "./my-model"

# Push the model to Replicate
model_url = replicate.push(model_path)
print(f"Model pushed successfully: {model_url}")
output
Model pushed successfully: replicate.com/username/model-name:version

Common variations

  • Push with Dockerfile: You can push a model by specifying a directory with a Dockerfile that builds your model environment.
  • Async usage: The replicate package currently supports synchronous push; async is not required.
  • Model versioning: Replicate automatically versions your model on push; you can specify tags in your model metadata.

Troubleshooting

  • If you see AuthenticationError, verify your REPLICATE_API_TOKEN is correctly set.
  • If the push fails due to Docker build errors, check your Dockerfile syntax and dependencies.
  • Ensure your model directory contains all required files including Dockerfile and model weights.

Key Takeaways

  • Use the official replicate Python package to push models programmatically.
  • Set your REPLICATE_API_TOKEN environment variable before pushing.
  • Your model directory must include a valid Dockerfile for building the container.
  • Replicate handles model versioning automatically on each push.
  • Check Docker build logs if the push fails due to environment issues.
Verified 2026-04
Verify ↗