replicate / replicate-python

Python client for Replicate
https://replicate.com
Apache License 2.0
696 stars 194 forks source link

Using API to Enable/Disable Deployments in Scripts #282

Closed talhen123 closed 3 months ago

talhen123 commented 3 months ago

Hello,

I'm currently working on automating some of our processes and was wondering if it's possible to use an API to programmatically enable or disable deployments.

mattt commented 3 months ago

Hi @talhen123. Yes, you can use the Python client library to enable and disable deployments.

To disable a deployment, update with min_instances and max_instances set to 0:

import replicate

replicate.deployments.update(
    deployment_owner="acme", 
    deployment_name="image-upscaler", 
    min_instances=0,
    max_instances=0
)

To enable a deployment, update max_instances to a value greater than 0:

replicate.deployments.update(
    deployment_owner="acme", 
    deployment_name="image-upscaler", 
    max_instances=1
)