//native
type Replicate = {
token: string;
};
/**
* List available hardware for models
* Example cURL request:
```console
curl -s \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
https://api.replicate.com/v1/hardware
```
The response will be a JSON array of hardware objects:
```json
[
{"name": "CPU", "sku": "cpu"},
{"name": "Nvidia T4 GPU", "sku": "gpu-t4"},
{"name": "Nvidia A40 GPU", "sku": "gpu-a40-small"},
{"name": "Nvidia A40 (Large) GPU", "sku": "gpu-a40-large"},
]
```
*/
export async function main(auth: Replicate) {
const url = new URL(`https://api.replicate.com/v1/hardware`);
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago