Skip to content

Commit be0fcee

Browse files
authored
Update README with deployments methods (#228)
1 parent 1c98382 commit be0fcee

File tree

1 file changed

+107
-1
lines changed

1 file changed

+107
-1
lines changed

README.md

Lines changed: 107 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const app = new Hono();
108108
app.get('/webhooks/replicate', async (c) => {
109109
// Get the prediction from the request.
110110
const prediction = await c.req.json();
111-
console.log(prediction);
111+
console.log(prediction);
112112
//=> {"id": "xyz", "status": "successful", ... }
113113

114114
// Acknowledge the webhook.
@@ -828,6 +828,112 @@ const response = await replicate.deployments.predictions.create(deployment_owner
828828
Use `replicate.wait` to wait for a prediction to finish,
829829
or `replicate.predictions.cancel` to cancel a prediction before it finishes.
830830

831+
### `replicate.deployments.list`
832+
833+
List your deployments.
834+
835+
```js
836+
const response = await replicate.deployments.list();
837+
```
838+
839+
```jsonc
840+
{
841+
"next": null,
842+
"previous": null,
843+
"results": [
844+
{
845+
"owner": "acme",
846+
"name": "my-app-image-generator",
847+
"current_release": { /* ... */ }
848+
}
849+
/* ... */
850+
]
851+
}
852+
```
853+
854+
### `replicate.deployments.create`
855+
856+
Create a new deployment.
857+
858+
```js
859+
const response = await replicate.deployments.create(options);
860+
```
861+
862+
| name | type | description |
863+
| ----------------------- | ------ | -------------------------------------------------------------------------------- |
864+
| `options.name` | string | Required. Name of the new deployment |
865+
| `options.model` | string | Required. Name of the model in the format `{username}/{model_name}` |
866+
| `options.version` | string | Required. ID of the model version |
867+
| `options.hardware` | string | Required. SKU of the hardware to run the deployment on (`cpu`, `gpu-a100`, etc.) |
868+
| `options.min_instances` | number | Minimum number of instances to run. Defaults to 0 |
869+
| `options.max_instances` | number | Maximum number of instances to scale up to based on traffic. Defaults to 1 |
870+
871+
```jsonc
872+
{
873+
"owner": "acme",
874+
"name": "my-app-image-generator",
875+
"current_release": {
876+
"number": 1,
877+
"model": "stability-ai/sdxl",
878+
"version": "da77bc59ee60423279fd632efb4795ab731d9e3ca9705ef3341091fb989b7eaf",
879+
"created_at": "2024-03-14T11:43:32.049157Z",
880+
"created_by": {
881+
"type": "organization",
882+
"username": "acme",
883+
"name": "Acme, Inc.",
884+
"github_url": "https://github.com/replicate"
885+
},
886+
"configuration": {
887+
"hardware": "gpu-a100",
888+
"min_instances": 1,
889+
"max_instances": 0
890+
}
891+
}
892+
}
893+
```
894+
895+
### `replicate.deployments.update`
896+
897+
Update an existing deployment.
898+
899+
```js
900+
const response = await replicate.deployments.update(deploymentOwner, deploymentName, options);
901+
```
902+
903+
| name | type | description |
904+
| ----------------------- | ------ | -------------------------------------------------------------------------------- |
905+
| `deploymentOwner` | string | Required. Owner of the deployment |
906+
| `deploymentName` | string | Required. Name of the deployment to update |
907+
| `options.model` | string | Name of the model in the format `{username}/{model_name}` |
908+
| `options.version` | string | ID of the model version |
909+
| `options.hardware` | string | Required. SKU of the hardware to run the deployment on (`cpu`, `gpu-a100`, etc.) |
910+
| `options.min_instances` | number | Minimum number of instances to run |
911+
| `options.max_instances` | number | Maximum number of instances to scale up to |
912+
913+
```jsonc
914+
{
915+
"owner": "acme",
916+
"name": "my-app-image-generator",
917+
"current_release": {
918+
"number": 2,
919+
"model": "stability-ai/sdxl",
920+
"version": "39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
921+
"created_at": "2024-03-14T11:43:32.049157Z",
922+
"created_by": {
923+
"type": "organization",
924+
"username": "acme",
925+
"name": "Acme, Inc.",
926+
"github_url": "https://github.com/replicate"
927+
},
928+
"configuration": {
929+
"hardware": "gpu-a100",
930+
"min_instances": 1,
931+
"max_instances": 0
932+
}
933+
}
934+
}
935+
```
936+
831937
### `replicate.paginate`
832938

833939
Pass another method as an argument to iterate over results

0 commit comments

Comments
 (0)