0

Get a collection of models

by
Published Oct 17, 2025

Example cURL request: ```console curl -s \ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ https://api.replicate.com/v1/collections/super-resolution ``` The response will be a collection object with a nested list of the models in that collection: ```json { "name": "Super resolution", "slug": "super-resolution", "description": "Upscaling models that create high-quality images from low-quality images.", "models": [...] } ```

Script replicate Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Replicate = {
3
  token: string;
4
};
5
/**
6
 * Get a collection of models
7
 * Example cURL request:
8

9
```console
10
curl -s \
11
  -H "Authorization: Bearer $REPLICATE_API_TOKEN" \
12
  https://api.replicate.com/v1/collections/super-resolution
13
```
14

15
The response will be a collection object with a nested list of the models in that collection:
16

17
```json
18
{
19
  "name": "Super resolution",
20
  "slug": "super-resolution",
21
  "description": "Upscaling models that create high-quality images from low-quality images.",
22
  "models": [...]
23
}
24
```
25

26
 */
27
export async function main(auth: Replicate, collection_slug: string) {
28
  const url = new URL(
29
    `https://api.replicate.com/v1/collections/${collection_slug}`,
30
  );
31

32
  const response = await fetch(url, {
33
    method: "GET",
34
    headers: {
35
      Authorization: "Bearer " + auth.token,
36
    },
37
    body: undefined,
38
  });
39
  if (!response.ok) {
40
    const text = await response.text();
41
    throw new Error(`${response.status} ${text}`);
42
  }
43
  return await response.text();
44
}
45