Skip to content

Update README with deployments methods #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 107 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const app = new Hono();
app.get('/webhooks/replicate', async (c) => {
// Get the prediction from the request.
const prediction = await c.req.json();
console.log(prediction);
console.log(prediction);
//=> {"id": "xyz", "status": "successful", ... }

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

### `replicate.deployments.list`

List your deployments.

```js
const response = await replicate.deployments.list();
```

```jsonc
{
"next": null,
"previous": null,
"results": [
{
"owner": "acme",
"name": "my-app-image-generator",
"current_release": { /* ... */ }
}
/* ... */
]
}
```

### `replicate.deployments.create`

Create a new deployment.

```js
const response = await replicate.deployments.create(options);
```

| name | type | description |
| ----------------------- | ------ | -------------------------------------------------------------------------------- |
| `options.name` | string | Required. Name of the new deployment |
| `options.model` | string | Required. Name of the model in the format `{username}/{model_name}` |
| `options.version` | string | Required. ID of the model version |
| `options.hardware` | string | Required. SKU of the hardware to run the deployment on (`cpu`, `gpu-a100`, etc.) |
| `options.min_instances` | number | Minimum number of instances to run. Defaults to 0 |
| `options.max_instances` | number | Maximum number of instances to scale up to based on traffic. Defaults to 1 |

```jsonc
{
"owner": "acme",
"name": "my-app-image-generator",
"current_release": {
"number": 1,
"model": "stability-ai/sdxl",
"version": "da77bc59ee60423279fd632efb4795ab731d9e3ca9705ef3341091fb989b7eaf",
"created_at": "2024-03-14T11:43:32.049157Z",
"created_by": {
"type": "organization",
"username": "acme",
"name": "Acme, Inc.",
"github_url": "https://github.com/replicate"
},
"configuration": {
"hardware": "gpu-a100",
"min_instances": 1,
"max_instances": 0
}
}
}
```

### `replicate.deployments.update`

Update an existing deployment.

```js
const response = await replicate.deployments.update(deploymentOwner, deploymentName, options);
```

| name | type | description |
| ----------------------- | ------ | -------------------------------------------------------------------------------- |
| `deploymentOwner` | string | Required. Owner of the deployment |
| `deploymentName` | string | Required. Name of the deployment to update |
| `options.model` | string | Name of the model in the format `{username}/{model_name}` |
| `options.version` | string | ID of the model version |
| `options.hardware` | string | Required. SKU of the hardware to run the deployment on (`cpu`, `gpu-a100`, etc.) |
| `options.min_instances` | number | Minimum number of instances to run |
| `options.max_instances` | number | Maximum number of instances to scale up to |

```jsonc
{
"owner": "acme",
"name": "my-app-image-generator",
"current_release": {
"number": 2,
"model": "stability-ai/sdxl",
"version": "39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
"created_at": "2024-03-14T11:43:32.049157Z",
"created_by": {
"type": "organization",
"username": "acme",
"name": "Acme, Inc.",
"github_url": "https://github.com/replicate"
},
"configuration": {
"hardware": "gpu-a100",
"min_instances": 1,
"max_instances": 0
}
}
}
```

### `replicate.paginate`

Pass another method as an argument to iterate over results
Expand Down