Scaffold Replicate apps with one command
Posted by @jakedahn and @mattrothenberg
You can now scaffold a fully-configured development environment for your project with Replicate’s CLI.
It sets up a development environment, installs the dependencies you need, configures Replicate's client libraries and gives you some working code to get started with.
Prerequisites
There are still a few things you’ll need to install before you can get started.
- Install Replicate’s CLI using Homebrew or follow the instructions for your operating system.
- Install and set up Git on your machine. This is required to clone a template.
- If bootstrapping a Node.js development environment, you’ll need to install Node.js and npm.
- If bootstrapping a Python development environment, you’ll need to install Python and pip.
Ready, set, scaffold
First things first, be sure to create an account on Replicate and set your access token as an environment variable. Replicate’s CLI will use this access token to authenticate your request when you run the scaffold
command.
The scaffold command works by bootstrapping a development environment for you based on a prediction you’ve already created, or have access to. There are three inputs you can pass to the command:
- a prediction ID or URL
- the name of the template you want to use (
node
orpython
at the time of writing) - the path to a directory where you want the starter project to live
Node example
Let’s say you want to set up a Node environment to do things like: generate studio photos of cats, chat with a llama, or animate videos.
The Python example works in a similar way, except you’ll need to pass python
as the template name. We’re working on adding support for more languages. If you have a language you’d like to see supported, please open a pull request on the CLI GitHub repository.
Troubleshooting
Everyone’s development environment looks a little different, so if you run into any issues, please don’t hesitate to reach out to us on Discord or via an issue on the CLI GitHub repository.
Some of the most common issues we’ve seen are:
-
Git is not installed - If you see an error like
git: command not found
, you’ll need to install Git on your machine. -
Error: failed to create client: REPLICATE_API_TOKEN environment variable not set – If you see this after running a command, it means you probably haven’t set your access token as an environment variable.
You can do this by logging in, copying your access token, then running
export REPLICATE_API_TOKEN=your-token
in your terminal.
Up, up, and away
Just as scaffolding supports the construction of a physical building, we hope our new scaffold
command supports the construction of your next Replicate project.
We’d love to hear from you about features or starter templates you’d like to see added to the CLI. The best way to do this is to submit an issue or pull request on the CLI GitHub repository..
Let us know what you end up building on X or Discord.
Happy hacking!