API for listing public models

October 5, 2023

Replicate's API now has an endpoint for listing public models.

You can use it to discover newly published models, and to build your own tools for exploring Replicate's ecosystem of thousands of open-source models.

cURL usage

Here's an example that uses cURL and jq to fetch the URLs of the 25 most recently updated public models:

 curl -s -H "Authorization: Token $REPLICATE_API_TOKEN" \
    https://api.replicate.com/v1/models | jq ".results[].url"

The response is a paginated JSON array of model objects:

{
  "next": null,
  "previous": null,
  "results": [
    {
      "url": "https://replicate.com/replicate/hello-world",
      "owner": "replicate",
      "name": "hello-world",
      "description": "A tiny model that says hello",
      "visibility": "public",
      "github_url": "https://github.com/replicate/cog-examples",
      "paper_url": null,
      "license_url": null,
      "run_count": 5681081,
      "cover_image_url": "...",
      "default_example": {...},
      "latest_version": {...}
    }
  ]
}

JavaScript usage

We've added this new operation to the Replicate JavaScript client:

npm install replicate@latest

Then:

import Replicate from "replicate";
const replicate = new Replicate();
 
// get recently published models
const latestModels = await replicate.models.list();
console.log(latestModels)
 
// paginate and get all models
const allModels = []
for await (const batch of replicate.paginate(replicate.models.list)) {
  allModels.push(...batch);
}
console.log(allModels)

Python usage

We've added this new operation to the Replicate Python client:

pip install --upgrade replicate

Then:

import replicate
 
models = replicate.models.list()
print(models)

Making your own models discoverable

If you’re deploying your own public models to Replicate and want others to be able to discover them, make sure they meet the following criteria:

  • The model is public.
  • The model has at least one published version.
  • The model has at least one example prediction. To add an example, create a prediction using the web interface then click the “Add to examples” button below the prediction output.