Installation and Setup
- Create a Replicate account. Get your API key and set it as an environment variable (
REPLICATE_API_TOKEN
) - Install the Replicate python client with
pip install replicate
Calling a model
Find a model on the Replicate explore page, and then paste in the model name and version in this format:owner-name/model-name:version
For example, for this dolly model, click on the API tab. The model name/version would be: "replicate/dolly-v2-12b:ef0e1aefc61f8e096ebe4db6b2bacc297daf2ef6899f0f7e001ec445893500e5"
Only the model
param is required, but any other model parameters can also be passed in with the format input={model_param: value, ...}
For example, if we were running stable diffusion and wanted to change the image dimensions: