# replicate

Running models on Replicate: a prediction waited for, one streamed, or one
kept as a row and followed by a job (and the webhook) until it ends; files
in and out. The whole of it is [docs/replicate.md](../../docs/replicate.md).

```text
use "pkg:replicate/replicate.mote"

let p = replicateRun("owner/model:<version>", {prompt: "a lamp"}, 60)?
let run = replicateStart("owner/model:<version>", {prompt}, `art:${me.id}`, "")?
fn replicateDone(r: ReplicateRun): bool        // told once, when a kept run ends
```

Settings: `REPLICATE_KEY` (a secret); `REPLICATE_WEBHOOK` and
`REPLICATE_SECRET` for the webhook; `REPLICATE_API` for a stand-in.

| File | |
|---|---|
| `replicate.mote` | The calls, `ReplicateRun`, `job fn replicateFollow`, the route `POST /replicate/webhook`. |
| `tests.mote` | Its tests: `use "pkg:replicate/tests.mote"`, then `mote test`. |

**Not yet run against Replicate**: only against a stand-in of its API
(`tests/all.sh real_svc_replicate`).
