0

Get a file

by
Published Oct 17, 2025

Get the details of a file. Example cURL request: ```console curl -s \ -H "Authorization: Token $REPLICATE_API_TOKEN" \ https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o ```

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 file
7
 * Get the details of a file.
8

9
Example cURL request:
10

11
```console
12
curl -s \
13
  -H "Authorization: Token $REPLICATE_API_TOKEN" \
14
  https://api.replicate.com/v1/files/cneqzikepnug6xezperrr4z55o
15
```
16

17
 */
18
export async function main(auth: Replicate, file_id: string) {
19
  const url = new URL(`https://api.replicate.com/v1/files/${file_id}`);
20

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