0

Get a model

by
Published Oct 17, 2025

Example cURL request: ```console curl -s \ -H "Authorization: Bearer $REPLICATE_API_TOKEN" \ https://api.

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 model
7
 * Example cURL request:
8

9
```console
10
curl -s \
11
  -H "Authorization: Bearer $REPLICATE_API_TOKEN" \
12
  https://api.
13
 */
14
export async function main(
15
  auth: Replicate,
16
  model_owner: string,
17
  model_name: string,
18
) {
19
  const url = new URL(
20
    `https://api.replicate.com/v1/models/${model_owner}/${model_name}`,
21
  );
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: "Bearer " + auth.token,
27
    },
28
    body: undefined,
29
  });
30
  if (!response.ok) {
31
    const text = await response.text();
32
    throw new Error(`${response.status} ${text}`);
33
  }
34
  return await response.text();
35
}
36