Skip to content

Commit 1c3c0b3

Browse files
authored
Document trainings methods (#61)
* Document training methods * Formatting
1 parent 06db0de commit 1c3c0b3

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,99 @@ const response = await replicate.predictions.list();
304304
}
305305
```
306306

307+
### `replicate.trainings.create`
308+
309+
```js
310+
const response = await replicate.trainings.create(options);
311+
```
312+
313+
| name | type | description |
314+
| ------------------------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- |
315+
| `options.version` | string | **Required**. The model version |
316+
| `options.destination` | string | **Required**. The destination for the trained version in the form `{username}/{model_name}` |
317+
| `options.input` | object | **Required**. An object with the models inputs |
318+
| `options.webhook` | string | An HTTPS URL for receiving a webhook when the training has new output |
319+
| `options.webhook_events_filter` | string[] | You can change which events trigger webhook requests by specifying webhook events (`start` \| `output` \| `logs` \| `completed`) |
320+
321+
```jsonc
322+
{
323+
"id": "zz4ibbonubfz7carwiefibzgga",
324+
"version": "{version}",
325+
"status": "starting",
326+
"input": {
327+
"text": "..."
328+
},
329+
"output": null,
330+
"error": null,
331+
"logs": null,
332+
"started_at": null,
333+
"created_at": "2023-03-28T21:47:58.566434Z",
334+
"completed_at": null
335+
}
336+
```
337+
338+
### `replicate.trainings.get`
339+
340+
```js
341+
const response = await replicate.trainings.get(training_id);
342+
```
343+
344+
| name | type | description |
345+
| ------------- | ------ | ----------------------------- |
346+
| `training_id` | number | **Required**. The training id |
347+
348+
```jsonc
349+
{
350+
"id": "zz4ibbonubfz7carwiefibzgga",
351+
"version": "{version}",
352+
"status": "succeeded",
353+
"input": {
354+
"data": "..."
355+
"param1": "..."
356+
},
357+
"output": {
358+
"version": "..."
359+
},
360+
"error": null,
361+
"logs": null,
362+
"webhook_completed": null,
363+
"started_at": null,
364+
"created_at": "2023-03-28T21:47:58.566434Z",
365+
"completed_at": null
366+
}
367+
```
368+
369+
### `replicate.trainings.list`
370+
371+
```js
372+
const response = await replicate.trainings.list();
373+
```
374+
375+
`replicate.trainings.list()` takes no arguments.
376+
377+
```jsonc
378+
{
379+
"previous": null,
380+
"next": "https://api.replicate.com/v1/trainings?cursor=cD0yMDIyLTAxLTIxKzIzJTNBMTglM0EyNC41MzAzNTclMkIwMCUzQTAw",
381+
"results": [
382+
{
383+
"id": "jpzd7hm5gfcapbfyt4mqytarku",
384+
"version": "b21cbe271e65c1718f2999b038c18b45e21e4fba961181fbfae9342fc53b9e05",
385+
"urls": {
386+
"get": "https://api.replicate.com/v1/trainings/jpzd7hm5gfcapbfyt4mqytarku",
387+
"cancel": "https://api.replicate.com/v1/trainings/jpzd7hm5gfcapbfyt4mqytarku/cancel"
388+
},
389+
"created_at": "2022-04-26T20:00:40.658234Z",
390+
"started_at": "2022-04-26T20:00:84.583803Z",
391+
"completed_at": "2022-04-26T20:02:27.648305Z",
392+
"source": "web",
393+
"status": "succeeded"
394+
}
395+
/* ... */
396+
]
397+
}
398+
```
399+
307400
### `replicate.paginate`
308401

309402
Pass another method as an argument to iterate over results

0 commit comments

Comments
 (0)